|
|
|
@ -185,18 +185,21 @@ def remove_switchport_config_commands(name, existing, proposed, module):
|
|
|
|
|
commands.append(command)
|
|
|
|
|
|
|
|
|
|
elif mode == 'trunk':
|
|
|
|
|
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
|
|
|
|
|
|
|
|
|
|
if not tv_check:
|
|
|
|
|
existing_vlans = existing.get('trunk_vlans_list')
|
|
|
|
|
proposed_vlans = proposed.get('trunk_vlans_list')
|
|
|
|
|
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
|
|
|
|
|
|
|
|
|
|
if vlans_to_remove:
|
|
|
|
|
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
|
|
|
|
|
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
|
|
|
|
|
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
|
|
|
|
|
commands.append(command)
|
|
|
|
|
# Supported Remove Scenarios for trunk_vlans_list
|
|
|
|
|
# 1) Existing: 1,2,3 Proposed: 1,2,3 - Remove all
|
|
|
|
|
# 2) Existing: 1,2,3 Proposed: 1,2 - Remove 1,2 Leave 3
|
|
|
|
|
# 3) Existing: 1,2,3 Proposed: 2,3 - Remove 2,3 Leave 1
|
|
|
|
|
# 4) Existing: 1,2,3 Proposed: 4,5,6 - None removed.
|
|
|
|
|
# 5) Existing: None Proposed: 1,2,3 - None removed.
|
|
|
|
|
existing_vlans = existing.get('trunk_vlans_list')
|
|
|
|
|
proposed_vlans = proposed.get('trunk_vlans_list')
|
|
|
|
|
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
|
|
|
|
|
|
|
|
|
|
if vlans_to_remove:
|
|
|
|
|
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
|
|
|
|
|
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
|
|
|
|
|
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
|
|
|
|
|
commands.append(command)
|
|
|
|
|
|
|
|
|
|
native_check = existing.get('native_vlan') == proposed.get('native_vlan')
|
|
|
|
|
if native_check and proposed.get('native_vlan'):
|
|
|
|
@ -291,7 +294,7 @@ def vlan_range_to_list(vlans):
|
|
|
|
|
result = []
|
|
|
|
|
if vlans:
|
|
|
|
|
for part in vlans.split(','):
|
|
|
|
|
if part == 'none':
|
|
|
|
|
if part.lower() == 'none':
|
|
|
|
|
break
|
|
|
|
|
if '-' in part:
|
|
|
|
|
start, stop = (int(i) for i in part.split('-'))
|
|
|
|
|