Fix DVR regression for ofagent
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
This commit is contained in:
parent
68713c94ee
commit
8e31122d36
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user