[AIM] Implement the allowed_vm_names feature
basically port the following patch over from apic_mapping driver:
https://review.openstack.org/#/c/385218/
Change-Id: I79ebd4f283dba573090331926e268310f4cd4bce
(cherry picked from commit 852d379b23)
This commit is contained in:
@@ -144,6 +144,8 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
|
||||
self.aim = aim_manager.AimManager()
|
||||
self._core_plugin = None
|
||||
self._l3_plugin = None
|
||||
self._gbp_plugin = None
|
||||
self._aim_mapping = None
|
||||
# Get APIC configuration and subscribe for changes
|
||||
self.enable_metadata_opt = (
|
||||
cfg.CONF.ml2_apic_aim.enable_optimized_metadata)
|
||||
@@ -1110,21 +1112,25 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
|
||||
self._notify_port_update_bulk(context, ports_to_notify)
|
||||
|
||||
def bind_port(self, context):
|
||||
current = context.current
|
||||
port = context.current
|
||||
LOG.debug("Attempting to bind port %(port)s on network %(net)s",
|
||||
{'port': current['id'],
|
||||
{'port': port['id'],
|
||||
'net': context.network.current['id']})
|
||||
|
||||
# Check the VNIC type.
|
||||
vnic_type = current.get(portbindings.VNIC_TYPE,
|
||||
portbindings.VNIC_NORMAL)
|
||||
vnic_type = port.get(portbindings.VNIC_TYPE,
|
||||
portbindings.VNIC_NORMAL)
|
||||
if vnic_type not in [portbindings.VNIC_NORMAL]:
|
||||
LOG.debug("Refusing to bind due to unsupported vnic_type: %s",
|
||||
vnic_type)
|
||||
return
|
||||
|
||||
# For compute ports, try to bind DVS agent first.
|
||||
if current['device_owner'].startswith('compute:'):
|
||||
if port['device_owner'].startswith('compute:'):
|
||||
if (self.aim_mapping and not
|
||||
self.aim_mapping.check_allow_vm_names(context, port)):
|
||||
return
|
||||
|
||||
# For compute ports, try to bind DVS agent first.
|
||||
if self._agent_bind_port(context, AGENT_TYPE_DVS,
|
||||
self._dvs_bind_port):
|
||||
return
|
||||
@@ -1320,6 +1326,20 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
|
||||
self._l3_plugin = plugins[pconst.L3_ROUTER_NAT]
|
||||
return self._l3_plugin
|
||||
|
||||
@property
|
||||
def gbp_plugin(self):
|
||||
if not self._gbp_plugin:
|
||||
self._gbp_plugin = (manager.NeutronManager.get_service_plugins()
|
||||
.get("GROUP_POLICY"))
|
||||
return self._gbp_plugin
|
||||
|
||||
@property
|
||||
def aim_mapping(self):
|
||||
if not self._aim_mapping and self.gbp_plugin:
|
||||
self._aim_mapping = (self.gbp_plugin.policy_driver_manager.
|
||||
policy_drivers['aim_mapping'].obj)
|
||||
return self._aim_mapping
|
||||
|
||||
def _merge_status(self, aim_ctx, sync_state, resource):
|
||||
status = self.aim.get_status(aim_ctx, resource)
|
||||
if not status:
|
||||
|
||||
Reference in New Issue
Block a user