Do not return 'id' in REST API error messages
REST API should return 'uuid' instead of 'id' in error messages. Closes-Bug: #1372499 Change-Id: I0b5c8fce3e50da2a9fa42f6407409dcf6332fa45
This commit is contained in:
parent
85c36c561f
commit
93ffb9e08e
@ -137,7 +137,7 @@ def _check_port_change_forbidden(port, session):
|
|||||||
query = query.filter_by(id=node_id)
|
query = query.filter_by(id=node_id)
|
||||||
node_ref = query.one()
|
node_ref = query.one()
|
||||||
if node_ref['reservation'] is not None:
|
if node_ref['reservation'] is not None:
|
||||||
raise exception.NodeLocked(node=node_id,
|
raise exception.NodeLocked(node=node_ref['uuid'],
|
||||||
host=node_ref['reservation'])
|
host=node_ref['reservation'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class Chassis(base.IronicObject):
|
|||||||
A context should be set when instantiating the
|
A context should be set when instantiating the
|
||||||
object, e.g.: Chassis(context)
|
object, e.g.: Chassis(context)
|
||||||
"""
|
"""
|
||||||
self.dbapi.destroy_chassis(self.id)
|
self.dbapi.destroy_chassis(self.uuid)
|
||||||
self.obj_reset_changes()
|
self.obj_reset_changes()
|
||||||
|
|
||||||
@base.remotable
|
@base.remotable
|
||||||
|
@ -205,7 +205,7 @@ class Node(base.IronicObject):
|
|||||||
A context should be set when instantiating the
|
A context should be set when instantiating the
|
||||||
object, e.g.: Node(context)
|
object, e.g.: Node(context)
|
||||||
"""
|
"""
|
||||||
self.dbapi.destroy_node(self.id)
|
self.dbapi.destroy_node(self.uuid)
|
||||||
self.obj_reset_changes()
|
self.obj_reset_changes()
|
||||||
|
|
||||||
@base.remotable
|
@base.remotable
|
||||||
|
@ -170,7 +170,7 @@ class Port(base.IronicObject):
|
|||||||
A context should be set when instantiating the
|
A context should be set when instantiating the
|
||||||
object, e.g.: Port(context)
|
object, e.g.: Port(context)
|
||||||
"""
|
"""
|
||||||
self.dbapi.destroy_port(self.id)
|
self.dbapi.destroy_port(self.uuid)
|
||||||
self.obj_reset_changes()
|
self.obj_reset_changes()
|
||||||
|
|
||||||
@base.remotable
|
@base.remotable
|
||||||
|
@ -377,6 +377,7 @@ class TestDelete(base.FunctionalTest):
|
|||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
|
self.assertIn(chassis.uuid, response.json['error_message'])
|
||||||
|
|
||||||
def test_delete_chassis_not_found(self):
|
def test_delete_chassis_not_found(self):
|
||||||
uuid = utils.generate_uuid()
|
uuid = utils.generate_uuid()
|
||||||
|
@ -604,22 +604,28 @@ class TestDelete(base.FunctionalTest):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDelete, self).setUp()
|
super(TestDelete, self).setUp()
|
||||||
self.node = obj_utils.create_test_node(context.get_admin_context())
|
self.node = obj_utils.create_test_node(self.context)
|
||||||
obj_utils.create_test_port(self.context)
|
self.port = obj_utils.create_test_port(self.context)
|
||||||
|
|
||||||
def test_delete_port_byid(self):
|
def test_delete_port_byid(self):
|
||||||
pdict = dbutils.get_test_port()
|
self.delete('/ports/%s' % self.port.uuid)
|
||||||
self.delete('/ports/%s' % pdict['uuid'])
|
response = self.get_json('/ports/%s' % self.port.uuid,
|
||||||
response = self.get_json('/ports/%s' % pdict['uuid'],
|
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertIn(self.port.uuid, response.json['error_message'])
|
||||||
|
|
||||||
def test_delete_port_byaddress(self):
|
def test_delete_port_byaddress(self):
|
||||||
pdict = dbutils.get_test_port()
|
response = self.delete('/ports/%s' % self.port.address,
|
||||||
response = self.delete('/ports/%s' % pdict['address'],
|
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertIn(pdict['address'], response.json['error_message'])
|
self.assertIn(self.port.address, response.json['error_message'])
|
||||||
|
|
||||||
|
def test_delete_port_node_locked(self):
|
||||||
|
self.node.reserve(self.context, 'fake', self.node.uuid)
|
||||||
|
response = self.delete('/ports/%s' % self.port.uuid,
|
||||||
|
expect_errors=True)
|
||||||
|
self.assertEqual(409, response.status_int)
|
||||||
|
self.assertEqual('application/json', response.content_type)
|
||||||
|
self.assertIn(self.node.uuid, response.json['error_message'])
|
||||||
|
Loading…
Reference in New Issue
Block a user