def test_dhcp_options_for_instance_ipxe(self): self.config(tftp_server='192.0.2.1', group='pxe') self.config(pxe_bootfile_name='fake-bootfile', group='pxe') self.config(ipxe_enabled=True, group='pxe') self.config(http_url='http://192.0.3.2:1234', group='pxe') self.config(ipxe_boot_script='/test/boot.ipxe', group='pxe') self.config(dhcp_provider='isc', group='dhcp') expected_boot_script_url = 'http://192.0.3.2:1234/boot.ipxe' expected_info = [{'opt_name': '!175,bootfile-name', 'opt_value': 'fake-bootfile'}, {'opt_name': 'server-ip-address', 'opt_value': '192.0.2.1'}, {'opt_name': 'tftp-server', 'opt_value': '192.0.2.1'}, {'opt_name': 'bootfile-name', 'opt_value': expected_boot_script_url}] with task_manager.acquire(self.context, self.node.uuid) as task: self.assertItemsEqual(expected_info, pxe_utils.dhcp_options_for_instance(task)) self.config(dhcp_provider='neutron', group='dhcp') expected_boot_script_url = 'http://192.0.3.2:1234/boot.ipxe' expected_info = [{'opt_name': 'tag:!ipxe,bootfile-name', 'opt_value': 'fake-bootfile'}, {'opt_name': 'server-ip-address', 'opt_value': '192.0.2.1'}, {'opt_name': 'tftp-server', 'opt_value': '192.0.2.1'}, {'opt_name': 'tag:ipxe,bootfile-name', 'opt_value': expected_boot_script_url}] with task_manager.acquire(self.context, self.node.uuid) as task: self.assertItemsEqual(expected_info, pxe_utils.dhcp_options_for_instance(task))
def test_get_nodes_nested(self): uuids = self.uuids[0:2] more_uuids = self.uuids[3:4] with task_manager.acquire(uuids) as task: self.assertThat(task, ContainsUUIDs(uuids)) with task_manager.acquire(more_uuids) as another_task: self.assertThat(another_task, ContainsUUIDs(more_uuids))
def test_require_exclusive_lock_on_object(self): with task_manager.acquire(self.context, self.uuids, shared=True) as task: self.assertRaises(exception.ExclusiveLockRequired, self._do_state_change, task) with task_manager.acquire(self.context, self.uuids, shared=False) as task: self._do_state_change(task) for uuid in self.uuids: res = objects.Node.get_by_uuid(self.context, uuid) self.assertEqual("test-state", res.power_state)
def test_require_exclusive_lock_on_object(self): with task_manager.acquire(self.uuids, shared=True) as task: self.assertRaises(exception.ExclusiveLockRequired, self._do_state_change, task) with task_manager.acquire(self.uuids, shared=False) as task: self._do_state_change(task) for uuid in self.uuids: res = self.dbapi.get_node(uuid) self.assertEqual("test-state", res.task_state)
def test_remove_vifs_from_node(self): db_utils.create_test_port( node_id=self.node.id, address='aa:bb:cc:dd:ee:ff', internal_info={driver_common.TENANT_VIF_KEY: 'test-vif-A'}) db_utils.create_test_portgroup( node_id=self.node.id, address='dd:ee:ff:aa:bb:cc', internal_info={driver_common.TENANT_VIF_KEY: 'test-vif-B'}) with task_manager.acquire(self.context, self.node.uuid) as task: network.remove_vifs_from_node(task) with task_manager.acquire(self.context, self.node.uuid) as task: result = network.get_node_vif_ids(task) self.assertEqual({}, result['ports']) self.assertEqual({}, result['portgroups'])
def test_should_write_image(self): 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: self.assertFalse(self.interface.should_write_image(task)) self.node.instance_info = {'image_source': 'fake-value'} self.node.save() with task_manager.acquire(self.context, self.node.id) as task: self.assertTrue(self.interface.should_write_image(task))
def test_get_shared_lock(self): uuids = self.uuids[0:2] # confirm we can elevate from shared -> exclusive with task_manager.acquire(uuids, shared=True) as task: self.assertThat(task, ContainsUUIDs(uuids)) with task_manager.acquire(uuids, shared=False) as inner_task: self.assertThat(inner_task, ContainsUUIDs(uuids)) # confirm someone else can still get a shared lock with task_manager.acquire(uuids, shared=False) as task: self.assertThat(task, ContainsUUIDs(uuids)) with task_manager.acquire(uuids, shared=True) as inner_task: self.assertThat(inner_task, ContainsUUIDs(uuids))
def test_remove_vifs_from_node_failure(self, mock_unbind): db_utils.create_test_port( node_id=self.node.id, address='aa:bb:cc:dd:ee:ff', internal_info={driver_common.TENANT_VIF_KEY: 'test-vif-A'}) db_utils.create_test_portgroup( node_id=self.node.id, address='dd:ee:ff:aa:bb:cc', internal_info={driver_common.TENANT_VIF_KEY: 'test-vif-B'}) mock_unbind.side_effect = [exception.NetworkError, None] with task_manager.acquire(self.context, self.node.uuid) as task: network.remove_vifs_from_node(task) with task_manager.acquire(self.context, self.node.uuid) as task: result = network.get_node_vif_ids(task) self.assertEqual({}, result['ports']) self.assertEqual({}, result['portgroups']) self.assertEqual(2, mock_unbind.call_count)
def test_require_exclusive_lock(self): @task_manager.require_exclusive_lock def do_state_change(task): for r in task.resources: task.dbapi.update_node(r.node.uuid, {"power_state": "test-state"}) with task_manager.acquire(self.context, self.uuids, shared=True) as task: self.assertRaises(exception.ExclusiveLockRequired, do_state_change, task) with task_manager.acquire(self.context, self.uuids, shared=False) as task: do_state_change(task) for uuid in self.uuids: res = objects.Node.get_by_uuid(self.context, uuid) self.assertEqual("test-state", res.power_state)
def test_vendor_passthru_driver_routes(self): expected = ['lookup'] with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: driver_routes = task.driver.vendor.driver_routes self.assertIsInstance(driver_routes, dict) self.assertEqual(expected, list(driver_routes))
def test_get_properties(self): expected = irmc_common.COMMON_PROPERTIES expected.update(ipmitool.COMMON_PROPERTIES) expected.update(ipmitool.CONSOLE_PROPERTIES) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(expected, task.driver.get_properties())
def test_lookup_v2_empty_interfaces(self): with task_manager.acquire(self.context, self.node.uuid) as task: self.assertRaises(exception.NodeNotFound, self.passthru.lookup, task.context, version='2', inventory={'interfaces': []})
def test_management_interface_get_supported_boot_devices(self): with task_manager.acquire(self.context, self.node.uuid) as task: expected = [boot_devices.PXE, boot_devices.DISK, boot_devices.CDROM, boot_devices.BIOS, boot_devices.SAFE] self.assertEqual(sorted(expected), sorted(task.driver.management. get_supported_boot_devices()))
def test_deallocate_server_hardware_from_ironic_missing_profile_uuid( self, mock_node_save, mock_get_ov_client ): """Test for case when server profile application fails. Due to an error when applying Server Profile in OneView, the node will have no Server Profile uuid in the 'applied_server_profile_uri' namespace. When the method tested is called without Server Profile uuid, the client will raise a ValueError when trying to delete the profile, this error is converted to an OneViewError. """ ov_client = mock_get_ov_client.return_value fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = 'any/applied_sp_uri/' ov_client.get_server_hardware_by_uuid.return_value = fake_sh ov_client.delete_server_profile.side_effect = ValueError mock_get_ov_client.return_value = ov_client with task_manager.acquire(self.context, self.node.uuid) as task: driver_info = task.node.driver_info driver_info['applied_server_profile_uri'] = 'any/applied_sp_uri/' task.node.driver_info = driver_info self.assertRaises( exception.OneViewError, deploy_utils.deallocate_server_hardware_from_ironic, ov_client, task.node ) self.assertTrue(ov_client.delete_server_profile.called) self.assertTrue( 'applied_server_profile_uri' in task.node.driver_info )
def test_tear_down(self, mock_get_ov_client): """`tear_down` behavior when node already has Profile applied """ sp_uri = '/rest/server-profiles/1234556789' ov_client = mock_get_ov_client() fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = sp_uri ov_client = mock_get_ov_client.return_value ov_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: driver_info = task.node.driver_info driver_info['applied_server_profile_uri'] = \ '/rest/server-profiles/1234556789' task.node.driver_info = driver_info self.assertTrue( 'applied_server_profile_uri' in task.node.driver_info ) deploy_utils.tear_down(ov_client, task) self.assertFalse( 'applied_server_profile_uri' in task.node.driver_info ) self.assertTrue( ov_client.delete_server_profile.called )
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'])
def test_allocate_server_hardware_to_ironic_node_has_server_profile( self, mock_delete_applied_sp, mock_node_save, mock_get_ov_client ): """Tests server profile allocation when applied_server_profile_uri exists. This test consider that no Server Profile is applied on the Server Hardware but the applied_server_profile_uri remained on the node. Thus, the conductor should remove the value and apply a new server profile to use the node. """ oneview_client = mock_get_ov_client() fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None oneview_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: driver_info = task.node.driver_info driver_info['applied_server_profile_uri'] = 'any/applied_sp_uri/' task.node.driver_info = driver_info deploy_utils.allocate_server_hardware_to_ironic( oneview_client, task.node, 'serverProfileName' ) self.assertTrue(mock_delete_applied_sp.called)
def test_clean_up_instance(self, get_image_info_mock, clean_up_pxe_env_mock): with task_manager.acquire(self.context, self.node.uuid) as task: image_info = {"kernel": ["", "/path/to/kernel"], "ramdisk": ["", "/path/to/ramdisk"]} get_image_info_mock.return_value = image_info task.driver.boot.clean_up_instance(task) clean_up_pxe_env_mock.assert_called_once_with(task, image_info) get_image_info_mock.assert_called_once_with(task.node, task.context)
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'])
def test_validate_fail_missing_image_source(self): info = dict(INST_INFO_DICT) del info["image_source"] self.node.instance_info = json.dumps(info) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: task.node["instance_info"] = json.dumps(info) self.assertRaises(exception.MissingParameterValue, task.driver.boot.validate, task)
def test_validate_fail_invalid_trusted_boot_value(self): properties = {"capabilities": "trusted_boot:value"} instance_info = {"trusted_boot": "value"} with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: task.node.properties = properties task.node.instance_info["capabilities"] = instance_info self.assertRaises(exception.InvalidParameterValue, task.driver.boot.validate, task)
def test_deploy_boot_mode_exists(self, set_persistent_mock, pxe_deploy_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.driver.deploy.deploy(task) set_persistent_mock.assert_called_with(task, boot_devices.PXE) pxe_deploy_mock.assert_called_once_with(mock.ANY, task)
def test__clean_up_pxe_env(self, mock_cache, mock_pxe_clean, mock_unlink): image_info = {"label": ["", "deploy_kernel"]} with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: pxe._clean_up_pxe_env(task, image_info) mock_pxe_clean.assert_called_once_with(task) mock_unlink.assert_any_call("deploy_kernel") mock_cache.return_value.clean_up.assert_called_once_with()
def test_reset_ilo_credential_no_password(self, clean_step_mock, log_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.driver.management.reset_ilo_credential(task) self.assertFalse(clean_step_mock.called) self.assertTrue(log_mock.info.called)
def test__validate_MissingParam(self, mock_parse_driver_info): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: self.assertRaisesRegex(exception.MissingParameterValue, "Missing 'ilo_deploy_iso'", ilo_deploy._validate, task) mock_parse_driver_info.assert_called_once_with(task.node)
def test_get_supported_power_states(self): with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: supported_power_states = ( task.driver.power.get_supported_power_states(task)) self.assertEqual(list(redfish_power.SET_POWER_STATE_MAP), supported_power_states)
def test_heartbeat(self): kwargs = { 'agent_url': 'http://127.0.0.1:9999/bar' } with task_manager.acquire( self.context, self.node['uuid'], shared=True) as task: self.passthru.heartbeat(task, **kwargs)
def test_set_power_state_not_reached(self, mock_get_system): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: self.config(power_state_change_timeout=2, group='conductor') expected_values = [ (states.POWER_ON, sushy.RESET_ON), (states.POWER_OFF, sushy.RESET_FORCE_OFF), (states.REBOOT, sushy.RESET_FORCE_RESTART), (states.SOFT_REBOOT, sushy.RESET_GRACEFUL_RESTART), (states.SOFT_POWER_OFF, sushy.RESET_GRACEFUL_SHUTDOWN) ] for target, expected in expected_values: fake_system = mock_get_system.return_value if target in (states.POWER_OFF, states.SOFT_POWER_OFF): fake_system.power_state = sushy.SYSTEM_POWER_STATE_ON else: fake_system.power_state = sushy.SYSTEM_POWER_STATE_OFF self.assertRaises(exception.PowerStateFailure, task.driver.power.set_power_state, task, target) # Asserts fake_system.reset_system.assert_called_once_with(expected) mock_get_system.assert_called_with(task.node) # Reset mocks mock_get_system.reset_mock()
def test_reboot(self, mock_get_system): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: expected_values = [ (sushy.SYSTEM_POWER_STATE_ON, sushy.RESET_FORCE_RESTART), (sushy.SYSTEM_POWER_STATE_OFF, sushy.RESET_ON) ] for current, expected in expected_values: system_result = [ # Initial state mock.Mock(power_state=current), # Transient state - powering off mock.Mock(power_state=sushy.SYSTEM_POWER_STATE_OFF), # Final state - down powering off mock.Mock(power_state=sushy.SYSTEM_POWER_STATE_ON) ] mock_get_system.side_effect = system_result task.driver.power.reboot(task) # Asserts system_result[0].reset_system.assert_called_once_with(expected) mock_get_system.assert_called_with(task.node) self.assertEqual(3, mock_get_system.call_count) # Reset mocks mock_get_system.reset_mock()
def test_set_power_state(self, mock_get_system): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: expected_values = [ (states.POWER_ON, sushy.RESET_ON), (states.POWER_OFF, sushy.RESET_FORCE_OFF), (states.REBOOT, sushy.RESET_FORCE_RESTART), (states.SOFT_REBOOT, sushy.RESET_GRACEFUL_RESTART), (states.SOFT_POWER_OFF, sushy.RESET_GRACEFUL_SHUTDOWN) ] for target, expected in expected_values: if target in (states.POWER_OFF, states.SOFT_POWER_OFF): final = sushy.SYSTEM_POWER_STATE_OFF transient = sushy.SYSTEM_POWER_STATE_ON else: final = sushy.SYSTEM_POWER_STATE_ON transient = sushy.SYSTEM_POWER_STATE_OFF system_result = [ mock.Mock(power_state=transient) ] * 3 + [mock.Mock(power_state=final)] mock_get_system.side_effect = system_result task.driver.power.set_power_state(task, target) # Asserts system_result[0].reset_system.assert_called_once_with(expected) mock_get_system.assert_called_with(task.node) self.assertEqual(4, mock_get_system.call_count) # Reset mocks mock_get_system.reset_mock()
def test_set_power_state_invalid_state(self): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: self.assertRaises(exception.InvalidParameterValue, task.driver.power.set_power_state, task, 'invalid-state')
def test_reboot(self, run_method_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.driver.power.reboot(task) run_method_mock.assert_any_call(task.node, 'reboot', 'stop') run_method_mock.assert_any_call(task.node, 'reboot', 'start')
def test_set_boot_device_invalid(self, run_method_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: self.assertRaises(exception.InvalidParameterValue, task.driver.management.set_boot_device, task, 'invalid-boot-device')
def test_power_interface_validate_good(self, parse_drv_info_mock): with task_manager.acquire(self.context, self.node['uuid'], shared=True) as task: task.driver.power.validate(task) self.assertEqual(1, parse_drv_info_mock.call_count)
def _test_prepare_ramdisk(self, mock_pxe_config, mock_build_pxe, mock_cache_r_k, mock_deploy_img_info, mock_instance_img_info, dhcp_factory_mock, set_boot_device_mock, get_boot_mode_mock, uefi=False, cleaning=False, ipxe_use_swift=False, whole_disk_image=False, mode='deploy', node_boot_mode=None, persistent=False): mock_build_pxe.return_value = {} kernel_label = '%s_kernel' % mode ramdisk_label = '%s_ramdisk' % mode mock_deploy_img_info.return_value = { kernel_label: 'a', ramdisk_label: 'r' } if whole_disk_image: mock_instance_img_info.return_value = {} else: mock_instance_img_info.return_value = {'kernel': 'b'} mock_pxe_config.return_value = None mock_cache_r_k.return_value = None provider_mock = mock.MagicMock() dhcp_factory_mock.return_value = provider_mock get_boot_mode_mock.return_value = node_boot_mode driver_internal_info = self.node.driver_internal_info driver_internal_info['is_whole_disk_image'] = whole_disk_image self.node.driver_internal_info = driver_internal_info if mode == 'rescue': mock_deploy_img_info.return_value = { 'rescue_kernel': 'a', 'rescue_ramdisk': 'r' } self.node.save() with task_manager.acquire(self.context, self.node.uuid) as task: dhcp_opts = pxe_utils.dhcp_options_for_instance(task, ipxe_enabled=True) task.driver.boot.prepare_ramdisk(task, {'foo': 'bar'}) mock_deploy_img_info.assert_called_once_with(task.node, mode=mode, ipxe_enabled=True) provider_mock.update_dhcp.assert_called_once_with(task, dhcp_opts) if self.node.provision_state == states.DEPLOYING: get_boot_mode_mock.assert_called_once_with(task) set_boot_device_mock.assert_called_once_with(task, boot_devices.PXE, persistent=persistent) if ipxe_use_swift: if whole_disk_image: self.assertFalse(mock_cache_r_k.called) else: mock_cache_r_k.assert_called_once_with(task, {'kernel': 'b'}, ipxe_enabled=True) mock_instance_img_info.assert_called_once_with( task, ipxe_enabled=True) elif not cleaning and mode == 'deploy': mock_cache_r_k.assert_called_once_with(task, { 'deploy_kernel': 'a', 'deploy_ramdisk': 'r', 'kernel': 'b' }, ipxe_enabled=True) mock_instance_img_info.assert_called_once_with( task, ipxe_enabled=True) elif mode == 'deploy': mock_cache_r_k.assert_called_once_with(task, { 'deploy_kernel': 'a', 'deploy_ramdisk': 'r' }, ipxe_enabled=True) elif mode == 'rescue': mock_cache_r_k.assert_called_once_with(task, { 'rescue_kernel': 'a', 'rescue_ramdisk': 'r' }, ipxe_enabled=True) if uefi: mock_pxe_config.assert_called_once_with( task, {}, CONF.pxe.uefi_pxe_config_template, ipxe_enabled=True) else: mock_pxe_config.assert_called_once_with( task, {}, CONF.pxe.pxe_config_template, ipxe_enabled=True)
def test_validate(self, mock_drvinfo): with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: task.driver.management.validate(task) mock_drvinfo.assert_called_once_with(task.node)
def test_set_boot_device_fail(self): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: self.assertRaises(exception.InvalidParameterValue, task.driver.management.set_boot_device, task, 'fake-device')
def test_validate(self, driver_info_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.driver.inspect.validate(task) driver_info_mock.assert_called_once_with(task.node)
def test_dhcp_options_for_instance_ipxe_uefi(self): boot_file = 'fake-bootfile-uefi' self.config(uefi_pxe_bootfile_name=boot_file, group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: task.node.properties['capabilities'] = 'boot_mode:uefi' self._dhcp_options_for_instance_ipxe(task, boot_file)
def test_dhcp_options_for_instance_ipxe_bios(self): boot_file = 'fake-bootfile-bios' self.config(pxe_bootfile_name=boot_file, group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: self._dhcp_options_for_instance_ipxe(task, boot_file)
def test_validate_rescue(self): with task_manager.acquire(self.context, self.node.uuid) as task: task.driver.boot.validate_rescue(task)
def test_get_properties(self): expected = pxe_base.COMMON_PROPERTIES expected.update(agent_base.VENDOR_PROPERTIES) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(expected, task.driver.get_properties())
def test_validate_fail_no_image_kernel_ramdisk_props(self, mock_glance): mock_glance.return_value = {'properties': {}} with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertRaises(exception.MissingParameterValue, task.driver.boot.validate, task)
def test_validate_fail_glance_image_doesnt_exists(self, mock_glance): mock_glance.side_effect = exception.ImageNotFound('not found') with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertRaises(exception.InvalidParameterValue, task.driver.boot.validate, task)
def test_validate_good_whole_disk_image(self, mock_glance): with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: task.node.driver_internal_info['is_whole_disk_image'] = True task.driver.boot.validate(task)
def test_validate_fail_missing_deploy_ramdisk(self): with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: del task.node.driver_info['deploy_ramdisk'] self.assertRaises(exception.MissingParameterValue, task.driver.boot.validate, task)
def test_rollback_ports(self, remove_mock): with task_manager.acquire(self.context, self.node.uuid) as task: neutron.rollback_ports(task, self.network_uuid) remove_mock.assert_called_once_with(task, self.network_uuid)
def test_rollback_ports_exception(self, remove_mock, log_mock): remove_mock.side_effect = exception.NetworkError('boom') with task_manager.acquire(self.context, self.node.uuid) as task: neutron.rollback_ports(task, self.network_uuid) self.assertTrue(log_mock.exception.called)
def test_get_node_vif_ids_no_ports_no_portgroups(self): expected = {'portgroups': {}, 'ports': {}} with task_manager.acquire(self.context, self.node.uuid) as task: result = network.get_node_vif_ids(task) self.assertEqual(expected, result)
def test_get_node_portmap(self): with task_manager.acquire(self.context, self.node.uuid) as task: portmap = neutron.get_node_portmap(task) self.assertEqual( {self.ports[0].uuid: self.ports[0].local_link_connection}, portmap)
def test_get_physnets_for_node_excludes_None(self): node = object_utils.create_test_node(self.context) object_utils.create_test_port(self.context, node_id=node.id) with task_manager.acquire(self.context, node.uuid) as task: res = network.get_physnets_for_node(task) self.assertEqual(set(), res)
def _test(self, expected_result, exclude_port=None): with task_manager.acquire(self.context, self.node.uuid) as task: result = network.get_physnets_by_portgroup_id( task, self.portgroup.id, exclude_port) self.assertEqual(expected_result, result)
def test_management_interface_get_boot_device(self): with task_manager.acquire(self.context, self.node.uuid) as task: expected = {'boot_device': None, 'persistent': None} self.assertEqual(expected, task.driver.management.get_boot_device(task))
def test_management_interface_validate_good(self): with task_manager.acquire(self.context, self.node.uuid) as task: task.driver.management.validate(task)
def test_get_boot_device(self): expected = {'boot_device': boot_devices.DISK, 'persistent': True} with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(expected, task.driver.management.get_boot_device(task))
def test_management_interface_get_supported_boot_devices(self): with task_manager.acquire(self.context, self.node.uuid) as task: expected = [boot_devices.PXE, boot_devices.DISK] self.assertEqual( sorted(expected), sorted(task.driver.management.get_supported_boot_devices()))
def test_get_sensor_data(self): with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertRaises(NotImplementedError, task.driver.management.get_sensors_data, task)
def test_get_properties(self): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: properties = ilo_common.REQUIRED_PROPERTIES.copy() self.assertEqual(properties, task.driver.inspect.get_properties())
def test_get_properties(self): expected = amt_common.COMMON_PROPERTIES with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(expected, task.driver.get_properties())
def test_get_properties(self): expected = seamicro.COMMON_PROPERTIES with task_manager.acquire(self.context, self.node['uuid'], shared=True) as task: self.assertEqual(expected, task.driver.get_properties())