예제 #1
0
    def test_partitions_policy(self):
        data = {'partitions_policy': "test_value",
                'partitions': 'fake_shema'}

        data_driver = ironic.Ironic(data)

        self.assertEqual('test_value', data_driver.partitions_policy)
예제 #2
0
 def __init__(self, *args, **kwargs):
     super(TestProcessPartition, self).__init__(*args, **kwargs)
     self.driver = ironic.Ironic({})
     self.driver._partition_data = self.mock_part_data = mock.MagicMock()
     self.driver._add_partition = self.mock_add_part = mock.MagicMock()
     self.mock_add_part.return_value = self.mock_part = mock.MagicMock()
     self.driver.get_os_ids = self.mock_get_os_ids = mock.MagicMock()
     self.driver.get_image_ids = self.mock_get_image_ids = mock.MagicMock()
예제 #3
0
    def test_no_device_info(self, mock_scsi_address, mock_get_device_info,
                            mock_get_device_ids):
        data_driver = ironic.Ironic('')
        device = 'fake_device'

        mock_scsi_address.return_value = None
        mock_get_device_info.return_value = {}
        mock_get_device_ids.return_value = []

        result = data_driver._get_block_device_info(device)

        self.assertEqual(result, {'name': 'fake_device'})
예제 #4
0
    def test_kernel_params(self, cmdline_mock):
        data = {'deploy_data': {'kernel_params': "test_param=test_val",
                                'other_data': 'test'},
                'partitions': 'fake_shema'}
        cmdline_mock.return_value = {
            "BOOTIF": "01-52-54-00-a5-55-58",
            "extrastuff": "test123"
        }

        data_driver = ironic.Ironic(data)

        self.assertEqual('test_param=test_val BOOTIF=01-52-54-00-a5-55-58',
                         data_driver.grub.kernel_params)
예제 #5
0
    def test_partition_scheme(self, mock_scsi_address):
        data_driver = ironic.Ironic(PROVISION_SAMPLE_DATA_SWIFT)

        data_driver.get_image_ids = mock.MagicMock
        mock_devices = data_driver._get_block_devices = mock.MagicMock()
        mock_devices.return_value = LIST_BLOCK_DEVICES_SAMPLE

        p_scheme = data_driver.partition_scheme
        self.assertEqual(5, len(p_scheme.fss))
        self.assertEqual(5, len(p_scheme.pvs))
        self.assertEqual(3, len(p_scheme.lvs))
        self.assertEqual(2, len(p_scheme.vgs))
        self.assertEqual(3, len(p_scheme.parteds))
예제 #6
0
    def test__find_hw_fstab_fail_error_while_reading_fstba(self, exec_mock):
        fs = namedtuple('fs', 'mount type device os_id')
        fss = [
            fs(mount='/etc', type='ext4', device='/dev/sda', os_id='1'),
            fs(mount='/', type='ext4', device='/dev/sda', os_id='1')
        ]

        data_driver = ironic.Ironic({})
        data_driver._partition_scheme = ironic.objects.PartitionScheme()
        data_driver.partition_scheme.fss = fss
        exec_mock.side_effect = [('stdout', 'stderr'),
                                 errors.ProcessExecutionError,
                                 ('stdout', 'stderr')]

        self.assertRaises(errors.HardwarePartitionSchemeCannotBeReadError,
                          data_driver._find_hw_fstab)
예제 #7
0
    def test__find_hw_fstab_success_single_disk(self, exec_mock):
        fs = namedtuple('fs', 'mount type device os_id')
        fss = [
            fs(mount='/', type='ext4', device='/dev/sda', os_id='1'),
            fs(mount='/usr', type='ext4', device='/dev/sdb', os_id='1')
        ]

        data_driver = ironic.Ironic({})
        data_driver._partition_scheme = ironic.objects.PartitionScheme()
        data_driver.partition_scheme.fss = fss

        exec_mock.side_effect = [('stdout', 'stderr'), ('fstab_1', 'stderr'),
                                 ('stdout', 'stderr')]

        res = data_driver._find_hw_fstab()

        self.assertEqual('\n'.join(('fstab_1', )), res)
예제 #8
0
    def test_device_info(self, mock_scsi_address, mock_get_device_info,
                         mock_get_device_ids):
        data_driver = ironic.Ironic('')
        device = 'fake_device'
        devpath = ['test/devpath']
        uspec = {'DEVPATH': devpath}

        mock_get_device_info.return_value = {
            'uspec': uspec
        }
        mock_scsi_address.return_value = scsi_address = '1:0:0:0'
        mock_get_device_ids.return_value = devpath

        desired = {'path': devpath, 'name': device, 'scsi': scsi_address,
                   'uspec': uspec}

        result = data_driver._get_block_device_info(device)
        self.assertEqual(result, desired)
        mock_get_device_info.assert_called_once_with(device)
        mock_scsi_address.assert_called_once_with(device)
예제 #9
0
    def test_get_image_schema(self):
        image_uri = 'test_uri'
        rsync_flags = '-a -X'
        deploy_flags = {'rsync_flags': rsync_flags}
        data = {
            'images': [{
                'image_pull_url': image_uri,
                'target': '/',
                'name': 'test'
            }],
            'image_deploy_flags':
            deploy_flags
        }
        self.driver = ironic.Ironic(data)

        result = self.driver._get_image_scheme()

        self.assertEqual(len(result.images), 1)

        result_image = result.images[0]
        self.assertEqual(result_image.deployment_flags, deploy_flags)
        self.assertEqual(result_image.uri, image_uri)
예제 #10
0
    def test_no_kernel_params(self):
        data = {'deploy_data': {'other_data': "test"},
                'partitions': 'fake_shema'}
        data_driver = ironic.Ironic(data)

        self.assertEqual('', data_driver.grub.kernel_params)
예제 #11
0
 def __init__(self, *args, **kwargs):
     super(TestGetBlockDevices, self).__init__(*args, **kwargs)
     self.driver = ironic.Ironic('')
     self.mock_devices = mock.MagicMock()
     self.driver._get_block_device_info = self.mock_devices
예제 #12
0
 def __init__(self, *args, **kwargs):
     super(TestMatchDevice, self).__init__(*args, **kwargs)
     self.driver = ironic.Ironic({})
예제 #13
0
 def __init__(self, *args, **kwargs):
     super(TestGetPartitionIds, self).__init__(*args, **kwargs)
     self.driver = ironic.Ironic({})
예제 #14
0
 def __init__(self, *args, **kwargs):
     super(TestDiskPartition, self).__init__(*args, **kwargs)
     self.driver = ironic.Ironic({})
     self.driver._match_data_by_pattern = \
         self.mock_match_part = mock.MagicMock()
예제 #15
0
 def __init__(self, *args, **kwargs):
     super(TestIronicMatch, self).__init__(*args, **kwargs)
     self.data_driver = ironic.Ironic('')
예제 #16
0
    def test_partitions_policy_default(self):
        data = {'partitions': 'fake_shema'}

        data_driver = ironic.Ironic(data)

        self.assertEqual('verify', data_driver.partitions_policy)
예제 #17
0
 def __init__(self, *args, **kwargs):
     super(TestDiskDev, self).__init__(*args, **kwargs)
     self.driver = ironic.Ironic({})
     self.driver._match_device = self.mock_match_device = mock.MagicMock()