Exemplo n.º 1
0
 def test_add_node_capability(self):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.properties['capabilities'] = ''
         driver_utils.add_node_capability(task, 'boot_mode', 'bios')
         self.assertEqual('boot_mode:bios',
                          task.node.properties['capabilities'])
Exemplo n.º 2
0
 def test_add_node_capability_append_duplicate(self):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.properties['capabilities'] = 'a:b,c:d'
         driver_utils.add_node_capability(task, 'a', 'b')
         self.assertEqual('a:b,c:d,a:b',
                          task.node.properties['capabilities'])
Exemplo n.º 3
0
 def test_validate_success_connectors_and_boot(self, mock_log, mock_fail):
     """Perform validate with volume connectors and boot capabilities."""
     object_utils.create_test_volume_connector(
         self.context,
         node_id=self.node.id,
         type='iqn',
         connector_id='iqn.address',
         uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_connector(
         self.context,
         node_id=self.node.id,
         type='wwpn',
         connector_id='wwpn.address',
         uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_connector(
         self.context,
         node_id=self.node.id,
         type='wwnn',
         connector_id='wwnn.address',
         uuid=uuidutils.generate_uuid())
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'fibre_channel_boot',
                                          'True')
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.interface.validate(task)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_fail.called)
Exemplo n.º 4
0
 def test_validate_success_fc_targets(self, mock_log, mock_fail):
     """Validate success with full fc scenario."""
     object_utils.create_test_volume_connector(
         self.context,
         node_id=self.node.id,
         type='wwpn',
         connector_id='fc.address',
         uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_connector(
         self.context,
         node_id=self.node.id,
         type='wwnn',
         connector_id='fc.address',
         uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_target(self.context,
                                            node_id=self.node.id,
                                            volume_type='fibre_channel',
                                            boot_index=0,
                                            volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'fibre_channel_boot',
                                          'True')
         self.interface.validate(task)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_fail.called)
Exemplo n.º 5
0
 def test_add_node_capability_append_duplicate(self):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.properties['capabilities'] = 'a:b,c:d'
         driver_utils.add_node_capability(task, 'a', 'b')
         self.assertEqual('a:b,c:d,a:b',
                          task.node.properties['capabilities'])
Exemplo n.º 6
0
 def test_add_node_capability(self):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.properties['capabilities'] = ''
         driver_utils.add_node_capability(task, 'boot_mode', 'bios')
         self.assertEqual('boot_mode:bios',
                          task.node.properties['capabilities'])
Exemplo n.º 7
0
 def test_management_interface_set_boot_device_bios_ok(
         self, set_boot_device_mock):
     """bios mode specified."""
     with task_manager.acquire(self.context, self.node.uuid) as task:
         driver_utils.add_node_capability(task, 'boot_mode', 'bios')
         task.driver.management.set_boot_device(task, boot_devices.PXE)
         set_boot_device_mock.assert_called_once_with(
             task.driver.management, task, boot_devices.PXE, False)
Exemplo n.º 8
0
    def test_management_interface_set_boot_device_uefi_ng(self, send_raw_mock):
        """uefi mode, next boot only, unknown device."""
        send_raw_mock.return_value = [None, None]

        with task_manager.acquire(self.context, self.node.uuid) as task:
            driver_utils.add_node_capability(task, 'boot_mode', 'uefi')
            self.assertRaises(exception.InvalidParameterValue,
                              self.driver.management.set_boot_device, task,
                              "unknown")
Exemplo n.º 9
0
    def test_management_interface_set_boot_device_ng(self, send_raw_mock):
        """uefi mode, next boot only, unknown device."""
        send_raw_mock.return_value = [None, None]

        with task_manager.acquire(self.context, self.node.uuid) as task:
            driver_utils.add_node_capability(task, 'boot_mode', 'uefi')
            self.assertRaises(exception.InvalidParameterValue,
                              self.driver.management.set_boot_device,
                              task,
                              "unknown")
Exemplo n.º 10
0
 def test_management_interface_set_boot_device_bios_ok(
         self,
         set_boot_device_mock):
     """bios mode specified."""
     with task_manager.acquire(self.context, self.node.uuid) as task:
         driver_utils.add_node_capability(task, 'boot_mode', 'bios')
         task.driver.management.set_boot_device(task, boot_devices.PXE)
         set_boot_device_mock.assert_called_once_with(
             task.driver.management, task,
             boot_devices.PXE,
             False)
Exemplo n.º 11
0
    def _test_management_interface_set_boot_device_uefi_ok(
            self, params, expected_raw_code, send_raw_mock):
        send_raw_mock.return_value = [None, None]

        with task_manager.acquire(self.context, self.node.uuid) as task:
            task.node.properties['capabilities'] = ''
            driver_utils.add_node_capability(task, 'boot_mode', 'uefi')
            self.driver.management.set_boot_device(task, **params)
            send_raw_mock.assert_has_calls([
                mock.call(task, "0x00 0x08 0x03 0x08"),
                mock.call(task, expected_raw_code)
            ])
Exemplo n.º 12
0
    def _test_management_interface_set_boot_device_uefi_ok(self, params,
                                                           expected_raw_code,
                                                           send_raw_mock):
        send_raw_mock.return_value = [None, None]

        with task_manager.acquire(self.context, self.node.uuid) as task:
            task.node.properties['capabilities'] = ''
            driver_utils.add_node_capability(task, 'boot_mode', 'uefi')
            self.driver.management.set_boot_device(task, **params)
            send_raw_mock.assert_has_calls([
                mock.call(task, "0x00 0x08 0x03 0x08"),
                mock.call(task, expected_raw_code)])
Exemplo n.º 13
0
 def test_validate_success_iscsi_targets(self, mock_log, mock_fail):
     """Validate success with full iscsi scenario."""
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='iqn.address', uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='iscsi',
         boot_index=0, volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.interface.validate(task)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_fail.called)
Exemplo n.º 14
0
 def test_validate_fails_iscsi_conn_fc_target(self, mock_log):
     """Validate failure of iSCSI connectors with FC target."""
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='foo.address')
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='fibre_channel',
         boot_index=0, volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.assertRaises(exception.InvalidParameterValue,
                           self.interface.validate,
                           task)
     self.assertTrue(mock_log.error.called)
Exemplo n.º 15
0
 def test_validate_fail_on_unknown_volume_types(self, mock_log):
     """Ensure exception is raised when connector/target do not match."""
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='foo.address')
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='wetcat',
         boot_index=0, volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.assertRaises(exception.InvalidParameterValue,
                           self.interface.validate,
                           task)
     self.assertTrue(mock_log.error.called)
Exemplo n.º 16
0
 def test_validate_fail_on_unknown_volume_types(self, mock_log):
     """Ensure exception is raised when connector/target do not match."""
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='foo.address')
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='wetcat',
         boot_index=0, volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.assertRaises(exception.InvalidParameterValue,
                           self.interface.validate,
                           task)
     self.assertTrue(mock_log.error.called)
Exemplo n.º 17
0
 def test_validate_fails_iscsi_conn_fc_target(self, mock_log):
     """Validate failure of iSCSI connectors with FC target."""
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='foo.address')
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='fibre_channel',
         boot_index=0, volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.assertRaises(exception.InvalidParameterValue,
                           self.interface.validate,
                           task)
     self.assertTrue(mock_log.error.called)
Exemplo n.º 18
0
    def test_validate_failure_if_iscsi_boot_no_connectors(self, mock_log):
        valid_types = ', '.join(cinder.VALID_ISCSI_TYPES)
        expected_msg = ("Failed to validate cinder storage interface for node "
                        "%(id)s. In order to enable the 'iscsi_boot' "
                        "capability for the node, an associated "
                        "volume_connector type must be valid for "
                        "iSCSI (%(options)s)." %
                        {'id': self.node.uuid, 'options': valid_types})

        with task_manager.acquire(self.context, self.node.id) as task:
            driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
            self.assertRaises(exception.InvalidParameterValue,
                              self.interface.validate,
                              task)
        mock_log.error.assert_called_once_with(expected_msg)
Exemplo n.º 19
0
    def test_validate_failure_if_iscsi_boot_no_connectors(self, mock_log):
        valid_types = ', '.join(cinder.VALID_ISCSI_TYPES)
        expected_msg = ("Failed to validate cinder storage interface for node "
                        "%(id)s. In order to enable the 'iscsi_boot' "
                        "capability for the node, an associated "
                        "volume_connector type must be valid for "
                        "iSCSI (%(options)s)." %
                        {'id': self.node.uuid, 'options': valid_types})

        with task_manager.acquire(self.context, self.node.id) as task:
            driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
            self.assertRaises(exception.InvalidParameterValue,
                              self.interface.validate,
                              task)
        mock_log.error.assert_called_once_with(expected_msg)
Exemplo n.º 20
0
 def test_validate_fails_with_ipxe_not_enabled(self, mock_log):
     """Ensure a validation failure is raised when iPXE not enabled."""
     self.config(ipxe_enabled=False, group='pxe')
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='foo.address')
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='iscsi',
         boot_index=0, volume_id='2345')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.assertRaises(exception.InvalidParameterValue,
                           self.interface.validate,
                           task)
     self.assertTrue(mock_log.error.called)
Exemplo n.º 21
0
 def test_validate_fails_with_ipxe_not_enabled(self, mock_log):
     """Ensure a validation failure is raised when iPXE not enabled."""
     self.node.boot_interface = 'pxe'
     self.node.save()
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='foo.address')
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='iscsi',
         boot_index=0, volume_id='2345')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.assertRaises(exception.InvalidParameterValue,
                           self.interface.validate,
                           task)
     self.assertTrue(mock_log.error.called)
Exemplo n.º 22
0
    def _test_set_boot_device_one_time(self, persistent, uefi, mock_gci):
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            mock_c = mock.MagicMock(spec=msftocsclient.MSFTOCSClientApi)
            blade_id = task.node.driver_info['msftocs_blade_id']
            mock_gci.return_value = (mock_c, blade_id)

            if uefi:
                drivers_utils.add_node_capability(task, 'boot_mode', 'uefi')

            task.driver.management.set_boot_device(task, boot_devices.PXE,
                                                   persistent)

            mock_gci.assert_called_once_with(task.node.driver_info)
            mock_c.set_next_boot.assert_called_once_with(
                blade_id, msftocsclient.BOOT_TYPE_FORCE_PXE, persistent, uefi)
Exemplo n.º 23
0
    def _test_set_boot_device_one_time(self, persistent, uefi,
                                       mock_gci):
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            mock_c = mock.MagicMock(spec=msftocsclient.MSFTOCSClientApi)
            blade_id = task.node.driver_info['msftocs_blade_id']
            mock_gci.return_value = (mock_c, blade_id)

            if uefi:
                drivers_utils.add_node_capability(task, 'boot_mode', 'uefi')

            task.driver.management.set_boot_device(
                task, boot_devices.PXE, persistent)

            mock_gci.assert_called_once_with(task.node.driver_info)
            mock_c.set_next_boot.assert_called_once_with(
                blade_id, msftocsclient.BOOT_TYPE_FORCE_PXE, persistent, uefi)
Exemplo n.º 24
0
 def test_validate_success_connectors_and_boot(self, mock_log, mock_fail):
     """Perform validate with volume connectors and boot capabilities."""
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='iqn',
         connector_id='iqn.address', uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='wwpn',
         connector_id='wwpn.address', uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='wwnn',
         connector_id='wwnn.address', uuid=uuidutils.generate_uuid())
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task,
                                          'fibre_channel_boot',
                                          'True')
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.interface.validate(task)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_fail.called)
Exemplo n.º 25
0
 def test_validate_success_fc_targets(self, mock_log, mock_fail):
     """Validate success with full fc scenario."""
     self.node = object_utils.create_test_node(self.context,
                                               storage_interface='cinder')
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='wwpn',
         connector_id='fc.address', uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_connector(
         self.context, node_id=self.node.id, type='wwnn',
         connector_id='fc.address', uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_target(
         self.context, node_id=self.node.id, volume_type='fibre_channel',
         boot_index=0, volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task,
                                          'fibre_channel_boot',
                                          'True')
         self.interface.validate(task)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_fail.called)
Exemplo n.º 26
0
 def test_validate_success_iscsi_targets(self, mock_log, mock_fail):
     """Validate success with full iscsi scenario."""
     self.node = object_utils.create_test_node(self.context,
                                               storage_interface='cinder')
     object_utils.create_test_volume_connector(
         self.context,
         node_id=self.node.id,
         type='iqn',
         connector_id='iqn.address',
         uuid=uuidutils.generate_uuid())
     object_utils.create_test_volume_target(self.context,
                                            node_id=self.node.id,
                                            volume_type='iscsi',
                                            boot_index=0,
                                            volume_id='1234')
     with task_manager.acquire(self.context, self.node.id) as task:
         driver_utils.add_node_capability(task, 'iscsi_boot', 'True')
         self.interface.validate(task)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_fail.called)
Exemplo n.º 27
0
def update_boot_mode_capability(task):
    """Update 'boot_mode' capability value of node's 'capabilities' property.

    :param task: Task object.

    """
    ilo_object = get_ilo_object(task.node)

    try:
        p_boot_mode = ilo_object.get_pending_boot_mode()
        if p_boot_mode == "UNKNOWN":
            # NOTE(faizan) ILO will return this in remote cases and mostly on
            # the nodes which supports UEFI. Such nodes mostly comes with UEFI
            # as default boot mode. So we will try setting bootmode to UEFI
            # and if it fails then we fall back to BIOS boot mode.
            ilo_object.set_pending_boot_mode("UEFI")
            p_boot_mode = "UEFI"
    except ilo_client.IloCommandNotSupportedError:
        p_boot_mode = DEFAULT_BOOT_MODE

    driver_utils.rm_node_capability(task, "boot_mode")

    driver_utils.add_node_capability(task, "boot_mode", BOOT_MODE_ILO_TO_GENERIC[p_boot_mode.lower()])
Exemplo n.º 28
0
def update_boot_mode_capability(task):
    """Update 'boot_mode' capability value of node's 'capabilities' property.

    :param task: Task object.

    """
    ilo_object = get_ilo_object(task.node)

    try:
        p_boot_mode = ilo_object.get_pending_boot_mode()
        if p_boot_mode == 'UNKNOWN':
            # NOTE(faizan) ILO will return this in remote cases and mostly on
            # the nodes which supports UEFI. Such nodes mostly comes with UEFI
            # as default boot mode. So we will try setting bootmode to UEFI
            # and if it fails then we fall back to BIOS boot mode.
            ilo_object.set_pending_boot_mode('UEFI')
            p_boot_mode = 'UEFI'
    except ilo_client.IloCommandNotSupportedError:
        p_boot_mode = DEFAULT_BOOT_MODE

    driver_utils.rm_node_capability(task, 'boot_mode')

    driver_utils.add_node_capability(task, 'boot_mode',
        BOOT_MODE_ILO_TO_GENERIC[p_boot_mode.lower()])
Exemplo n.º 29
0
 def test_add_node_capability(self):
     with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
         task.node.properties["capabilities"] = ""
         driver_utils.add_node_capability(task, "boot_mode", "bios")
         self.assertEqual("boot_mode:bios", task.node.properties["capabilities"])
Exemplo n.º 30
0
 def test_add_node_capability_append_duplicate(self):
     with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
         task.node.properties["capabilities"] = "a:b,c:d"
         driver_utils.add_node_capability(task, "a", "b")
         self.assertEqual("a:b,c:d,a:b", task.node.properties["capabilities"])