Ejemplo n.º 1
0
    def list_of_error_mount_points(self, mount_points):
        """Returns list of devices which don't have
        enough free space

        :param list mount_points: elements are dicts
                  where key is path to mount point
                  and value is required space for
                  this mount point
        :returns: list where elements are dicts
                  {'path': 'path to mount point',
                   'size': 'required free space'
                   'available': 'available free space'}
        """
        free_space_error_devices = []
        for path, required_size in sorted(mount_points.items()):
            free_space = utils.calculate_free_space(path)

            if free_space < required_size:
                free_space_error_devices.append({
                    'path': path,
                    'size': required_size,
                    'available': free_space
                })

        return free_space_error_devices
    def test_calculate_free_space(self):
        dev_info = mock.Mock()
        dev_info.f_bsize = 1048576
        dev_info.f_bavail = 2
        with mock.patch('fuel_upgrade.utils.os.statvfs',
                        return_value=dev_info) as st_mock:
            self.assertEqual(utils.calculate_free_space('/tmp/dir'), 2)

        st_mock.assert_called_once_with('/tmp/dir/')
Ejemplo n.º 3
0
    def test_calculate_free_space(self):
        dev_info = mock.Mock()
        dev_info.f_bsize = 1048576
        dev_info.f_bavail = 2
        with mock.patch('fuel_upgrade.utils.os.statvfs',
                        return_value=dev_info) as st_mock:
            self.assertEqual(utils.calculate_free_space('/tmp/dir'), 2)

        st_mock.assert_called_once_with('/tmp/dir/')
Ejemplo n.º 4
0
    def list_of_error_mount_points(self, mount_points):
        """Returns list of devices which don't have
        enough free space

        :param list mount_points: elements are dicts
                  where key is path to mount point
                  and value is required space for
                  this mount point
        :returns: list where elements are dicts
                  {'path': 'path to mount point',
                   'size': 'required free space'
                   'available': 'available free space'}
        """
        free_space_error_devices = []
        for path, required_size in sorted(mount_points.items()):
            free_space = utils.calculate_free_space(path)

            if free_space < required_size:
                free_space_error_devices.append({"path": path, "size": required_size, "available": free_space})

        return free_space_error_devices