Merge "Fix the cell API with string rpc_port failed"
This commit is contained in:
@@ -323,7 +323,12 @@ class Controller(object):
|
||||
if not transport_url.hosts:
|
||||
transport_url.hosts.append(messaging.TransportHost())
|
||||
transport_host = transport_url.hosts[0]
|
||||
|
||||
if cell.get('rpc_port') is not None:
|
||||
try:
|
||||
cell['rpc_port'] = int(cell['rpc_port'])
|
||||
except ValueError:
|
||||
raise exc.HTTPBadRequest(
|
||||
explanation=_('rpc_port must be integer'))
|
||||
# Copy over the input fields
|
||||
transport_field_map = {
|
||||
'username': 'username',
|
||||
|
||||
@@ -216,7 +216,8 @@ class CellsController(object):
|
||||
if not transport_url.hosts:
|
||||
transport_url.hosts.append(messaging.TransportHost())
|
||||
transport_host = transport_url.hosts[0]
|
||||
|
||||
if 'rpc_port' in cell:
|
||||
cell['rpc_port'] = int(cell['rpc_port'])
|
||||
# Copy over the input fields
|
||||
transport_field_map = {
|
||||
'username': 'username',
|
||||
|
||||
@@ -313,6 +313,31 @@ class CellsTestV21(BaseCellsTest):
|
||||
self.assertRaises(exception.PolicyNotAuthorized,
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def test_cell_create_rpc_port_with_string(self):
|
||||
body = {'cell': {'name': 'fake',
|
||||
'username': 'fred',
|
||||
'password': 'secret',
|
||||
'rpc_host': 'r3.example.org',
|
||||
'rpc_port': '123',
|
||||
'type': 'parent'}}
|
||||
|
||||
req = self._get_request("cells")
|
||||
req.environ['nova.context'] = self.context
|
||||
self.controller.create(req, body=body)
|
||||
|
||||
def test_cell_create_rpc_port_with_null(self):
|
||||
body = {'cell': {'name': 'fake',
|
||||
'username': 'fred',
|
||||
'password': 'secret',
|
||||
'rpc_host': 'r3.example.org',
|
||||
'rpc_port': None,
|
||||
'type': 'parent'}}
|
||||
|
||||
req = self._get_request("cells")
|
||||
req.environ['nova.context'] = self.context
|
||||
self.assertRaises(self.bad_request,
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def _cell_update(self):
|
||||
body = {'cell': {'username': 'zeb',
|
||||
'password': 'sneaky'}}
|
||||
@@ -402,6 +427,31 @@ class CellsTestV21(BaseCellsTest):
|
||||
self.assertEqual(cell2['username'], 'wingwj')
|
||||
self.assertEqual(cell2['type'], 'parent')
|
||||
|
||||
def test_cell_update_rpc_port_with_string(self):
|
||||
body = {'cell': {'name': 'fake',
|
||||
'username': 'fred',
|
||||
'password': 'secret',
|
||||
'rpc_host': 'r3.example.org',
|
||||
'rpc_port': '123',
|
||||
'type': 'parent'}}
|
||||
|
||||
req = self._get_request("cells")
|
||||
req.environ['nova.context'] = self.context
|
||||
self.controller.update(req, 'cell1', body=body)
|
||||
|
||||
def test_cell_update_rpc_port_with_null(self):
|
||||
body = {'cell': {'name': 'fake',
|
||||
'username': 'fred',
|
||||
'password': 'secret',
|
||||
'rpc_host': 'r3.example.org',
|
||||
'rpc_port': None,
|
||||
'type': 'parent'}}
|
||||
|
||||
req = self._get_request("cells")
|
||||
req.environ['nova.context'] = self.context
|
||||
self.assertRaises(self.bad_request,
|
||||
self.controller.update, req, 'cell1', body=body)
|
||||
|
||||
def test_cell_info(self):
|
||||
caps = ['cap1=a;b', 'cap2=c;d']
|
||||
self.flags(name='darksecret', capabilities=caps, group='cells')
|
||||
@@ -612,6 +662,30 @@ class CellsTestV2(CellsTestV21):
|
||||
self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def test_cell_create_rpc_port_with_null(self):
|
||||
body = {'cell': {'name': 'fake',
|
||||
'username': 'fred',
|
||||
'password': 'secret',
|
||||
'rpc_host': 'r3.example.org',
|
||||
'rpc_port': None,
|
||||
'type': 'parent'}}
|
||||
|
||||
req = self._get_request("cells")
|
||||
req.environ['nova.context'] = self.context
|
||||
self.controller.create(req, body=body)
|
||||
|
||||
def test_cell_update_rpc_port_with_null(self):
|
||||
body = {'cell': {'name': 'fake',
|
||||
'username': 'fred',
|
||||
'password': 'secret',
|
||||
'rpc_host': 'r3.example.org',
|
||||
'rpc_port': None,
|
||||
'type': 'parent'}}
|
||||
|
||||
req = self._get_request("cells")
|
||||
req.environ['nova.context'] = self.context
|
||||
self.controller.update(req, 'cell1', body=body)
|
||||
|
||||
|
||||
class TestCellsXMLSerializer(BaseCellsTest):
|
||||
def test_multiple_cells(self):
|
||||
|
||||
Reference in New Issue
Block a user