]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix DVR regression for ofagent
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>
Fri, 11 Jul 2014 00:15:58 +0000 (09:15 +0900)
committerYAMAMOTO Takashi <yamamoto@valinux.co.jp>
Fri, 18 Jul 2014 05:51:20 +0000 (14:51 +0900)
Background:
    ML2 plugin sometimes uses truncated port uuids.
    For example, in the case of ofagent and linuxbridge,
    if port id is 804ceaa1-0e3e-11e4-b537-08606e7f74e7,
    an agent would send "tap804ceaa1-0e" to the plugin.
    ML2 plugin's _device_to_port_id() would restore it to
    "804ceaa1-0e".  While it's still truncated, ML2 plugin's
    get_port() handles that by using "startswith".

The recently merged DVR change (https://review.openstack.org/#/c/102332/)
assumes that port_id is always a complete uuid (it's the case
for openvswitch) and fails to handle the above mentioned case.
This commit fixes the regression.

Change-Id: I9c0845be606969068ab5d13c0165e76760378500
Closes-Bug: #1343750

neutron/plugins/ml2/plugin.py
neutron/plugins/ml2/rpc.py

index 294deb668a73121ec3285c6609391638aec39239..34e5add14c7263887402616149ddeb9622399191 100644 (file)
@@ -939,6 +939,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
         return self._bind_port_if_needed(port_context)
 
     def update_port_status(self, context, port_id, status, host=None):
+        """
+        Returns port_id (non-truncated uuid) if the port exists.
+        Otherwise returns None.
+        """
         updated = False
         session = context.session
         # REVISIT: Serialize this operation with a semaphore to
@@ -951,7 +955,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
             if not port:
                 LOG.warning(_("Port %(port)s updated up by agent not found"),
                             {'port': port_id})
-                return False
+                return None
             if port.status != status:
                 original_port = self._make_port_dict(port)
                 port.status = status
@@ -967,7 +971,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
         if updated:
             self.mechanism_manager.update_port_postcommit(mech_context)
 
-        return True
+        return port['id']
 
     def port_bound_to_host(self, context, port_id, host):
         port_host = db.get_port_binding_host(port_id)
index 553ba1f1f2bcddb4968320b7e940738491808a4f..0ee8c009991bdc2d481fc538ac20fd53898e3e74 100644 (file)
@@ -159,9 +159,9 @@ class RpcCallbacks(n_rpc.RpcCallback,
             return {'device': device,
                     'exists': port_exists}
 
-        port_exists = plugin.update_port_status(rpc_context, port_id,
-                                                q_const.PORT_STATUS_DOWN,
-                                                host)
+        port_exists = bool(plugin.update_port_status(rpc_context, port_id,
+                                                     q_const.PORT_STATUS_DOWN,
+                                                     host))
 
         return {'device': device,
                 'exists': port_exists}
@@ -182,9 +182,9 @@ class RpcCallbacks(n_rpc.RpcCallback,
                       {'device': device, 'host': host})
             return
 
-        plugin.update_port_status(rpc_context, port_id,
-                                  q_const.PORT_STATUS_ACTIVE,
-                                  host)
+        port_id = plugin.update_port_status(rpc_context, port_id,
+                                            q_const.PORT_STATUS_ACTIVE,
+                                            host)
         l3plugin = manager.NeutronManager.get_service_plugins().get(
             service_constants.L3_ROUTER_NAT)
         if l3plugin: