Esempio n. 1
0
    def test_set_boot_device_with_list_unfinished_jobs_without_clean_step(
            self, mock__get_next_persistent_boot_mode, mock__get_boot_device,
            mock_list_unfinished_jobs, mock_validate_job_queue,
            mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client

        bios_job_dict = {
            'id': 'JID_602553293345',
            'name': 'ConfigBIOS:BIOS.Setup.1-1',
            'start_time': 'TIME_NOW',
            'until_time': 'TIME_NA',
            'message': 'Task successfully scheduled.',
            'status': 'Scheduled',
            'percent_complete': 0}
        bios_job = test_utils.make_job(bios_job_dict)

        mock_list_unfinished_jobs.return_value = [bios_job]
        mock_client.list_boot_devices.return_value = self.boot_devices['IPL']
        boot_device = {'boot_device': ironic.common.boot_devices.DISK,
                       'persistent': True}

        mock__get_boot_device.return_value = boot_device
        mock__get_next_persistent_boot_mode.return_value = 'IPL'

        self.node.driver_internal_info['clean_steps'] = []

        drac_mgmt.set_boot_device(self.node, ironic.common.boot_devices.DISK,
                                  persistent=True)
        self.assertEqual(0, mock_list_unfinished_jobs.call_count)
        self.assertEqual(0, mock_client.delete_jobs.call_count)

        mock_validate_job_queue.assert_called_once_with(self.node)
Esempio n. 2
0
def _commit_boot_list_change(node):
    driver_internal_info = node.driver_internal_info

    boot_device = node.driver_internal_info.get('drac_boot_device')
    if boot_device is not None:
        drac_management.set_boot_device(node, boot_device['boot_device'],
                                        boot_device['persistent'])

        driver_internal_info['drac_boot_device'] = None
        node.driver_internal_info = driver_internal_info
        node.save()
Esempio n. 3
0
    def test_set_boot_device_called_with_no_drac_boot_device(
            self, mock_list_unfinished_jobs, mock__get_boot_device,
            mock__get_next_persistent_boot_mode,
            mock__is_boot_order_flexibly_programmable,
            mock__flexibly_program_boot_order, mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_devices.return_value = self.boot_devices['UEFI']
        mock_list_unfinished_jobs.return_value = []

        mock_job = mock.Mock()
        mock_job.status = "Scheduled"
        mock_client.get_job.return_value = mock_job
        boot_device = {
            'boot_device': ironic.common.boot_devices.PXE,
            'persistent': False
        }
        mock__get_boot_device.return_value = boot_device
        mock__get_next_persistent_boot_mode.return_value = 'UEFI'
        settings = [
            {
                'name': 'BootMode',
                'instance_id': 'BIOS.Setup.1-1:BootMode',
                'current_value': 'Uefi',
                'pending_value': None,
                'read_only': False,
                'possible_values': ['Bios', 'Uefi']
            },
        ]
        bios_settings = {
            s['name']: test_utils.dict_to_namedtuple(values=s)
            for s in settings
        }
        mock_client.list_bios_settings.return_value = bios_settings
        mock__is_boot_order_flexibly_programmable.return_value = True
        flexibly_program_settings = {
            'SetBootOrderFqdd1': '*.*.*',
            'SetBootOrderFqdd2': 'NIC.*.*',
            'SetBootOrderFqdd3': 'Optical.*.*',
            'SetBootOrderFqdd4': 'Floppy.*.*',
        }
        mock__flexibly_program_boot_order.return_value = \
            flexibly_program_settings

        drac_mgmt.set_boot_device(self.node,
                                  ironic.common.boot_devices.DISK,
                                  persistent=True)

        mock_list_unfinished_jobs.assert_called_once_with(self.node)
        self.assertEqual(0, mock_client.change_boot_device_order.call_count)
        mock_client.set_bios_settings.assert_called_once_with(
            flexibly_program_settings)
        mock_client.commit_pending_bios_changes.assert_called_once_with()
Esempio n. 4
0
    def test_set_boot_device(self, mock_validate_job_queue,
                             mock_list_unfinished_jobs,
                             mock__get_boot_device,
                             mock__get_next_persistent_boot_mode,
                             mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_devices.return_value = self.boot_devices['IPL']
        mock_list_unfinished_jobs.return_value = []

        mock_job = mock.Mock()
        mock_job.status = "Scheduled"
        mock_client.get_job.return_value = mock_job

        boot_device = {'boot_device': ironic.common.boot_devices.DISK,
                       'persistent': True}
        mock__get_boot_device.return_value = boot_device
        mock__get_next_persistent_boot_mode.return_value = 'IPL'
        self.node.driver_internal_info['clean_steps'] = []

        boot_device = drac_mgmt.set_boot_device(
            self.node, ironic.common.boot_devices.PXE, persistent=False)

        self.assertEqual(0, mock_list_unfinished_jobs.call_count)
        self.assertEqual(0, mock_client.delete_jobs.call_count)
        mock_validate_job_queue.assert_called_once_with(self.node)
        mock_client.change_boot_device_order.assert_called_once_with(
            'OneTime', 'BIOS.Setup.1-1#BootSeq#NIC.Embedded.1-1-1')
        self.assertEqual(0, mock_client.set_bios_settings.call_count)
        mock_client.commit_pending_bios_changes.assert_called_once_with()
Esempio n. 5
0
    def test_set_boot_device_called_with_no_change(self,
                                                   mock_validate_job_queue,
                                                   mock__get_boot_device,
                                                   mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_modes.return_value = [
            mock.Mock(**self.boot_mode_ipl),
            mock.Mock(**self.boot_mode_one_time)
        ]
        mock_client.list_boot_devices.return_value = {
            'IPL': [
                mock.Mock(**self.boot_device_pxe),
                mock.Mock(**self.boot_device_disk)
            ]
        }
        boot_device = {
            'boot_device': ironic.common.boot_devices.PXE,
            'persistent': True
        }
        mock__get_boot_device.return_value = boot_device

        boot_device = drac_mgmt.set_boot_device(self.node,
                                                ironic.common.boot_devices.PXE,
                                                persistent=True)

        mock_validate_job_queue.assert_called_once_with(self.node)
        self.assertEqual(0, mock_client.change_boot_device_order.call_count)
        self.assertEqual(0, mock_client.commit_pending_bios_changes.call_count)
Esempio n. 6
0
    def test_set_boot_device(self, mock_validate_job_queue,
                             mock__get_boot_device, mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_modes.return_value = [
            mock.Mock(**self.boot_mode_ipl),
            mock.Mock(**self.boot_mode_one_time)
        ]
        mock_client.list_boot_devices.return_value = {
            'IPL': [
                mock.Mock(**self.boot_device_pxe),
                mock.Mock(**self.boot_device_disk)
            ]
        }
        boot_device = {
            'boot_device': ironic.common.boot_devices.DISK,
            'persistent': True
        }
        mock__get_boot_device.return_value = boot_device

        boot_device = drac_mgmt.set_boot_device(self.node,
                                                ironic.common.boot_devices.PXE,
                                                persistent=False)

        mock_validate_job_queue.assert_called_once_with(self.node)
        mock_client.change_boot_device_order.assert_called_once_with(
            'OneTime', 'BIOS.Setup.1-1#BootSeq#NIC.Embedded.1-1-1')
        mock_client.commit_pending_bios_changes.assert_called_once_with()
Esempio n. 7
0
    def test_set_boot_device_called_with_no_drac_boot_device(
            self, mock_validate_job_queue, mock__get_boot_device,
            mock__get_next_persistent_boot_mode,
            mock__is_boot_order_flexibly_programmable,
            mock__flexibly_program_boot_order,
            mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_devices.return_value = self.boot_devices['UEFI']
        boot_device = {'boot_device': ironic.common.boot_devices.PXE,
                       'persistent': False}
        mock__get_boot_device.return_value = boot_device
        mock__get_next_persistent_boot_mode.return_value = 'UEFI'
        settings = [
            {
                'name': 'BootMode',
                'instance_id': 'BIOS.Setup.1-1:BootMode',
                'current_value': 'Uefi',
                'pending_value': None,
                'read_only': False,
                'possible_values': ['Bios', 'Uefi']
            },
        ]
        bios_settings = {
            s['name']: test_utils.dict_to_namedtuple(
                values=s) for s in settings}
        mock_client.list_bios_settings.return_value = bios_settings
        mock__is_boot_order_flexibly_programmable.return_value = True
        flexibly_program_settings = {
            'SetBootOrderFqdd1': '*.*.*',
            'SetBootOrderFqdd2': 'NIC.*.*',
            'SetBootOrderFqdd3': 'Optical.*.*',
            'SetBootOrderFqdd4': 'Floppy.*.*',
        }
        mock__flexibly_program_boot_order.return_value = \
            flexibly_program_settings

        drac_mgmt.set_boot_device(self.node, ironic.common.boot_devices.DISK,
                                  persistent=True)

        mock_validate_job_queue.assert_called_once_with(self.node)
        self.assertEqual(0, mock_client.change_boot_device_order.call_count)
        mock_client.set_bios_settings.assert_called_once_with(
            flexibly_program_settings)
        mock_client.commit_pending_bios_changes.assert_called_once_with()
Esempio n. 8
0
    def test_set_boot_device_called_with_no_change(
            self, mock_validate_job_queue, mock__get_boot_device,
            mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_modes.return_value = self.boot_modes('IPL')
        mock_client.list_boot_devices.return_value = self.boot_devices
        boot_device = {'boot_device': ironic.common.boot_devices.PXE,
                       'persistent': True}
        mock__get_boot_device.return_value = boot_device

        boot_device = drac_mgmt.set_boot_device(
            self.node, ironic.common.boot_devices.PXE, persistent=True)

        mock_validate_job_queue.assert_called_once_with(self.node)
        self.assertEqual(0, mock_client.change_boot_device_order.call_count)
        self.assertEqual(0, mock_client.commit_pending_bios_changes.call_count)
Esempio n. 9
0
    def test_set_boot_device(self, mock_validate_job_queue,
                             mock__get_boot_device, mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_modes.return_value = self.boot_modes('IPL')
        mock_client.list_boot_devices.return_value = self.boot_devices
        boot_device = {'boot_device': ironic.common.boot_devices.DISK,
                       'persistent': True}
        mock__get_boot_device.return_value = boot_device

        boot_device = drac_mgmt.set_boot_device(
            self.node, ironic.common.boot_devices.PXE, persistent=False)

        mock_validate_job_queue.assert_called_once_with(self.node)
        mock_client.change_boot_device_order.assert_called_once_with(
            'OneTime', 'BIOS.Setup.1-1#BootSeq#NIC.Embedded.1-1-1')
        mock_client.commit_pending_bios_changes.assert_called_once_with()
Esempio n. 10
0
    def test_set_boot_device_called_with_no_change(
            self, mock_validate_job_queue, mock__get_boot_device,
            mock__get_next_persistent_boot_mode, mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_devices.return_value = self.boot_devices['IPL']
        boot_device = {'boot_device': ironic.common.boot_devices.PXE,
                       'persistent': True}
        mock__get_boot_device.return_value = boot_device
        mock__get_next_persistent_boot_mode.return_value = 'IPL'

        boot_device = drac_mgmt.set_boot_device(
            self.node, ironic.common.boot_devices.PXE, persistent=True)

        mock_validate_job_queue.assert_called_once_with(self.node)
        self.assertEqual(0, mock_client.change_boot_device_order.call_count)
        self.assertEqual(0, mock_client.set_bios_settings.call_count)
        self.assertEqual(0, mock_client.commit_pending_bios_changes.call_count)
Esempio n. 11
0
    def test_set_boot_device(self, mock_validate_job_queue,
                             mock__get_boot_device,
                             mock__get_next_persistent_boot_mode,
                             mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_devices.return_value = self.boot_devices['IPL']
        boot_device = {'boot_device': ironic.common.boot_devices.DISK,
                       'persistent': True}
        mock__get_boot_device.return_value = boot_device
        mock__get_next_persistent_boot_mode.return_value = 'IPL'

        boot_device = drac_mgmt.set_boot_device(
            self.node, ironic.common.boot_devices.PXE, persistent=False)

        mock_validate_job_queue.assert_called_once_with(self.node)
        mock_client.change_boot_device_order.assert_called_once_with(
            'OneTime', 'BIOS.Setup.1-1#BootSeq#NIC.Embedded.1-1-1')
        self.assertEqual(0, mock_client.set_bios_settings.call_count)
        mock_client.commit_pending_bios_changes.assert_called_once_with()
Esempio n. 12
0
    def test_set_boot_device_called_with_no_change(
            self, mock_validate_job_queue, mock__get_boot_device,
            mock_get_drac_client):
        mock_client = mock.Mock()
        mock_get_drac_client.return_value = mock_client
        mock_client.list_boot_modes.return_value = [
            test_utils.dict_to_namedtuple(values=self.boot_mode_ipl),
            test_utils.dict_to_namedtuple(values=self.boot_mode_one_time)]
        mock_client.list_boot_devices.return_value = {
            'IPL': [test_utils.dict_to_namedtuple(values=self.boot_device_pxe),
                    test_utils.dict_to_namedtuple(
                        values=self.boot_device_disk)]}
        boot_device = {'boot_device': ironic.common.boot_devices.PXE,
                       'persistent': True}
        mock__get_boot_device.return_value = boot_device

        boot_device = drac_mgmt.set_boot_device(
            self.node, ironic.common.boot_devices.PXE, persistent=True)

        mock_validate_job_queue.assert_called_once_with(self.node)
        self.assertEqual(0, mock_client.change_boot_device_order.call_count)
        self.assertEqual(0, mock_client.commit_pending_bios_changes.call_count)