def test__parse_driver_info(self): # make sure we get back the expected things self.assertIsNotNone(self.info.get('address')) self.assertIsNotNone(self.info.get('username')) self.assertIsNotNone(self.info.get('password')) self.assertIsNotNone(self.info.get('uuid')) info = dict(INFO_DICT) # test the default value for 'priv_level' node = db_utils.get_test_node(driver_info=info) ret = ipmi._parse_driver_info(node) self.assertEqual('ADMINISTRATOR', ret['priv_level']) # ipmi_username / ipmi_password are not mandatory del info['ipmi_username'] node = db_utils.get_test_node(driver_info=info) ipmi._parse_driver_info(node) del info['ipmi_password'] node = db_utils.get_test_node(driver_info=info) ipmi._parse_driver_info(node) # make sure error is raised when ipmi_address is missing del info['ipmi_address'] node = db_utils.get_test_node(driver_info=info) self.assertRaises(exception.InvalidParameterValue, ipmi._parse_driver_info, node) # test the invalid priv_level value self.info['priv_level'] = 'ABCD' node = db_utils.get_test_node(driver_info=info) self.assertRaises(exception.InvalidParameterValue, ipmi._parse_driver_info, node)
def test_get_nodeinfo_list_provision(self, mock_utcnow): past = datetime.datetime(2000, 1, 1, 0, 0) next = past + datetime.timedelta(minutes=8) present = past + datetime.timedelta(minutes=10) mock_utcnow.return_value = past # node with provision_updated timeout n1 = utils.get_test_node(id=1, uuid=ironic_utils.generate_uuid(), provision_updated_at=past) # node with None in provision_updated_at n2 = utils.get_test_node(id=2, uuid=ironic_utils.generate_uuid(), provision_state=states.DEPLOYWAIT) # node without timeout n3 = utils.get_test_node(id=3, uuid=ironic_utils.generate_uuid(), provision_updated_at=next) self.dbapi.create_node(n1) self.dbapi.create_node(n2) self.dbapi.create_node(n3) mock_utcnow.return_value = present res = self.dbapi.get_nodeinfo_list(filters={'provisioned_before': 300}) self.assertEqual([1], [r[0] for r in res]) res = self.dbapi.get_nodeinfo_list(filters={'provision_state': states.DEPLOYWAIT}) self.assertEqual([2], [r[0] for r in res])
def test_get_nodeinfo_list_with_filters(self): n1 = utils.get_test_node(id=1, driver='driver-one', instance_uuid=ironic_utils.generate_uuid(), reservation='fake-host', uuid=ironic_utils.generate_uuid()) n2 = utils.get_test_node(id=2, driver='driver-two', uuid=ironic_utils.generate_uuid(), maintenance=True) self.dbapi.create_node(n1) self.dbapi.create_node(n2) res = self.dbapi.get_nodeinfo_list(filters={'driver': 'driver-one'}) self.assertEqual([1], [r[0] for r in res]) res = self.dbapi.get_nodeinfo_list(filters={'driver': 'bad-driver'}) self.assertEqual([], [r[0] for r in res]) res = self.dbapi.get_nodeinfo_list(filters={'associated': True}) self.assertEqual([1], [r[0] for r in res]) res = self.dbapi.get_nodeinfo_list(filters={'associated': False}) self.assertEqual([2], [r[0] for r in res]) res = self.dbapi.get_nodeinfo_list(filters={'reserved': True}) self.assertEqual([1], [r[0] for r in res]) res = self.dbapi.get_nodeinfo_list(filters={'reserved': False}) self.assertEqual([2], [r[0] for r in res]) res = self.dbapi.get_node_list(filters={'maintenance': True}) self.assertEqual([2], [r.id for r in res]) res = self.dbapi.get_node_list(filters={'maintenance': False}) self.assertEqual([1], [r.id for r in res])
def test_create_node_instance_already_associated(self): instance = ironic_utils.generate_uuid() n1 = utils.get_test_node(id=1, uuid=ironic_utils.generate_uuid(), instance_uuid=instance) self.dbapi.create_node(n1) n2 = utils.get_test_node(id=2, uuid=ironic_utils.generate_uuid(), instance_uuid=instance) self.assertRaises(exception.InstanceAssociated, self.dbapi.create_node, n2)
def test__sync_power_state_node_no_power_state(self): self.service.start() self.config(force_power_state_during_sync=False, group='conductor') # create three nodes nodes = [] for i in range(0, 3): n = utils.get_test_node(id=i, uuid=ironic_utils.generate_uuid(), driver='fake', power_state=states.POWER_OFF) self.dbapi.create_node(n) nodes.append(n['uuid']) # cannot get power state of node 2; only nodes 1 & 3 have # their power states changed. with mock.patch.object(self.driver.power, 'get_power_state') as get_power_mock: returns = [states.POWER_ON, exception.InvalidParameterValue("invalid"), states.POWER_ON] def side_effect(*args): result = returns.pop(0) if isinstance(result, Exception): raise result return result get_power_mock.side_effect = side_effect self.service._sync_power_states(self.context) self.assertThat(returns, HasLength(0)) final = [states.POWER_ON, states.POWER_OFF, states.POWER_ON] for i in range(0, 3): n = self.dbapi.get_node(nodes[i]) self.assertEqual(n.power_state, final[i])
def setUp(self): super(TestACL, self).setUp() self.environ = {"fake.cache": utils.FakeMemcache()} self.fake_db_node = db_utils.get_test_node(chassis_id=None) self.dbapi = db_api.get_instance() self.node_path = "/nodes/%s" % self.fake_db_node["uuid"]
def test__parse_driver_info_missing_creds(self): # make sure error is raised when info is missing info = db_utils.get_test_ssh_info('no-creds') node = db_utils.get_test_node(driver_info=info) self.assertRaises(exception.InvalidParameterValue, ssh._parse_driver_info, node)
def setUp(self): super(SSHDriverTestCase, self).setUp() self.driver = mgr_utils.get_mocked_node_manager(driver="fake_ssh") self.node = db_utils.get_test_node(driver="fake_ssh", driver_info=db_utils.ssh_info) self.dbapi = dbapi.get_instance() self.dbapi.create_node(self.node) self.sshclient = paramiko.SSHClient()
def test_change_node_power_state_node_already_locked(self, pwr_act_mock): # Test change_node_power_state with mocked # conductor.utils.node_power_action. fake_reservation = 'fake-reserv' pwr_state = states.POWER_ON n = utils.get_test_node(driver='fake', power_state=pwr_state, reservation=fake_reservation) db_node = self.dbapi.create_node(n) self.service.start() self.assertRaises(exception.NodeLocked, self.service.change_node_power_state, self.context, db_node.uuid, states.POWER_ON) # In this test worker should not be spawned, but waiting to make sure # the below perform_mock assertion is valid. self.service._worker_pool.waitall() self.assertFalse(pwr_act_mock.called, 'node_power_action has been ' 'unexpectedly called.') # Verify existing reservation wasn't broken. db_node.refresh(self.context) self.assertEqual(fake_reservation, db_node.reservation)
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 test_maintenance_mode_on(self): ndict = utils.get_test_node(driver='fake') node = self.dbapi.create_node(ndict) self.service.change_node_maintenance_mode(self.context, node.uuid, True) node.refresh(self.context) self.assertTrue(node.maintenance)
def test_change_node_power_state_worker_pool_full(self): # Test change_node_power_state including integration with # conductor.utils.node_power_action and lower. initial_state = states.POWER_OFF n = utils.get_test_node(driver='fake', power_state=initial_state) db_node = self.dbapi.create_node(n) self.service.start() with mock.patch.object(self.service, '_spawn_worker') \ as spawn_mock: spawn_mock.side_effect = exception.NoFreeConductorWorker() self.assertRaises(exception.NoFreeConductorWorker, self.service.change_node_power_state, self.context, db_node.uuid, states.POWER_ON) spawn_mock.assert_called_once_with(mock.ANY, mock.ANY, mock.ANY, mock.ANY) db_node.refresh(self.context) self.assertEqual(initial_state, db_node.power_state) self.assertIsNone(db_node.target_power_state) self.assertIsNone(db_node.last_error) # Verify the picked reservation has been cleared due to full pool. self.assertIsNone(db_node.reservation)
def test_change_node_power_state_set_power_failure(self): """Test if an exception is thrown when the set_power call fails. """ ndict = utils.get_test_node(driver='fake', power_state=states.POWER_OFF) node = self.dbapi.create_node(ndict) with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: with mock.patch.object(self.driver.power, 'set_power_state') \ as set_power_mock: get_power_mock.return_value = states.POWER_OFF set_power_mock.side_effect = exception.IronicException() self.assertRaises(exception.IronicException, self.service.change_node_power_state, self.context, node['uuid'], states.POWER_ON) node.refresh(self.context) get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) set_power_mock.assert_called_once_with(mock.ANY, mock.ANY, states.POWER_ON) self.assertEqual(node['power_state'], states.POWER_OFF) self.assertEqual(node['target_power_state'], None) self.assertNotEqual(node['last_error'], None)
def test_disable_console_already_disabled(self): ndict = utils.get_test_node(driver='fake', console_enabled=False) node = self.dbapi.create_node(ndict) with mock.patch.object(self.driver.console, 'stop_console') \ as mock_sc: self.service.set_console_mode(self.context, node.uuid, False) self.assertFalse(mock_sc.called)
def test_change_node_power_state_invalid_state(self): """Test if an exception is thrown when changing to an invalid power state. """ ndict = utils.get_test_node(driver='fake', power_state=states.POWER_ON) node = self.dbapi.create_node(ndict) with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: get_power_mock.return_value = states.POWER_ON self.assertRaises(exception.InvalidParameterValue, self.service.change_node_power_state, self.context, node['uuid'], "POWER") node.refresh(self.context) get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) self.assertEqual(node['power_state'], states.POWER_ON) self.assertEqual(node['target_power_state'], None) self.assertNotEqual(node['last_error'], None) # last_error is cleared when a new transaction happens self.service.change_node_power_state(self.context, node['uuid'], states.POWER_OFF) node.refresh(self.context) self.assertEqual(node['power_state'], states.POWER_OFF) self.assertEqual(node['target_power_state'], None) self.assertEqual(node['last_error'], None)
def setUp(self): super(TestACL, self).setUp() self.environ = {'fake.cache': utils.FakeMemcache()} self.fake_node = db_utils.get_test_node(chassis_id=None) self.dbapi = db_api.get_instance() self.node_path = '/nodes/%s' % self.fake_node['uuid']
def test_post_ports_subresource(self): ndict = dbutils.get_test_node() self.post_json('/nodes', ndict) pdict = dbutils.get_test_port() response = self.post_json('/nodes/ports', pdict, expect_errors=True) self.assertEqual(response.status_int, 403)
def setUp(self): super(ManagerRpcAPITestCase, self).setUp() self.context = context.get_admin_context() self.dbapi = dbapi.get_instance() self.fake_node = json.to_primitive(dbutils.get_test_node( control_driver='fake', deploy_driver='fake'))
def test_destroy_node(self): n = utils.get_test_node() self.dbapi.create_node(n) self.dbapi.destroy_node(n['id']) self.assertRaises(exception.NodeNotFound, self.dbapi.destroy_node, n['id'])
def test_change_node_power_state_in_same_state(self): """Test that we don't try to set the power state if the requested state is the same as the current state. """ ndict = utils.get_test_node(driver='fake', last_error='anything but None', power_state=states.POWER_ON) node = self.dbapi.create_node(ndict) with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: get_power_mock.return_value = states.POWER_ON with mock.patch.object(self.driver.power, 'set_power_state') \ as set_power_mock: set_power_mock.side_effect = exception.IronicException() self.service.change_node_power_state(self.context, node['uuid'], states.POWER_ON) node.refresh(self.context) get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) self.assertFalse(set_power_mock.called) self.assertEqual(node['power_state'], states.POWER_ON) self.assertEqual(node['target_power_state'], None) self.assertEqual(node['last_error'], None)
def test_node_power_action_invalid_state(self): """Test if an exception is thrown when changing to an invalid power state. """ ndict = utils.get_test_node(uuid=cmn_utils.generate_uuid(), driver='fake', power_state=states.POWER_ON) node = self.dbapi.create_node(ndict) task = task_manager.TaskManager(self.context, node.uuid) with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: get_power_mock.return_value = states.POWER_ON self.assertRaises(exception.InvalidParameterValue, conductor_utils.node_power_action, task, task.node, "INVALID_POWER_STATE") node.refresh(self.context) get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) self.assertEqual(node['power_state'], states.POWER_ON) self.assertIsNone(node['target_power_state']) self.assertIsNotNone(node['last_error']) # last_error is cleared when a new transaction happens conductor_utils.node_power_action(task, task.node, states.POWER_OFF) node.refresh(self.context) self.assertEqual(node['power_state'], states.POWER_OFF) self.assertIsNone(node['target_power_state']) self.assertIsNone(node['last_error'])
def setUp(self): super(SSHDriverTestCase, self).setUp() self.driver = mgr_utils.get_mocked_node_manager(driver='fake_ssh') self.node = db_utils.get_test_node( driver='fake_ssh', driver_info=INFO_DICT) self.dbapi = dbapi.get_instance() self.dbapi.create_node(self.node) 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 test_create_port_using_node_name(self, mock_utcnow, mock_anln): mock_anln.return_value = True pdict = apiutils.port_post_data() ndict = dbutils.get_test_node() del pdict['node_id'] ndict['name'] = 'nodenaaame' ndict['created_at'] = datetime.datetime(2000, 1, 1, 0, 0) ndict['uuid'] = '1ab23c4d-03f2-4d2e-ae87-c02d7f33c126' node = obj_utils.create_test_node(self.context, **ndict) pdict['node'] = node.name test_time = datetime.datetime(2000, 1, 1, 0, 0) mock_utcnow.return_value = test_time response = self.post_json('/ports', pdict) self.assertEqual(201, response.status_int) result = self.get_json('/ports/%s' % pdict['uuid']) self.assertEqual(pdict['uuid'], result['uuid']) self.assertFalse(result['updated_at']) return_created_at = timeutils.parse_isotime( result['created_at']).replace(tzinfo=None) self.assertEqual(test_time, return_created_at) # Check location header self.assertIsNotNone(response.location) expected_location = '/v1/ports/%s' % pdict['uuid'] self.assertEqual(urlparse.urlparse(response.location).path, expected_location) data = self.get_json("/ports?node=%s" % pdict['node'], headers={api_controller.Version.string: '1.5'}) data = self.get_json('/ports/%s' % pdict['uuid']) self.assertEqual(pdict['uuid'], data['uuid']) self.assertIn('extra', data) self.assertIn('node', data)
def test_node_power_action_invalid_driver_info(self): """Test if an exception is thrown when the driver validation fails. """ ndict = utils.get_test_node(uuid=cmn_utils.generate_uuid(), driver='fake', power_state=states.POWER_ON) node = self.dbapi.create_node(ndict) task = task_manager.TaskManager(self.context, node.uuid) with mock.patch.object(self.driver.power, 'validate') \ as validate_mock: validate_mock.side_effect = exception.InvalidParameterValue( 'wrong power driver info') self.assertRaises(exception.InvalidParameterValue, conductor_utils.node_power_action, task, task.node, states.POWER_ON) node.refresh(self.context) validate_mock.assert_called_once_with(mock.ANY, mock.ANY) self.assertEqual(node['power_state'], states.POWER_ON) self.assertIsNone(node['target_power_state']) self.assertIsNotNone(node['last_error'])
def test__sync_power_state_multiple_nodes(self): self.service.start() # create three nodes nodes = [] for i in range(0, 3): n = utils.get_test_node(id=i, uuid=ironic_utils.generate_uuid(), driver='fake', power_state=states.POWER_OFF) self.dbapi.create_node(n) nodes.append(n['uuid']) # lock the first node self.dbapi.reserve_nodes('fake-reserve', [nodes[0]]) with mock.patch.object(self.driver.power, 'get_power_state') as get_power_mock: get_power_mock.return_value = states.POWER_ON with mock.patch.object(self.dbapi, 'get_nodeinfo_list') as get_fnl_mock: # delete the second node self.dbapi.destroy_node(nodes[1]) get_fnl_mock.return_value = [[n] for n in nodes] self.service._sync_power_states(self.context) # check that get_power only called once, which updated third node get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) n1 = self.dbapi.get_node(nodes[0]) n3 = self.dbapi.get_node(nodes[2]) self.assertEqual(n1['power_state'], states.POWER_OFF) self.assertEqual(n3['power_state'], states.POWER_ON)
def test_validate_vendor_action_no_parameter(self): n = utils.get_test_node(driver='fake') self.dbapi.create_node(n) info = {'fake': 'baz'} self.assertRaises(exception.InvalidParameterValue, self.service.validate_vendor_action, self.context, n['uuid'], 'foo', info)
def setUp(self): super(RPCAPITestCase, self).setUp() self.dbapi = dbapi.get_instance() self.fake_node = dbutils.get_test_node(driver='fake-driver') self.fake_node_obj = objects.Node._from_db_object( objects.Node(self.context), self.fake_node)
def test_node_power_action_set_power_failure(self): """Test if an exception is thrown when the set_power call fails. """ ndict = utils.get_test_node(uuid=cmn_utils.generate_uuid(), driver='fake', power_state=states.POWER_OFF) node = self.dbapi.create_node(ndict) task = task_manager.TaskManager(self.context, node.uuid) with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: with mock.patch.object(self.driver.power, 'set_power_state') \ as set_power_mock: get_power_mock.return_value = states.POWER_OFF set_power_mock.side_effect = exception.IronicException() self.assertRaises( exception.IronicException, conductor_utils.node_power_action, task, task.node, states.POWER_ON) node.refresh(self.context) get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) set_power_mock.assert_called_once_with(mock.ANY, mock.ANY, states.POWER_ON) self.assertEqual(node['power_state'], states.POWER_OFF) self.assertIsNone(node['target_power_state']) self.assertIsNotNone(node['last_error'])
def test_change_node_power_state_power_on(self): # Test change_node_power_state including integration with # conductor.utils.node_power_action and lower. n = utils.get_test_node(driver='fake', power_state=states.POWER_OFF) db_node = self.dbapi.create_node(n) self.service.start() with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: get_power_mock.return_value = states.POWER_OFF self.service.change_node_power_state(self.context, db_node.uuid, states.POWER_ON) self.service._worker_pool.waitall() get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) db_node.refresh(self.context) self.assertEqual(states.POWER_ON, db_node.power_state) self.assertIsNone(db_node.target_power_state) self.assertIsNone(db_node.last_error) # Verify the reservation has been cleared by # background task's link callback. self.assertIsNone(db_node.reservation)
def test_node_power_action_in_same_state(self): """Test that we don't try to set the power state if the requested state is the same as the current state. """ ndict = utils.get_test_node(uuid=cmn_utils.generate_uuid(), driver='fake', last_error='anything but None', power_state=states.POWER_ON) node = self.dbapi.create_node(ndict) task = task_manager.TaskManager(self.context, node.uuid) with mock.patch.object(self.driver.power, 'get_power_state') \ as get_power_mock: get_power_mock.return_value = states.POWER_ON with mock.patch.object(self.driver.power, 'set_power_state') \ as set_power_mock: conductor_utils.node_power_action(task, task.node, states.POWER_ON) node.refresh(self.context) get_power_mock.assert_called_once_with(mock.ANY, mock.ANY) self.assertFalse(set_power_mock.called, "set_power_state unexpectedly called") self.assertEqual(node['power_state'], states.POWER_ON) self.assertIsNone(node['target_power_state']) self.assertIsNone(node['last_error'])
def _create_test_node(self, **kwargs): n = db_utils.get_test_node(**kwargs) return self.dbapi.create_node(n)
def setUp(self): super(SSHPrivateMethodsTestCase, self).setUp() self.node = db_utils.get_test_node( driver='fake_ssh', driver_info=db_utils.ssh_info) self.sshclient = paramiko.SSHClient()
def post_get_test_port(**kw): port = apiutils.port_post_data(**kw) node = dbutils.get_test_node() del port['node_id'] port['node_uuid'] = kw.get('node_uuid', node['uuid']) return port
def setUp(self): super(BareMetalIPMITestCase, self).setUp() self.node = db_utils.get_test_node() self.ipmi = ipmi.IPMIPowerDriver(self.node)
def setUp(self): super(IPMIToolPrivateMethodTestCase, self).setUp() self.node = db_utils.get_test_node(driver='fake_ipmitool', driver_info=INFO_DICT) self.info = ipmi._parse_driver_info(self.node)
def setUp(self): super(RPCAPITestCase, self).setUp() self.fake_node = dbutils.get_test_node(driver='fake-driver') self.fake_node_obj = objects.Node._from_db_object( objects.Node(self.context), self.fake_node)
def setUp(self): super(TestDelete, self).setUp() ndict = dbutils.get_test_node() self.node = self.dbapi.create_node(ndict) pdict = dbutils.get_test_port() self.dbapi.create_port(pdict)
def setUp(self): super(TestListPorts, self).setUp() ndict = dbutils.get_test_node() self.node = self.dbapi.create_node(ndict)
def setUp(self): super(TestPatch, self).setUp() ndict = dbutils.get_test_node() self.node = self.dbapi.create_node(ndict) self.pdict = dbutils.get_test_port(id=None) self.dbapi.create_port(self.pdict)
def test__parse_driver_info_too_many(self): info = db_utils.get_test_ssh_info('too_many') node = db_utils.get_test_node(driver='fake_ssh', driver_info=info) self.assertRaises(exception.InvalidParameterValue, ssh._parse_driver_info, node)
def test_get_nodeinfo_list_defaults(self): for i in range(1, 6): n = utils.get_test_node(id=i, uuid=ironic_utils.generate_uuid()) self.dbapi.create_node(n) res = [i[0] for i in self.dbapi.get_nodeinfo_list()] self.assertEqual(sorted(res), sorted(range(1, 6)))
def setUp(self): super(TestACL, self).setUp() self.environ = {'fake.cache': utils.FakeMemcache()} self.fake_db_node = db_utils.get_test_node(chassis_id=None) self.node_path = '/nodes/%s' % self.fake_db_node['uuid']
def test__parse_driver_info_bad_file(self): # A filename that doesn't exist errors. info = db_utils.get_test_ssh_info('file') node = db_utils.get_test_node(driver='fake_ssh', driver_info=info) self.assertRaises(exception.InvalidParameterValue, ssh._parse_driver_info, node)
def test_create_node_nullable_chassis_id(self): n = utils.get_test_node() del n['chassis_id'] self.dbapi.create_node(n)
def setUp(self): super(TestNodeObject, self).setUp() self.fake_node = utils.get_test_node() self.dbapi = db_api.get_instance()
def test_create_node(self): n = utils.get_test_node() self.dbapi.create_node(n)
def setUp(self): super(IPMIPrivateMethodTestCase, self).setUp() self.node = db_utils.get_test_node(driver='fake_ipmi', driver_info=db_utils.ipmi_info) self.info = ipmi._parse_driver_info(self.node)
def setUp(self): super(TestNodeObject, self).setUp() self.fake_node = utils.get_test_node()
def test_delete_ports_subresource(self): ndict = dbutils.get_test_node() self.dbapi.create_node(ndict) response = self.delete('/nodes/%s/ports' % ndict['uuid'], expect_errors=True) self.assertEqual(403, response.status_int)
def node_post_data(**kw): node = utils.get_test_node(**kw) node.pop('conductor_affinity') internal = node_controller.NodePatchType.internal_attrs() return remove_internal(node, internal)
def test_ports_subresource_link(self): ndict = dbutils.get_test_node() self.dbapi.create_node(ndict) data = self.get_json('/nodes/%s' % ndict['uuid']) self.assertIn('ports', data.keys())
def test_create_node_already_exists(self): n = utils.get_test_node() del n['id'] self.dbapi.create_node(n) self.assertRaises(exception.NodeAlreadyExists, self.dbapi.create_node, n)
def test_detail_against_single(self): ndict = dbutils.get_test_node() node = self.dbapi.create_node(ndict) response = self.get_json('/nodes/%s/detail' % node['uuid'], expect_errors=True) self.assertEqual(404, response.status_int)
def test_delete_node(self, mock_dn): ndict = dbutils.get_test_node() self.dbapi.create_node(ndict) self.delete('/nodes/%s' % ndict['uuid']) mock_dn.assert_called_once_with(mock.ANY, ndict['uuid'], 'test-topic')
def setUp(self): super(FakeDriverTestCase, self).setUp() self.driver = fake.FakeDriver() self.node = db_utils.get_test_node()
def create_fake_node(i): dbh = dbapi.get_instance() node = utils.get_test_node(id=i, uuid=ironic_utils.generate_uuid()) dbh.create_node(node) return node['uuid']