From: Kevin Benton Date: Fri, 23 Aug 2013 12:51:54 +0000 (-0700) Subject: BigSwitch plugin - add portbinding info in requests to controller X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=69dd72931fd09f346f4a3e455bf9ec28f5639369;p=openstack-build%2Fneutron-build.git BigSwitch plugin - add portbinding info in requests to controller Include portbinding info in requests to controller so it receives information about the compute node like the VIF type and the host ID. Also includes better debug output on back-end failures. Fixes: bug #1216061 Change-Id: Ib85c8a088ee9fb94baaf8f28849b318b32d9d672 --- diff --git a/neutron/plugins/bigswitch/plugin.py b/neutron/plugins/bigswitch/plugin.py index 641dfa910..98d21157e 100644 --- a/neutron/plugins/bigswitch/plugin.py +++ b/neutron/plugins/bigswitch/plugin.py @@ -295,10 +295,11 @@ class ServerPool(object): return ret else: LOG.error(_('ServerProxy: %(action)s failure for servers: ' - '%(server)r'), + '%(server)r Response: %(response)s'), {'action': action, 'server': (active_server.server, - active_server.port)}) + active_server.port), + 'response': ret[3]}) active_server.failed = True # All servers failed, reset server list and try again next time @@ -565,6 +566,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2, and 'id' in new_port): porttracker_db.put_port_hostid(context, new_port['id'], port['port'][portbindings.HOST_ID]) + new_port = self._extend_port_dict_binding(context, new_port) net = super(NeutronRestProxyV2, self).get_network(context, new_port["network_id"]) @@ -660,6 +662,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2, and 'id' in new_port): porttracker_db.put_port_hostid(context, new_port['id'], port['port'][portbindings.HOST_ID]) + new_port = self._extend_port_dict_binding(context, new_port) # update on networl ctrl try: resource = PORTS_PATH % (orig_port["tenant_id"], @@ -690,7 +693,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2, raise # return new_port - return self._extend_port_dict_binding(context, new_port) + return new_port def delete_port(self, context, port_id, l3_port_check=True): """Delete a port. diff --git a/neutron/tests/unit/bigswitch/test_router_db.py b/neutron/tests/unit/bigswitch/test_router_db.py index 72712fa7c..c17681fb9 100644 --- a/neutron/tests/unit/bigswitch/test_router_db.py +++ b/neutron/tests/unit/bigswitch/test_router_db.py @@ -65,16 +65,34 @@ class HTTPResponseMock(): return "{'status': '200 OK'}" +class HTTPResponseMock500(): + status = 500 + reason = 'Internal Server Error' + + def __init__(self, sock, debuglevel=0, strict=0, method=None, + buffering=False, errmsg='500 Internal Server Error'): + self.errmsg = errmsg + + def read(self): + return "{'status': '%s'}" % self.errmsg + + class HTTPConnectionMock(): def __init__(self, server, port, timeout): - pass + self.response = None def request(self, action, uri, body, headers): + self.response = HTTPResponseMock(None) + # Port creations/updates must contain binding information + if ('port' in uri and 'attachment' not in uri + and 'binding' not in body and action in ('POST', 'PUT')): + errmsg = "Port binding info missing in port request '%s'" % body + self.response = HTTPResponseMock500(None, errmsg=errmsg) return def getresponse(self): - return HTTPResponseMock(None) + return self.response def close(self): pass