]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
BigSwitch plugin - add portbinding info in requests to controller
authorKevin Benton <kevin.benton@bigswitch.com>
Fri, 23 Aug 2013 12:51:54 +0000 (05:51 -0700)
committerKevin Benton <kevin.benton@bigswitch.com>
Fri, 23 Aug 2013 21:50:15 +0000 (14:50 -0700)
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

neutron/plugins/bigswitch/plugin.py
neutron/tests/unit/bigswitch/test_router_db.py

index 641dfa91050a72b7dd1feb45bc8a677791fcbfeb..98d21157e7536c45925370d70581ab0c7097dbca 100644 (file)
@@ -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.
index 72712fa7cd3802c1f58623527a6c5f2e12f47cd9..c17681fb9836f5314ea1fd3a4cd31725cec5e08a 100644 (file)
@@ -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