Merge "Remove the support to create port in API"

This commit is contained in:
Zuul 2020-11-02 07:08:23 +00:00 committed by Gerrit Code Review
commit 160b75e22c
2 changed files with 3 additions and 52 deletions

View File

@ -632,17 +632,6 @@ class PortsController(rest.RestController):
raise exception.Invalid('A non-empty value is required when '
'setting physical_network')
create_remotely = api.request.rpcapi.can_send_create_port()
if (not create_remotely and pdict.get('portgroup_uuid')):
# NOTE(mgoddard): In RPC API v1.41, port creation was moved to the
# conductor service to facilitate validation of the physical
# network field of ports in portgroups. During a rolling upgrade,
# the RPCAPI will reject the create_port method, so we need to
# create the port locally. If the port is a member of a portgroup,
# we are unable to perform the validation and must reject the
# request.
raise exception.NotAcceptable()
vif = api_utils.handle_post_port_like_extra_vif(pdict)
if (pdict.get('portgroup_uuid')
@ -670,18 +659,9 @@ class PortsController(rest.RestController):
**notify_extra)
with notify.handle_error_notification(context, rpc_port, 'create',
**notify_extra):
# NOTE(mgoddard): In RPC API v1.41, port creation was moved to the
# conductor service to facilitate validation of the physical
# network field of ports in portgroups. During a rolling upgrade,
# the RPCAPI will reject the create_port method, so we need to
# create the port locally.
if create_remotely:
topic = api.request.rpcapi.get_topic_for(rpc_node)
new_port = api.request.rpcapi.create_port(context, rpc_port,
topic)
else:
rpc_port.create()
new_port = rpc_port
topic = api.request.rpcapi.get_topic_for(rpc_node)
new_port = api.request.rpcapi.create_port(context, rpc_port,
topic)
notify.emit_end_notification(context, new_port, 'create',
**notify_extra)
# Set the HTTP Location Header

View File

@ -2208,20 +2208,6 @@ class TestPost(test_api_base.BaseApiTest):
self.assertTrue(response.json['error_message'])
self.assertFalse(mock_create.called)
@mock.patch.object(rpcapi.ConductorAPI, 'can_send_create_port',
autospec=True)
def test_create_port_cannot_send_create_port(self, mock_cscp, mock_create):
mock_cscp.return_value = False
pdict = post_get_test_port(
node_uuid=self.node.uuid,
portgroup_uuid=None)
response = self.post_json('/ports', pdict, headers=self.headers)
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.CREATED, response.status_int)
self.assertFalse(mock_create.called)
mock_cscp.assert_called_once_with(mock.ANY)
objects.Port.get(self.context, pdict['uuid'])
def test_create_port_portgroup(self, mock_create):
pdict = post_get_test_port(
portgroup_uuid=self.portgroup.uuid,
@ -2256,21 +2242,6 @@ class TestPost(test_api_base.BaseApiTest):
self.assertEqual(http_client.NOT_ACCEPTABLE, response.status_int)
self.assertFalse(mock_create.called)
@mock.patch.object(rpcapi.ConductorAPI, 'can_send_create_port',
autospec=True)
def test_create_port_portgroup_cannot_send_create_port(self, mock_cscp,
mock_create):
mock_cscp.return_value = False
pdict = post_get_test_port(
node_uuid=self.node.uuid,
portgroup_uuid=self.portgroup.uuid)
response = self.post_json('/ports', pdict, expect_errors=True,
headers=self.headers)
self.assertEqual('application/json', response.content_type)
self.assertEqual(http_client.NOT_ACCEPTABLE, response.status_int)
self.assertFalse(mock_create.called)
mock_cscp.assert_called_once_with(mock.ANY)
@mock.patch.object(notification_utils, '_emit_api_notification')
def test_create_port_address_already_exist(self, mock_notify, mock_create):
address = 'AA:AA:AA:11:22:33'