Merge "Adapt check for restricted VLAN"
This commit is contained in:
commit
90b6791cb9
@ -2908,23 +2908,32 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
if not self.nsxlib:
|
if not self.nsxlib:
|
||||||
return []
|
return []
|
||||||
restricted_vlans = []
|
restricted_vlans = []
|
||||||
|
known_profiles = []
|
||||||
# Get all transport nodes of this transport zone
|
# Get all transport nodes of this transport zone
|
||||||
tns = self.nsxlib.transport_node.list()['results']
|
tns = self.nsxlib.transport_node.list()['results']
|
||||||
for tn in tns:
|
for tn in tns:
|
||||||
# Check if it belongs to the current TZ
|
# Find desired transport zone in host switches
|
||||||
tzs = [ep.get('transport_zone_id') for ep in
|
|
||||||
tn.get('transport_zone_endpoints', [])]
|
|
||||||
if tz_uuid not in tzs:
|
|
||||||
continue
|
|
||||||
if ('host_switch_spec' in tn and
|
if ('host_switch_spec' in tn and
|
||||||
'host_switches' in tn['host_switch_spec']):
|
'host_switches' in tn['host_switch_spec']):
|
||||||
for hs in tn['host_switch_spec']['host_switches']:
|
for hs in tn['host_switch_spec']['host_switches']:
|
||||||
|
# Check if it belongs to the current TZ
|
||||||
|
tzs = [ep.get('transport_zone_id') for ep in
|
||||||
|
hs.get('transport_zone_endpoints', [])]
|
||||||
|
if tz_uuid not in tzs:
|
||||||
|
# Move to next host switch for transport node
|
||||||
|
continue
|
||||||
profile_attrs = hs.get('host_switch_profile_ids', [])
|
profile_attrs = hs.get('host_switch_profile_ids', [])
|
||||||
for profile_attr in profile_attrs:
|
for profile_attr in profile_attrs:
|
||||||
if profile_attr['key'] == 'UplinkHostSwitchProfile':
|
if profile_attr['key'] == 'UplinkHostSwitchProfile':
|
||||||
|
profile_id = profile_attr['value']
|
||||||
|
if profile_id in known_profiles:
|
||||||
|
LOG.debug("Profile %s has already been "
|
||||||
|
"loaded, skipping", profile_id)
|
||||||
|
continue
|
||||||
profile = self.nsxlib.host_switch_profiles.get(
|
profile = self.nsxlib.host_switch_profiles.get(
|
||||||
profile_attr['value'])
|
profile_id)
|
||||||
vlan_id = profile.get('transport_vlan')
|
vlan_id = profile.get('transport_vlan')
|
||||||
|
known_profiles.append(profile_id)
|
||||||
if vlan_id:
|
if vlan_id:
|
||||||
restricted_vlans.append(vlan_id)
|
restricted_vlans.append(vlan_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user