Add port to database with supported device_owner

The arista_provisioned_vms table should contain only ports which are
provisioned by the arista mechanism driver. This patch verifies the
device owner of a port before adding it to the table.

Change-Id: I0ce405f305157a0dbb4873cccbf4031256630683
changes/18/468218/2
Nader Lahouti 6 years ago
parent eebed64795
commit 38484379fb

@ -402,6 +402,18 @@ class AristaDriver(driver_api.MechanismDriver):
return
def _supported_device_owner(self, device_owner):
supported_device_owner = [n_const.DEVICE_OWNER_DHCP,
n_const.DEVICE_OWNER_DVR_INTERFACE]
if any([device_owner in supported_device_owner,
device_owner.startswith('compute') and
device_owner != 'compute:probe',
device_owner.startswith('baremetal')]):
return True
LOG.info(_LI('Unsupported device owner: %s'), device_owner)
def _network_owner_tenant(self, context, network_id, tenant_id):
tid = tenant_id
if network_id and tenant_id:
@ -554,7 +566,7 @@ class AristaDriver(driver_api.MechanismDriver):
pretty_log("update_port_precommit: new", new_port)
pretty_log("update_port_precommit: orig", orig_port)
if new_port['device_owner'] == 'compute:probe':
if not self._supported_device_owner(new_port['device_owner']):
return
# Check if it is port migration case
@ -653,6 +665,9 @@ class AristaDriver(driver_api.MechanismDriver):
host = context.host
is_vm_boot = device_id and device_owner
if not self._supported_device_owner(device_owner):
return
vnic_type = port['binding:vnic_type']
binding_profile = port['binding:profile']
bindings = []
@ -814,6 +829,10 @@ class AristaDriver(driver_api.MechanismDriver):
port_id = port['id']
network_id = port['network_id']
device_owner = port['device_owner']
if not self._supported_device_owner(device_owner):
return
vnic_type = port['binding:vnic_type']
binding_profile = port['binding:profile']
switch_bindings = []

Loading…
Cancel
Save