def setUp(self):
     super(LibvirtManagementTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver="fake_libvirt_fake")
     driver_factory.get_driver("fake_libvirt_fake")
     self.node = obj_utils.create_test_node(
         self.context,
         driver='fake_libvirt_fake',
         driver_info=_get_test_libvirt_driver_info('sasl'))
     obj_utils.create_test_port(self.context,
                                node_id=self.node.id,
                                address='52:54:00:5c:b7:df')
Beispiel #2
0
    def __init__(self, context, node_id, shared=False, driver_name=None):
        """Create a new TaskManager.

        Acquire a lock on a node. The lock can be either shared or
        exclusive. Shared locks may be used for read-only or
        non-disruptive actions only, and must be considerate to what
        other threads may be doing on the same node at the same time.

        :param context: request context
        :param node_id: ID or UUID of node to lock.
        :param shared: Boolean indicating whether to take a shared or exclusive
                       lock. Default: False.
        :param driver_name: The name of the driver to load, if different
                            from the Node's current driver.
        :raises: DriverNotFound
        :raises: NodeNotFound
        :raises: NodeLocked

        """

        self._spawn_method = None
        self._on_error_method = None

        self.context = context
        self.node = None
        self.shared = shared

        self.fsm = states.machine.copy()

        # NodeLocked exceptions can be annoying. Let's try to alleviate
        # some of that pain by retrying our lock attempts. The retrying
        # module expects a wait_fixed value in milliseconds.
        @retrying.retry(
            retry_on_exception=lambda e: isinstance(e, exception.NodeLocked),
            stop_max_attempt_number=CONF.conductor.node_locked_retry_attempts,
            wait_fixed=CONF.conductor.node_locked_retry_interval * 1000,
        )
        def reserve_node():
            LOG.debug("Attempting to reserve node %(node)s", {"node": node_id})
            self.node = objects.Node.reserve(context, CONF.host, node_id)

        try:
            if not self.shared:
                reserve_node()
            else:
                self.node = objects.Node.get(context, node_id)
            self.ports = objects.Port.list_by_node_id(context, self.node.id)
            self.driver = driver_factory.get_driver(driver_name or self.node.driver)

            # NOTE(deva): this handles the Juno-era NOSTATE state
            #             and should be deleted after Kilo is released
            if self.node.provision_state is states.NOSTATE:
                self.node.provision_state = states.AVAILABLE
                self.node.save()

            self.fsm.initialize(self.node.provision_state)

        except Exception:
            with excutils.save_and_reraise_exception():
                self.release_resources()
Beispiel #3
0
    def setUp(self):
        super(SSHDriverTestCase, self).setUp()
        self.context = context.get_admin_context()
        mgr_utils.mock_the_extension_manager(driver="fake_ssh")
        self.driver = driver_factory.get_driver("fake_ssh")
        n = db_utils.get_test_node(
                driver='fake_ssh',
                driver_info=INFO_DICT)
        self.dbapi = dbapi.get_instance()
        self.node = self.dbapi.create_node(n)
        self.port = self.dbapi.create_port(db_utils.get_test_port(
                                                         node_id=self.node.id))
        self.sshclient = paramiko.SSHClient()

        #setup these mocks because most tests use them
        self.parse_drv_info_patcher = mock.patch.object(ssh,
                                                        '_parse_driver_info')
        self.parse_drv_info_mock = None
        self.get_mac_addr_patcher = mock.patch.object(
                ssh,
                '_get_nodes_mac_addresses')
        self.get_mac_addr_mock = self.get_mac_addr_patcher.start()
        self.get_conn_patcher = mock.patch.object(ssh, '_get_connection')
        self.get_conn_mock = self.get_conn_patcher.start()

        def stop_patchers():
            if self.parse_drv_info_mock:
                self.parse_drv_info_patcher.stop()
            if self.get_mac_addr_mock:
                self.get_mac_addr_patcher.stop()
            if self.get_conn_mock:
                self.get_conn_patcher.stop()

        self.addCleanup(stop_patchers)
    def setUp(self):
        super(OneViewManagementDriverTestCase, self).setUp()
        self.config(manager_url="https://1.2.3.4", group="oneview")
        self.config(username="******", group="oneview")
        self.config(password="******", group="oneview")

        self.mock_verify_oneview_version_obj = mock.patch.object(
            oneview_client, "verify_oneview_version", autospec=True, return_value=120
        )
        self.mock_verify_oneview_version = self.mock_verify_oneview_version_obj.start()
        self.addCleanup(self.mock_verify_oneview_version_obj.stop)
        self.mock_check_oneview_status_obj = mock.patch.object(
            oneview_client, "check_oneview_status", autospec=True, return_value=200
        )
        self.mock_check_oneview_status = self.mock_check_oneview_status_obj.start()
        self.addCleanup(self.mock_check_oneview_status_obj.stop)

        mgr_utils.mock_the_extension_manager(driver="fake_oneview")
        self.driver = driver_factory.get_driver("fake_oneview")

        self.node = obj_utils.create_test_node(
            self.context,
            driver="fake_oneview",
            properties=PROPERTIES_DICT,
            extra=EXTRA_DICT,
            driver_info=DRIVER_INFO_DICT,
            instance_info=INSTANCE_INFO_DICT,
        )
        self.info = common.parse_driver_info(self.node)
    def test__get_domain_by_macs_not_found(self, libvirt_conn_mock):
        mgr_utils.mock_the_extension_manager(driver="fake_libvirt_fake")
        driver_factory.get_driver("fake_libvirt_fake")
        node = obj_utils.create_test_node(
            self.context,
            driver='fake_libvirt_fake',
            driver_info=_get_test_libvirt_driver_info('socket'))
        obj_utils.create_test_port(self.context,
                                   node_id=node.id,
                                   address='00:17:3a:50:12:12')

        with task_manager.acquire(self.context, node.uuid,
                                  shared=True) as task:

            self.assertRaises(exception.NodeNotFound,
                              power._get_domain_by_macs, task)
Beispiel #6
0
    def setUp(self):
        super(IPMINativeDriverTestCase, self).setUp()
        mgr_utils.mock_the_extension_manager(driver="fake_ipminative")
        self.driver = driver_factory.get_driver("fake_ipminative")

        self.node = obj_utils.create_test_node(self.context, driver="fake_ipminative", driver_info=INFO_DICT)
        self.info = ipminative._parse_driver_info(self.node)
Beispiel #7
0
 def setUp(self):
     super(ManagerTestCase, self).setUp()
     self.service = manager.ConductorManager('test-host', 'test-topic')
     self.context = context.get_admin_context()
     self.dbapi = dbapi.get_instance()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
Beispiel #8
0
 def setUp(self):
     super(TaskManagerSetup, self).setUp()
     self.dbapi = dbapi.get_instance()
     self.context = context.get_admin_context()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
     self.config(host='test-host')
Beispiel #9
0
 def setUp(self):
     super(UtilsTestCase, self).setUp()
     self.context = context.get_admin_context()
     self.dbapi = db_api.get_instance()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
     self.node = obj_utils.create_test_node(self.context)
    def test__get_domain_by_macs(self, libvirt_conn_mock):
        mgr_utils.mock_the_extension_manager(driver="fake_libvirt_fake")
        driver_factory.get_driver("fake_libvirt_fake")
        node = obj_utils.create_test_node(
            self.context,
            driver='fake_libvirt_fake',
            driver_info=_get_test_libvirt_driver_info('socket'))
        obj_utils.create_test_port(self.context,
                                   node_id=node.id,
                                   address='00:16:3e:49:1d:11')

        with task_manager.acquire(self.context, node.uuid,
                                  shared=True) as task:
            domain = power._get_domain_by_macs(task)

        self.assertEqual('test_libvirt_domain', domain.name())
Beispiel #11
0
 def setUp(self):
     super(DracPeriodicTaskTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver='fake_drac')
     self.node = obj_utils.create_test_node(self.context,
                                            driver='fake_drac',
                                            driver_info=INFO_DICT)
     self.driver = driver_factory.get_driver("fake_drac")
     self.job = {
         'id': 'JID_001436912645',
         'name': 'ConfigBIOS:BIOS.Setup.1-1',
         'start_time': '00000101000000',
         'until_time': 'TIME_NA',
         'message': 'Job in progress',
         'state': 'Running',
         'percent_complete': 34}
     self.virtual_disk = {
         'id': 'Disk.Virtual.0:RAID.Integrated.1-1',
         'name': 'disk 0',
         'description': 'Virtual Disk 0 on Integrated RAID Controller 1',
         'controller': 'RAID.Integrated.1-1',
         'raid_level': '1',
         'size_mb': 571776,
         'state': 'ok',
         'raid_state': 'online',
         'span_depth': 1,
         'span_length': 2,
         'pending_operations': None
     }
Beispiel #12
0
    def __init__(self, context, node_id, shared=False, driver_name=None,
                 purpose='unspecified action'):
        """Create a new TaskManager.

        Acquire a lock on a node. The lock can be either shared or
        exclusive. Shared locks may be used for read-only or
        non-disruptive actions only, and must be considerate to what
        other threads may be doing on the same node at the same time.

        :param context: request context
        :param node_id: ID or UUID of node to lock.
        :param shared: Boolean indicating whether to take a shared or exclusive
                       lock. Default: False.
        :param driver_name: The name of the driver to load, if different
                            from the Node's current driver.
        :param purpose: human-readable purpose to put to debug logs.
        :raises: DriverNotFound
        :raises: NodeNotFound
        :raises: NodeLocked

        """

        self._spawn_method = None
        self._on_error_method = None

        self.context = context
        self.node = None
        self.node_id = node_id
        self.shared = shared

        self.fsm = states.machine.copy()
        self._purpose = purpose
        self._debug_timer = timeutils.StopWatch()

        try:
            LOG.debug("Attempting to get %(type)s lock on node %(node)s (for "
                      "%(purpose)s)",
                      {'type': 'shared' if shared else 'exclusive',
                       'node': node_id, 'purpose': purpose})
            if not self.shared:
                self._lock()
            else:
                self._debug_timer.restart()
                self.node = objects.Node.get(context, node_id)
            self.ports = objects.Port.list_by_node_id(context, self.node.id)
            self.driver = driver_factory.get_driver(driver_name or
                                                    self.node.driver)

            # NOTE(deva): this handles the Juno-era NOSTATE state
            #             and should be deleted after Kilo is released
            if self.node.provision_state is states.NOSTATE:
                self.node.provision_state = states.AVAILABLE
                self.node.save()

            self.fsm.initialize(start_state=self.node.provision_state,
                                target_state=self.node.target_provision_state)

        except Exception:
            with excutils.save_and_reraise_exception():
                self.release_resources()
Beispiel #13
0
 def setUp(self):
     super(WakeOnLanPrivateMethodTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver='fake_wol')
     self.driver = driver_factory.get_driver('fake_wol')
     self.node = obj_utils.create_test_node(self.context,
                                            driver='fake_wol')
     self.port = obj_utils.create_test_port(self.context,
                                            node_id=self.node.id)
Beispiel #14
0
 def setUp(self):
     super(ServiceSetUpMixin, self).setUp()
     self.hostname = 'test-host'
     self.config(enabled_drivers=['fake'])
     self.config(node_locked_retry_attempts=1, group='conductor')
     self.config(node_locked_retry_interval=0, group='conductor')
     self.service = manager.ConductorManager(self.hostname, 'test-topic')
     mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
 def setUp(self):
     super(IPMINativePowerMethodTestCase, self).setUp()
     self.context = context.get_admin_context()
     self.driver = driver_factory.get_driver("pxe_ipminative")
     self.node = obj_utils.create_test_node(self.context,
                                            driver='pxe_ipminative',
                                            driver_info=INFO_DICT)
     #self.dbapi = db_api.get_instance()
     self.info = ipminative._parse_driver_info(self.node)
Beispiel #16
0
 def setUp(self):
     super(SSHDriverTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver="fake_ssh")
     self.driver = driver_factory.get_driver("fake_ssh")
     self.node = obj_utils.create_test_node(
         self.context, driver="fake_ssh", driver_info=db_utils.get_test_ssh_info()
     )
     self.port = obj_utils.create_test_port(self.context, node_id=self.node.id)
     self.sshclient = paramiko.SSHClient()
Beispiel #17
0
    def setUp(self):
        super(IPMIToolDriverTestCase, self).setUp()
        self.context = context.get_admin_context()
        self.dbapi = db_api.get_instance()
        mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
        self.driver = driver_factory.get_driver("fake_ipmitool")

        self.node = obj_utils.create_test_node(self.context, driver="fake_ipmitool", driver_info=INFO_DICT)
        self.info = ipmi._parse_driver_info(self.node)
Beispiel #18
0
 def test_node_set_boot_device_non_existent_device(self):
     mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
     self.driver = driver_factory.get_driver("fake_ipmitool")
     ipmi_info = utils.get_test_ipmi_info()
     node = obj_utils.create_test_node(
         self.context, uuid=uuidutils.generate_uuid(), driver="fake_ipmitool", driver_info=ipmi_info
     )
     task = task_manager.TaskManager(self.context, node.uuid)
     self.assertRaises(exception.InvalidParameterValue, conductor_utils.node_set_boot_device, task, device="fake")
Beispiel #19
0
 def setUp(self):
     super(IBootDriverTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver='fake_iboot')
     self.driver = driver_factory.get_driver('fake_iboot')
     self.node = obj_utils.create_test_node(
             self.context,
             driver='fake_iboot',
             driver_info=INFO_DICT)
     self.info = iboot._parse_driver_info(self.node)
Beispiel #20
0
 def setUp(self):
     super(FakeDriverTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
     self.node = obj_utils.get_test_node(self.context)
     self.task = mock.MagicMock(spec=task_manager.TaskManager)
     self.task.shared = False
     self.task.node = self.node
     self.task.driver = self.driver
Beispiel #21
0
    def setUp(self):
        super(IRMCManagementTestCase, self).setUp()
        driver_info = INFO_DICT

        mgr_utils.mock_the_extension_manager(driver="fake_irmc")
        self.driver = driver_factory.get_driver("fake_irmc")
        self.node = obj_utils.create_test_node(self.context,
                                               driver='fake_irmc',
                                               driver_info=driver_info)
        self.info = irmc_common.parse_driver_info(self.node)
Beispiel #22
0
 def setUp(self):
     super(BaseTestCase, self).setUp()
     self.config(enabled=True, group='discoverd')
     mgr_utils.mock_the_extension_manager("fake_discoverd")
     self.driver = driver_factory.get_driver("fake_discoverd")
     self.node = obj_utils.get_test_node(self.context)
     self.task = mock.Mock(spec=task_manager.TaskManager)
     self.task.context = mock.Mock()
     self.task.shared = False
     self.task.node = self.node
     self.task.driver = self.driver
Beispiel #23
0
 def setUp(self):
     super(BaseTestCase, self).setUp()
     self.config(enabled=True, group='inspector')
     mgr_utils.mock_the_extension_manager("fake_inspector")
     self.driver = driver_factory.get_driver("fake_inspector")
     self.node = obj_utils.get_test_node(self.context)
     self.task = mock.MagicMock(spec=task_manager.TaskManager)
     self.task.context = mock.MagicMock(spec_set=['auth_token'])
     self.task.shared = False
     self.task.node = self.node
     self.task.driver = self.driver
 def setUp(self):
     super(IBootDriverTestCase, self).setUp()
     self.config(max_retry=0, group='iboot')
     self.config(retry_interval=0, group='iboot')
     self.config(reboot_delay=0, group='iboot')
     mgr_utils.mock_the_extension_manager(driver='fake_iboot_fake')
     self.driver = driver_factory.get_driver('fake_iboot_fake')
     self.node = obj_utils.create_test_node(
         self.context,
         driver='fake_iboot_fake',
         driver_info=INFO_DICT)
     self.info = iboot_power._parse_driver_info(self.node)
 def test_node_set_boot_device_non_existent_device(self):
     mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
     self.driver = driver_factory.get_driver("fake_ipmitool")
     ndict = utils.get_test_node(uuid=cmn_utils.generate_uuid(),
                                 driver='fake_ipmitool')
     node = self.dbapi.create_node(ndict)
     task = task_manager.TaskManager(self.context, node.uuid)
     self.assertRaises(exception.InvalidParameterValue,
                       conductor_utils.node_set_boot_device,
                       task,
                       task.node,
                       device='fake')
Beispiel #26
0
    def setUp(self):
        super(IPMINativeDriverTestCase, self).setUp()
        self.context = context.get_admin_context()
        mgr_utils.mock_the_extension_manager(driver="fake_ipminative")
        self.driver = driver_factory.get_driver("fake_ipminative")

        n = db_utils.get_test_node(
                driver='fake_ipminative',
                driver_info=INFO_DICT)
        self.dbapi = db_api.get_instance()
        self.node = self.dbapi.create_node(n)
        self.info = ipminative._parse_driver_info(self.node)
Beispiel #27
0
    def setUp(self):
        super(SeaMicroPowerDriverTestCase, self).setUp()
        mgr_utils.mock_the_extension_manager(driver='fake_seamicro')
        self.driver = driver_factory.get_driver('fake_seamicro')
        self.node = obj_utils.create_test_node(self.context,
                                               driver='fake_seamicro',
                                               driver_info=INFO_DICT)
        self.get_server_patcher = mock.patch.object(seamicro, '_get_server')

        self.get_server_mock = None
        self.Server = Fake_Server
        self.Volume = Fake_Volume
Beispiel #28
0
    def test_node_set_boot_device_valid(self):
        mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
        self.driver = driver_factory.get_driver("fake_ipmitool")
        ipmi_info = utils.get_test_ipmi_info()
        node = obj_utils.create_test_node(
            self.context, uuid=uuidutils.generate_uuid(), driver="fake_ipmitool", driver_info=ipmi_info
        )
        task = task_manager.TaskManager(self.context, node.uuid)

        with mock.patch.object(self.driver.management, "set_boot_device") as mock_sbd:
            conductor_utils.node_set_boot_device(task, device="pxe")
            mock_sbd.assert_called_once_with(task, device="pxe", persistent=False)
Beispiel #29
0
    def setUp(self):
        super(IRMCManagementFunctionsTestCase, self).setUp()
        driver_info = INFO_DICT

        mgr_utils.mock_the_extension_manager(driver="fake_irmc")
        self.driver = driver_factory.get_driver("fake_irmc")
        self.node = obj_utils.create_test_node(self.context,
                                               driver='fake_irmc',
                                               driver_info=driver_info)
        self.info = irmc_common.parse_driver_info(self.node)

        irmc_management.irmc.scci.SCCIError = Exception
        irmc_management.irmc.scci.SCCIInvalidInputError = ValueError
Beispiel #30
0
 def setUp(self):
     super(TestOneViewAgentDeploy, self).setUp()
     self.config(
         post_deploy_get_power_state_retries=GET_POWER_STATE_RETRIES,
         group='agent')
     mgr_utils.mock_the_extension_manager(driver="agent_pxe_oneview")
     self.driver = driver_factory.get_driver("agent_pxe_oneview")
     self.node = obj_utils.create_test_node(
         self.context, driver='agent_pxe_oneview',
         properties=db_utils.get_test_oneview_properties(),
         driver_info=db_utils.get_test_oneview_driver_info(),
         driver_internal_info={'agent_url': 'http://1.2.3.4:5678'},
     )
Beispiel #31
0
 def setUp(self):
     super(NodePowerActionTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
 def test_get_driver_known(self):
     driver = driver_factory.get_driver('fake')
     self.assertIsInstance(driver, drivers_base.BaseDriver)
Beispiel #33
0
    def __init__(self,
                 context,
                 node_id,
                 shared=False,
                 driver_name=None,
                 purpose='unspecified action'):
        """Create a new TaskManager.

        Acquire a lock on a node. The lock can be either shared or
        exclusive. Shared locks may be used for read-only or
        non-disruptive actions only, and must be considerate to what
        other threads may be doing on the same node at the same time.

        :param context: request context
        :param node_id: ID or UUID of node to lock.
        :param shared: Boolean indicating whether to take a shared or exclusive
                       lock. Default: False.
        :param driver_name: The name of the driver to load, if different
                            from the Node's current driver.
        :param purpose: human-readable purpose to put to debug logs.
        :raises: DriverNotFound
        :raises: NodeNotFound
        :raises: NodeLocked

        """

        self._spawn_method = None
        self._on_error_method = None

        self.context = context
        self.node = None
        self.node_id = node_id
        self.shared = shared

        self.fsm = states.machine.copy()
        self._purpose = purpose
        self._debug_timer = timeutils.StopWatch()

        try:
            LOG.debug(
                "Attempting to get %(type)s lock on node %(node)s (for "
                "%(purpose)s)", {
                    'type': 'shared' if shared else 'exclusive',
                    'node': node_id,
                    'purpose': purpose
                })
            if not self.shared:
                self._lock()
            else:
                self._debug_timer.restart()
                self.node = objects.Node.get(context, node_id)

            self.ports = objects.Port.list_by_node_id(context, self.node.id)
            self.portgroups = objects.Portgroup.list_by_node_id(
                context, self.node.id)
            self.driver = driver_factory.get_driver(driver_name
                                                    or self.node.driver)

            # NOTE(deva): this handles the Juno-era NOSTATE state
            #             and should be deleted after Kilo is released
            if self.node.provision_state is states.NOSTATE:
                self.node.provision_state = states.AVAILABLE
                self.node.save()

            self.fsm.initialize(start_state=self.node.provision_state,
                                target_state=self.node.target_provision_state)

        except Exception:
            with excutils.save_and_reraise_exception():
                self.release_resources()
Beispiel #34
0
 def setUp(self):
     super(UtilsTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
     self.node = obj_utils.create_test_node(self.context)
Beispiel #35
0
 def _do_mock(self):
     # NOTE(dtantsur): fake driver always has inspection, using another one
     mgr_utils.mock_the_extension_manager("pxe_ssh")
     self.driver = driver_factory.get_driver("pxe_ssh")
Beispiel #36
0
    def __init__(self, context, node_id, shared=False, driver_name=None,
                 purpose='unspecified action'):
        """Create a new TaskManager.

        Acquire a lock on a node. The lock can be either shared or
        exclusive. Shared locks may be used for read-only or
        non-disruptive actions only, and must be considerate to what
        other threads may be doing on the same node at the same time.

        :param context: request context
        :param node_id: ID or UUID of node to lock.
        :param shared: Boolean indicating whether to take a shared or exclusive
                       lock. Default: False.
        :param driver_name: The name of the driver to load, if different
                            from the Node's current driver.
        :param purpose: human-readable purpose to put to debug logs.
        :raises: DriverNotFound
        :raises: NodeNotFound
        :raises: NodeLocked

        """

        self._spawn_method = None
        self._on_error_method = None

        self.context = context
        self.node = None
        self.shared = shared

        self.fsm = states.machine.copy()
        self._purpose = purpose
        self._debug_timer = time.time()

        # NodeLocked exceptions can be annoying. Let's try to alleviate
        # some of that pain by retrying our lock attempts. The retrying
        # module expects a wait_fixed value in milliseconds.
        @retrying.retry(
            retry_on_exception=lambda e: isinstance(e, exception.NodeLocked),
            stop_max_attempt_number=CONF.conductor.node_locked_retry_attempts,
            wait_fixed=CONF.conductor.node_locked_retry_interval * 1000)
        def reserve_node():
            self.node = objects.Node.reserve(context, CONF.host, node_id)
            LOG.debug("Node %(node)s successfully reserved for %(purpose)s "
                      "(took %(time).2f seconds)",
                      {'node': node_id, 'purpose': purpose,
                       'time': time.time() - self._debug_timer})
            self._debug_timer = time.time()

        try:
            LOG.debug("Attempting to get %(type)s lock on node %(node)s (for "
                      "%(purpose)s)",
                      {'type': 'shared' if shared else 'exclusive',
                       'node': node_id, 'purpose': purpose})
            if not self.shared:
                reserve_node()
            else:
                self.node = objects.Node.get(context, node_id)
            self.ports = objects.Port.list_by_node_id(context, self.node.id)
            self.driver = driver_factory.get_driver(driver_name or
                                                    self.node.driver)

            # NOTE(deva): this handles the Juno-era NOSTATE state
            #             and should be deleted after Kilo is released
            if self.node.provision_state is states.NOSTATE:
                self.node.provision_state = states.AVAILABLE
                self.node.save()

            self.fsm.initialize(self.node.provision_state)

        except Exception:
            with excutils.save_and_reraise_exception():
                self.release_resources()
Beispiel #37
0
 def setUp(self):
     super(NodePowerActionTestCase, self).setUp()
     self.context = context.get_admin_context()
     self.dbapi = dbapi.get_instance()
     mgr_utils.mock_the_extension_manager()
     self.driver = driver_factory.get_driver("fake")
Beispiel #38
0
 def _do_mock(self):
     # NOTE(dtantsur): fake driver always has inspection, using another one
     self.config(enabled_drivers=['pxe_ipmitool'])
     self.driver = driver_factory.get_driver("pxe_ipmitool")