Fix port creation on shared networks

In create_port_precommit, the VM was only added to the Arista DB if
the port was associated to a network in the same tenant. But in the
case of a shared network, the port tenant and the network tenant can
be different, while the VM should still be added to the DB.

The same goes for removing resources in delete_port_postcommit.

This commit ensures the VM is added to the DB when connected to a
shared network, and that everything is cleaned-up when disconnected.

Change-Id: I295e6c87b460be4adb44e2275fa3008d3ce3eda7
changes/00/218800/2
Benoît Knecht 8 years ago
parent 926ede02ab
commit 1aa15e8b72

@ -211,7 +211,13 @@ class AristaDriver(driver_api.MechanismDriver):
if not tenant_id:
tenant_id = context._plugin_context.tenant_id
with self.eos_sync_lock:
if not db_lib.is_network_provisioned(tenant_id, network_id):
# If network does not exist under this tenant,
# it may be a shared network. Get shared network owner Id
net_provisioned = (
db_lib.is_network_provisioned(tenant_id, network_id) or
self.ndb.get_shared_network_owner_id(network_id)
)
if not net_provisioned:
# Ignore this request if network is not provisioned
return
db_lib.remember_tenant(tenant_id)
@ -402,7 +408,13 @@ class AristaDriver(driver_api.MechanismDriver):
device_owner = port['device_owner']
try:
if not db_lib.is_network_provisioned(tenant_id, network_id):
# If network does not exist under this tenant,
# it may be a shared network. Get shared network owner Id
net_provisioned = (
db_lib.is_network_provisioned(tenant_id, network_id) or
self.ndb.get_shared_network_owner_id(network_id)
)
if not net_provisioned:
# If we do not have network associated with this, ignore it
return
hostname = self._host_name(host)

Loading…
Cancel
Save