def test_activate_node(self): self._create_node() self.instance['uuid'] = 'fake-uuid' self.flags(pxe_deploy_timeout=1, group='baremetal') db.bm_node_update(self.context, 1, { 'task_state': baremetal_states.DEPLOYING, 'instance_uuid': 'fake-uuid' }) # test timeout self.assertRaises(exception.InstanceDeployFailure, self.driver.activate_node, self.context, self.node, self.instance) # test DEPLOYDONE db.bm_node_update(self.context, 1, {'task_state': baremetal_states.DEPLOYDONE}) self.driver.activate_node(self.context, self.node, self.instance) # test no deploy -- state is just ACTIVE db.bm_node_update(self.context, 1, {'task_state': baremetal_states.ACTIVE}) self.driver.activate_node(self.context, self.node, self.instance) # test node gone db.bm_node_destroy(self.context, 1) self.assertRaises(exception.InstanceDeployFailure, self.driver.activate_node, self.context, self.node, self.instance)
def test_activate_node(self): self._create_node() self.instance['uuid'] = 'fake-uuid' self.flags(pxe_deploy_timeout=1, group='baremetal') db.bm_node_update(self.context, 1, {'task_state': baremetal_states.DEPLOYING, 'instance_uuid': 'fake-uuid'}) # test timeout self.assertRaises(exception.InstanceDeployFailure, self.driver.activate_node, self.context, self.node, self.instance) # test DEPLOYDONE db.bm_node_update(self.context, 1, {'task_state': baremetal_states.DEPLOYDONE}) self.driver.activate_node(self.context, self.node, self.instance) # test no deploy -- state is just ACTIVE db.bm_node_update(self.context, 1, {'task_state': baremetal_states.ACTIVE}) self.driver.activate_node(self.context, self.node, self.instance) # test node gone db.bm_node_destroy(self.context, 1) self.assertRaises(exception.InstanceDeployFailure, self.driver.activate_node, self.context, self.node, self.instance)
def test_destroy_with_interfaces(self): self._create_nodes() if_a_id = db.bm_interface_create(self.context, self.ids[0], 'aa:aa:aa:aa:aa:aa', None, None) if_b_id = db.bm_interface_create(self.context, self.ids[0], 'bb:bb:bb:bb:bb:bb', None, None) if_x_id = db.bm_interface_create(self.context, self.ids[1], '11:22:33:44:55:66', None, None) db.bm_node_destroy(self.context, self.ids[0]) self.assertRaises( exception.NovaException, db.bm_interface_get, self.context, if_a_id) self.assertRaises( exception.NovaException, db.bm_interface_get, self.context, if_b_id) # Another node's interface is not affected if_x = db.bm_interface_get(self.context, if_x_id) self.assertEqual(self.ids[1], if_x['bm_node_id']) self.assertRaises( exception.NodeNotFound, db.bm_node_get, self.context, self.ids[0]) r = db.bm_node_get_all(self.context) self.assertEquals(len(r), 5)
def test_destroy_with_interfaces(self): self._create_nodes() if_a_id = db.bm_interface_create(self.context, self.ids[0], 'aa:aa:aa:aa:aa:aa', None, None) if_b_id = db.bm_interface_create(self.context, self.ids[0], 'bb:bb:bb:bb:bb:bb', None, None) if_x_id = db.bm_interface_create(self.context, self.ids[1], '11:22:33:44:55:66', None, None) db.bm_node_destroy(self.context, self.ids[0]) self.assertRaises(exception.NovaException, db.bm_interface_get, self.context, if_a_id) self.assertRaises(exception.NovaException, db.bm_interface_get, self.context, if_b_id) # Another node's interface is not affected if_x = db.bm_interface_get(self.context, if_x_id) self.assertEqual(self.ids[1], if_x['bm_node_id']) self.assertRaises(exception.NodeNotFound, db.bm_node_get, self.context, self.ids[0]) r = db.bm_node_get_all(self.context) self.assertEquals(len(r), 5)
def test_delete_node_not_found(self): self.mox.StubOutWithMock(db, 'bm_node_destroy') db.bm_node_destroy(self.context, 1).\ AndRaise(exception.NodeNotFound(node_id=1)) self.mox.ReplayAll() self.assertRaises(exc.HTTPNotFound, self.controller.delete, self.request, 1)
def delete(self, req, id): context = req.environ['nova.context'] authorize(context) try: db.bm_node_destroy(context, id) except exception.NodeNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) return webob.Response(status_int=202)
def delete(self, req, id): context = req.environ['nova.context'] authorize(context) try: db.bm_node_destroy(context, id) except exception.InstanceNotFound: raise webob.exc.HTTPNotFound return webob.Response(status_int=202)
def delete(self, req, id): context = req.environ['nova.context'] authorize(context) try: db.bm_node_destroy(context, id) except exception.NodeNotFound: raise webob.exc.HTTPNotFound return webob.Response(status_int=202)
def test_delete_node_not_found(self): self.mox.StubOutWithMock(db, 'bm_node_destroy') db.bm_node_destroy(self.context, 1).\ AndRaise(exception.NodeNotFound(node_id=1)) self.mox.ReplayAll() self.assertRaises( exc.HTTPNotFound, self.controller.delete, self.request, 1)
def test_destroy(self): self._create_nodes() db.bm_node_destroy(self.context, self.ids[0]) r = db.bm_node_get(self.context, self.ids[0]) self.assertTrue(r is None) r = db.bm_node_get_all(self.context) self.assertEquals(len(r), 5)
def test_destroy(self): self._create_nodes() db.bm_node_destroy(self.context, self.ids[0]) self.assertRaises(exception.InstanceNotFound, db.bm_node_get, self.context, self.ids[0]) r = db.bm_node_get_all(self.context) self.assertEquals(len(r), 5)
def delete(self, req, id): if _use_ironic(): _no_ironic_proxy("node-delete") context = req.environ['nova.context'] authorize(context) try: db.bm_node_destroy(context, id) except exception.NodeNotFound: raise webob.exc.HTTPNotFound() return webob.Response(status_int=202)
def test_destroy(self): self._create_nodes() db.bm_node_destroy(self.context, self.ids[0]) self.assertRaises( exception.NodeNotFound, db.bm_node_get, self.context, self.ids[0]) r = db.bm_node_get_all(self.context) self.assertEquals(len(r), 5)
def test_activate_node(self): self._create_node() self.instance["uuid"] = "fake-uuid" db.bm_node_update(self.context, 1, {"task_state": baremetal_states.DEPLOYING, "instance_uuid": "fake-uuid"}) # test DEPLOYDONE db.bm_node_update(self.context, 1, {"task_state": baremetal_states.DEPLOYDONE}) self.driver.activate_node(self.context, self.node, self.instance) # test no deploy -- state is just ACTIVE db.bm_node_update(self.context, 1, {"task_state": baremetal_states.ACTIVE}) self.driver.activate_node(self.context, self.node, self.instance) # test node gone db.bm_node_destroy(self.context, 1) self.assertRaises( exception.InstanceDeployFailure, self.driver.activate_node, self.context, self.node, self.instance )
def test_delete(self): self.mox.StubOutWithMock(db, 'bm_node_destroy') db.bm_node_destroy(self.context, 1) self.mox.ReplayAll() self.controller.delete(self.request, 1)