From c3287e158697ea8682cc288ff13ed63475dd2254 Mon Sep 17 00:00:00 2001 From: Ratnesh Nagori Date: Sun, 6 Jun 2021 19:12:30 +1000 Subject: [PATCH 1/6] icx_vlan - add support for stacked switches --- plugins/modules/network/icx/icx_vlan.py | 97 ++++++++----------------- 1 file changed, 30 insertions(+), 67 deletions(-) diff --git a/plugins/modules/network/icx/icx_vlan.py b/plugins/modules/network/icx/icx_vlan.py index 4c102705..5c33abd0 100644 --- a/plugins/modules/network/icx/icx_vlan.py +++ b/plugins/modules/network/icx/icx_vlan.py @@ -6,9 +6,14 @@ __metaclass__ = type -DOCUMENTATION = ''' +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = """ --- module: icx_vlan +version_added: "2.9" author: "Ruckus Wireless (@Commscope)" short_description: Manage VLANs on Ruckus ICX 7000 series switches description: @@ -215,11 +220,11 @@ Module will use environment variable value(default:True), unless it is overridden, by specifying it as module parameter. type: bool default: yes -''' +""" EXAMPLES = """ - name: Add a single ethernet 1/1/48 as access(untagged) port to vlan 20 - community.network.icx_vlan: + icx_vlan: name: test-vlan vlan_id: 20 interfaces: @@ -227,21 +232,21 @@ - ethernet 1/1/48 - name: Add a single LAG 10 as access(untagged) port to vlan 20 - community.network.icx_vlan: + icx_vlan: vlan_id: 20 interfaces: name: - lag 10 - name: Add a range of ethernet ports as trunk(tagged) ports to vlan 20 by port - community.network.icx_vlan: + icx_vlan: vlan_id: 20 tagged: name: - ethernet 1/1/40 to 1/1/48 - name: Add discontinuous lags, ethernet ports as access(untagged) and trunk(tagged) port to vlan 20. - community.network.icx_vlan: + icx_vlan: vlan_id: 20 interfaces: name: @@ -255,7 +260,7 @@ - lag 1 to 3 - name: Remove an access and range of trunk ports from vlan - community.network.icx_vlan: + icx_vlan: vlan_id: 20 interfaces: name: @@ -265,19 +270,19 @@ - ethernet 1/1/39 to 1/1/70 - name: Enable dhcp snooping, disable arp inspection in vlan - community.network.icx_vlan: + icx_vlan: vlan_id: 20 ip_dhcp_snooping: present ip_arp_inspection: absent - name: Create vlan 20. Enable arp inspection in vlan. Purge all other vlans. - community.network.icx_vlan: + icx_vlan: vlan_id: 20 ip_arp_inspection: present purge: present - name: Remove vlan 20. - community.network.icx_vlan: + icx_vlan: vlan_id: 20 state: absent """ @@ -299,10 +304,10 @@ from time import sleep from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig -from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config +from ansible.module_utils.network.common.config import NetworkConfig +from ansible.module_utils.network.icx.icx import load_config, get_config from ansible.module_utils.connection import Connection, ConnectionError, exec_command -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec +from ansible.module_utils.network.common.utils import conditional, remove_default_spec def search_obj_in_list(vlan_id, lst): @@ -320,7 +325,6 @@ def parse_vlan_brief(module, vlan_id): untagged_lags = list() tagged_ports = list() tagged_lags = list() - for line in lines: if 'tagged' in line.split(): lags = line.split(" lag ") @@ -329,12 +333,12 @@ def parse_vlan_brief(module, vlan_id): del lags[0] for port in ports: if "to" in port: - p = port.split(" to ") + p = port.strip().split(" to ") pr = int(p[1].split('/')[2]) - int(p[0].split('/')[2]) for i in range(0, pr + 1): - tagged_ports.append((int(p[0].split('/')[2]) + i)) + tagged_ports.append(p[0][0:4] + str(int(p[0].split('/')[2]) + i)) else: - tagged_ports.append(int(port.split('/')[2])) + tagged_ports.append(port.strip()) for lag in lags: if "to" in lag: l = lag.split(" to ") @@ -350,12 +354,12 @@ def parse_vlan_brief(module, vlan_id): del lags[0] for port in ports: if "to" in port: - p = port.split(" to ") + p = port.strip().split(" to ") pr = int(p[1].split('/')[2]) - int(p[0].split('/')[2]) for i in range(0, pr + 1): - untagged_ports.append((int(p[0].split('/')[2]) + i)) + untagged_ports.append(p[0][0:4] + str(int(p[0].split('/')[2]) + i)) else: - untagged_ports.append(int(port.split('/')[2])) + untagged_ports.append(port.strip()) for lag in lags: if "to" in lag: l = lag.split(" to ") @@ -364,7 +368,6 @@ def parse_vlan_brief(module, vlan_id): untagged_lags.append((int(l[0]) + i)) else: untagged_lags.append(int(lag)) - return untagged_ports, untagged_lags, tagged_ports, tagged_lags @@ -387,7 +390,6 @@ def extract_list_from_interface(interface): s = re.search(r"(?P\d+)", interface) low = int(s.group('low')) high = int(s.group('low')) - return low, high @@ -416,14 +418,12 @@ def spanning_tree(module, stp): if stp.get('type') == '802-1w': stp_cmd.append('no spanning-tree' + ' ' + stp.get('type')) stp_cmd.append('no spanning-tree') - elif stp.get('type'): stp_cmd.append('spanning-tree' + ' ' + stp.get('type')) if stp.get('priority') and stp.get('type') == 'rstp': module.fail_json(msg='spanning-tree 802-1w only can have priority') elif stp.get('priority'): stp_cmd.append('spanning-tree' + ' ' + stp.get('type') + ' ' + 'priority' + ' ' + stp.get('priority')) - return stp_cmd @@ -439,11 +439,8 @@ def map_params_to_obj(module): if stp: stp_cmd = spanning_tree(module, stp) item.update({'stp': stp_cmd}) - d = item.copy() - obj.append(d) - else: params = { 'name': module.params['name'], @@ -457,14 +454,11 @@ def map_params_to_obj(module): 'ip_arp_inspection': module.params['ip_arp_inspection'], 'state': module.params['state'], } - stp = module.params.get('stp') if stp: stp_cmd = spanning_tree(module, stp) params.update({'stp': stp_cmd}) - obj.append(params) - return obj @@ -472,7 +466,6 @@ def map_obj_to_commands(updates, module): commands = list() want, have = updates purge = module.params['purge'] - for w in want: vlan_id = w['vlan_id'] state = w['state'] @@ -483,81 +476,67 @@ def map_obj_to_commands(updates, module): arp = w.get('ip_arp_inspection') stp = w.get('stp') obj_in_have = search_obj_in_list(str(vlan_id), have) - if state == 'absent': if have == []: commands.append('no vlan {0}'.format(vlan_id)) if obj_in_have: commands.append('no vlan {0}'.format(vlan_id)) - elif state == 'present': if not obj_in_have: commands.append('vlan {0}'.format(vlan_id)) if name: commands.append('vlan {0} name {1}'.format(vlan_id, name)) - if interfaces: if interfaces['name']: for item in interfaces['name']: commands.append('untagged {0}'.format(item)) - if tagged: if tagged['name']: for item in tagged['name']: commands.append('tagged {0}'.format(item)) - if dhcp is True: commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) - if arp is True: commands.append('ip arp inspection vlan {0}'.format(vlan_id)) elif dhcp is False: commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) - if stp: if w.get('stp'): [commands.append(cmd) for cmd in w['stp']] - else: commands.append('vlan {0}'.format(vlan_id)) if name: if name != obj_in_have['name']: commands.append('vlan {0} name {1}'.format(vlan_id, name)) - if interfaces: if interfaces['name']: have_interfaces = list() for interface in interfaces['name']: low, high = extract_list_from_interface(interface) - while(high >= low): if 'ethernet' in interface: - have_interfaces.append('ethernet 1/1/{0}'.format(low)) + have_interfaces.append('ethernet ' + interface.split(" ")[1].split("/")[0]+'/'+interface.split(" ")[1].split("/")[1]+'/{0}'.format(low)) if 'lag' in interface: have_interfaces.append('lag {0}'.format(low)) low = low + 1 - if interfaces['purge'] is True: remove_interfaces = list(set(obj_in_have['interfaces']) - set(have_interfaces)) for item in remove_interfaces: commands.append('no untagged {0}'.format(item)) - if interfaces['name']: add_interfaces = list(set(have_interfaces) - set(obj_in_have['interfaces'])) for item in add_interfaces: commands.append('untagged {0}'.format(item)) - if tagged: if tagged['name']: have_tagged = list() for tag in tagged['name']: low, high = extract_list_from_interface(tag) - while(high >= low): if 'ethernet' in tag: - have_tagged.append('ethernet 1/1/{0}'.format(low)) + have_tagged.append('ethernet ' + tag.split(" ")[1].split("/")[0]+'/'+tag.split(" ")[1].split("/")[1]+'/{0}'.format(low)) if 'lag' in tag: have_tagged.append('lag {0}'.format(low)) low = low + 1 @@ -565,31 +544,25 @@ def map_obj_to_commands(updates, module): remove_tagged = list(set(obj_in_have['tagged']) - set(have_tagged)) for item in remove_tagged: commands.append('no tagged {0}'.format(item)) - if tagged['name']: add_tagged = list(set(have_tagged) - set(obj_in_have['tagged'])) for item in add_tagged: commands.append('tagged {0}'.format(item)) - if dhcp != obj_in_have['ip_dhcp_snooping']: if dhcp is True: commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) - if arp != obj_in_have['ip_arp_inspection']: if arp is True: commands.append('ip arp inspection vlan {0}'.format(vlan_id)) elif arp is False: commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) - if stp: if w.get('stp'): [commands.append(cmd) for cmd in w['stp']] - if len(commands) == 1 and 'vlan ' + str(vlan_id) in commands: commands = [] - if purge: commands = [] vlans = parse_vlan_id(module) @@ -597,7 +570,6 @@ def map_obj_to_commands(updates, module): obj_in_want = search_obj_in_list(h, want) if not obj_in_want and h != '1': commands.append('no vlan {0}'.format(h)) - return commands @@ -615,19 +587,17 @@ def parse_interfaces_argument(module, item, port_type): if port_type == "interfaces": if untagged_ports: for port in untagged_ports: - ports.append('ethernet 1/1/' + str(port)) + ports.append(port) if untagged_lags: for port in untagged_lags: ports.append('lag ' + str(port)) - elif port_type == "tagged": if tagged_ports: for port in tagged_ports: - ports.append('ethernet 1/1/' + str(port)) + ports.append(port) if tagged_lags: for port in tagged_lags: ports.append('lag ' + str(port)) - return ports @@ -643,7 +613,6 @@ def map_config_to_obj(module): config = get_config(module) vlans = parse_vlan_id(module) instance = list() - for item in set(vlans): obj = { 'vlan_id': item, @@ -659,7 +628,7 @@ def map_config_to_obj(module): def check_fail(module, output): error = [ - re.compile(r"^error", re.I) + re.compile(br"^error", re.I) ] for x in output: for regex in error: @@ -671,7 +640,6 @@ def check_declarative_intent_params(want, module, result): def parse_ports(interfaces, ports, lags): for interface in interfaces: low, high = extract_list_from_interface(interface) - while(high >= low): if 'ethernet' in interface: if not (low in ports): @@ -680,23 +648,18 @@ def parse_ports(interfaces, ports, lags): if not (low in lags): module.fail_json(msg='One or more conditional statements have not been satisfied ' + interface) low = low + 1 - is_delay = False low = 0 high = 0 for w in want: if w.get('associated_interfaces') is None and w.get('associated_tagged') is None: continue - if result['changed'] and not is_delay: sleep(module.params['delay']) is_delay = True - untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief(module, w['vlan_id']) - if w['associated_interfaces']: parse_ports(w.get('associated_interfaces'), untagged_ports, untagged_lags) - if w['associated_tagged']: parse_ports(w.get('associated_tagged'), tagged_ports, tagged_lags) @@ -776,4 +739,4 @@ def main(): if __name__ == '__main__': - main() + main() \ No newline at end of file From cb868e376dd2ebfedf914a1a9ffa696b040aa7c7 Mon Sep 17 00:00:00 2001 From: Ratnesh Nagori Date: Sun, 6 Jun 2021 20:09:49 +1000 Subject: [PATCH 2/6] corrections based on source file --- plugins/modules/network/icx/icx_vlan.py | 82 +++++++++++++++++-------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/plugins/modules/network/icx/icx_vlan.py b/plugins/modules/network/icx/icx_vlan.py index 5c33abd0..ad721744 100644 --- a/plugins/modules/network/icx/icx_vlan.py +++ b/plugins/modules/network/icx/icx_vlan.py @@ -6,14 +6,9 @@ __metaclass__ = type -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = """ +DOCUMENTATION = ''' --- module: icx_vlan -version_added: "2.9" author: "Ruckus Wireless (@Commscope)" short_description: Manage VLANs on Ruckus ICX 7000 series switches description: @@ -220,33 +215,30 @@ Module will use environment variable value(default:True), unless it is overridden, by specifying it as module parameter. type: bool default: yes -""" +''' EXAMPLES = """ - name: Add a single ethernet 1/1/48 as access(untagged) port to vlan 20 - icx_vlan: + community.network.icx_vlan: name: test-vlan vlan_id: 20 interfaces: name: - ethernet 1/1/48 - - name: Add a single LAG 10 as access(untagged) port to vlan 20 - icx_vlan: + community.network.icx_vlan: vlan_id: 20 interfaces: name: - lag 10 - - name: Add a range of ethernet ports as trunk(tagged) ports to vlan 20 by port - icx_vlan: + community.network.icx_vlan: vlan_id: 20 tagged: name: - ethernet 1/1/40 to 1/1/48 - - name: Add discontinuous lags, ethernet ports as access(untagged) and trunk(tagged) port to vlan 20. - icx_vlan: + community.network.icx_vlan: vlan_id: 20 interfaces: name: @@ -258,9 +250,8 @@ name: - ethernet 1/1/20 to 1/1/25 - lag 1 to 3 - - name: Remove an access and range of trunk ports from vlan - icx_vlan: + community.network.icx_vlan: vlan_id: 20 interfaces: name: @@ -268,21 +259,18 @@ tagged: name: - ethernet 1/1/39 to 1/1/70 - - name: Enable dhcp snooping, disable arp inspection in vlan - icx_vlan: + community.network.icx_vlan: vlan_id: 20 ip_dhcp_snooping: present ip_arp_inspection: absent - - name: Create vlan 20. Enable arp inspection in vlan. Purge all other vlans. - icx_vlan: + community.network.icx_vlan: vlan_id: 20 ip_arp_inspection: present purge: present - - name: Remove vlan 20. - icx_vlan: + community.network.icx_vlan: vlan_id: 20 state: absent """ @@ -304,10 +292,10 @@ from time import sleep from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible.module_utils.network.common.config import NetworkConfig -from ansible.module_utils.network.icx.icx import load_config, get_config +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig +from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config from ansible.module_utils.connection import Connection, ConnectionError, exec_command -from ansible.module_utils.network.common.utils import conditional, remove_default_spec +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec def search_obj_in_list(vlan_id, lst): @@ -325,6 +313,7 @@ def parse_vlan_brief(module, vlan_id): untagged_lags = list() tagged_ports = list() tagged_lags = list() + for line in lines: if 'tagged' in line.split(): lags = line.split(" lag ") @@ -368,6 +357,7 @@ def parse_vlan_brief(module, vlan_id): untagged_lags.append((int(l[0]) + i)) else: untagged_lags.append(int(lag)) + return untagged_ports, untagged_lags, tagged_ports, tagged_lags @@ -390,6 +380,7 @@ def extract_list_from_interface(interface): s = re.search(r"(?P\d+)", interface) low = int(s.group('low')) high = int(s.group('low')) + return low, high @@ -418,12 +409,14 @@ def spanning_tree(module, stp): if stp.get('type') == '802-1w': stp_cmd.append('no spanning-tree' + ' ' + stp.get('type')) stp_cmd.append('no spanning-tree') + elif stp.get('type'): stp_cmd.append('spanning-tree' + ' ' + stp.get('type')) if stp.get('priority') and stp.get('type') == 'rstp': module.fail_json(msg='spanning-tree 802-1w only can have priority') elif stp.get('priority'): stp_cmd.append('spanning-tree' + ' ' + stp.get('type') + ' ' + 'priority' + ' ' + stp.get('priority')) + return stp_cmd @@ -439,8 +432,11 @@ def map_params_to_obj(module): if stp: stp_cmd = spanning_tree(module, stp) item.update({'stp': stp_cmd}) + d = item.copy() + obj.append(d) + else: params = { 'name': module.params['name'], @@ -454,11 +450,14 @@ def map_params_to_obj(module): 'ip_arp_inspection': module.params['ip_arp_inspection'], 'state': module.params['state'], } + stp = module.params.get('stp') if stp: stp_cmd = spanning_tree(module, stp) params.update({'stp': stp_cmd}) + obj.append(params) + return obj @@ -466,6 +465,7 @@ def map_obj_to_commands(updates, module): commands = list() want, have = updates purge = module.params['purge'] + for w in want: vlan_id = w['vlan_id'] state = w['state'] @@ -476,64 +476,78 @@ def map_obj_to_commands(updates, module): arp = w.get('ip_arp_inspection') stp = w.get('stp') obj_in_have = search_obj_in_list(str(vlan_id), have) + if state == 'absent': if have == []: commands.append('no vlan {0}'.format(vlan_id)) if obj_in_have: commands.append('no vlan {0}'.format(vlan_id)) + elif state == 'present': if not obj_in_have: commands.append('vlan {0}'.format(vlan_id)) if name: commands.append('vlan {0} name {1}'.format(vlan_id, name)) + if interfaces: if interfaces['name']: for item in interfaces['name']: commands.append('untagged {0}'.format(item)) + if tagged: if tagged['name']: for item in tagged['name']: commands.append('tagged {0}'.format(item)) + if dhcp is True: commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) + if arp is True: commands.append('ip arp inspection vlan {0}'.format(vlan_id)) elif dhcp is False: commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) + if stp: if w.get('stp'): [commands.append(cmd) for cmd in w['stp']] + else: commands.append('vlan {0}'.format(vlan_id)) if name: if name != obj_in_have['name']: commands.append('vlan {0} name {1}'.format(vlan_id, name)) + if interfaces: if interfaces['name']: have_interfaces = list() for interface in interfaces['name']: low, high = extract_list_from_interface(interface) + while(high >= low): if 'ethernet' in interface: have_interfaces.append('ethernet ' + interface.split(" ")[1].split("/")[0]+'/'+interface.split(" ")[1].split("/")[1]+'/{0}'.format(low)) if 'lag' in interface: have_interfaces.append('lag {0}'.format(low)) low = low + 1 + if interfaces['purge'] is True: remove_interfaces = list(set(obj_in_have['interfaces']) - set(have_interfaces)) for item in remove_interfaces: commands.append('no untagged {0}'.format(item)) + if interfaces['name']: add_interfaces = list(set(have_interfaces) - set(obj_in_have['interfaces'])) for item in add_interfaces: commands.append('untagged {0}'.format(item)) + if tagged: if tagged['name']: have_tagged = list() for tag in tagged['name']: low, high = extract_list_from_interface(tag) + while(high >= low): if 'ethernet' in tag: have_tagged.append('ethernet ' + tag.split(" ")[1].split("/")[0]+'/'+tag.split(" ")[1].split("/")[1]+'/{0}'.format(low)) @@ -544,25 +558,31 @@ def map_obj_to_commands(updates, module): remove_tagged = list(set(obj_in_have['tagged']) - set(have_tagged)) for item in remove_tagged: commands.append('no tagged {0}'.format(item)) + if tagged['name']: add_tagged = list(set(have_tagged) - set(obj_in_have['tagged'])) for item in add_tagged: commands.append('tagged {0}'.format(item)) + if dhcp != obj_in_have['ip_dhcp_snooping']: if dhcp is True: commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) + if arp != obj_in_have['ip_arp_inspection']: if arp is True: commands.append('ip arp inspection vlan {0}'.format(vlan_id)) elif arp is False: commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) + if stp: if w.get('stp'): [commands.append(cmd) for cmd in w['stp']] + if len(commands) == 1 and 'vlan ' + str(vlan_id) in commands: commands = [] + if purge: commands = [] vlans = parse_vlan_id(module) @@ -570,6 +590,7 @@ def map_obj_to_commands(updates, module): obj_in_want = search_obj_in_list(h, want) if not obj_in_want and h != '1': commands.append('no vlan {0}'.format(h)) + return commands @@ -591,6 +612,7 @@ def parse_interfaces_argument(module, item, port_type): if untagged_lags: for port in untagged_lags: ports.append('lag ' + str(port)) + elif port_type == "tagged": if tagged_ports: for port in tagged_ports: @@ -598,6 +620,7 @@ def parse_interfaces_argument(module, item, port_type): if tagged_lags: for port in tagged_lags: ports.append('lag ' + str(port)) + return ports @@ -613,6 +636,7 @@ def map_config_to_obj(module): config = get_config(module) vlans = parse_vlan_id(module) instance = list() + for item in set(vlans): obj = { 'vlan_id': item, @@ -628,7 +652,7 @@ def map_config_to_obj(module): def check_fail(module, output): error = [ - re.compile(br"^error", re.I) + re.compile(r"^error", re.I) ] for x in output: for regex in error: @@ -640,6 +664,7 @@ def check_declarative_intent_params(want, module, result): def parse_ports(interfaces, ports, lags): for interface in interfaces: low, high = extract_list_from_interface(interface) + while(high >= low): if 'ethernet' in interface: if not (low in ports): @@ -648,18 +673,23 @@ def parse_ports(interfaces, ports, lags): if not (low in lags): module.fail_json(msg='One or more conditional statements have not been satisfied ' + interface) low = low + 1 + is_delay = False low = 0 high = 0 for w in want: if w.get('associated_interfaces') is None and w.get('associated_tagged') is None: continue + if result['changed'] and not is_delay: sleep(module.params['delay']) is_delay = True + untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief(module, w['vlan_id']) + if w['associated_interfaces']: parse_ports(w.get('associated_interfaces'), untagged_ports, untagged_lags) + if w['associated_tagged']: parse_ports(w.get('associated_tagged'), tagged_ports, tagged_lags) From a5d5de45146a80214b84422bcb0ad8959c9d5e87 Mon Sep 17 00:00:00 2001 From: Ratnesh Nagori Date: Wed, 21 Jul 2021 21:00:42 +1000 Subject: [PATCH 3/6] pep8 formatting --- plugins/modules/network/icx/icx_vlan.py | 102 +++++++++++++++--------- 1 file changed, 63 insertions(+), 39 deletions(-) diff --git a/plugins/modules/network/icx/icx_vlan.py b/plugins/modules/network/icx/icx_vlan.py index ad721744..5b251651 100644 --- a/plugins/modules/network/icx/icx_vlan.py +++ b/plugins/modules/network/icx/icx_vlan.py @@ -3,6 +3,16 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec +from ansible.module_utils.connection import Connection, ConnectionError, exec_command +from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig +from ansible.module_utils.basic import AnsibleModule, env_fallback +from ansible.module_utils._text import to_text +from copy import deepcopy +import itertools +from time import sleep +import re __metaclass__ = type @@ -285,18 +295,6 @@ - name test-vlan """ -import re -from time import sleep -import itertools -from copy import deepcopy -from time import sleep -from ansible.module_utils._text import to_text -from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig -from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config -from ansible.module_utils.connection import Connection, ConnectionError, exec_command -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec - def search_obj_in_list(vlan_id, lst): obj = list() @@ -325,7 +323,8 @@ def parse_vlan_brief(module, vlan_id): p = port.strip().split(" to ") pr = int(p[1].split('/')[2]) - int(p[0].split('/')[2]) for i in range(0, pr + 1): - tagged_ports.append(p[0][0:4] + str(int(p[0].split('/')[2]) + i)) + tagged_ports.append( + p[0][0:4] + str(int(p[0].split('/')[2]) + i)) else: tagged_ports.append(port.strip()) for lag in lags: @@ -346,7 +345,8 @@ def parse_vlan_brief(module, vlan_id): p = port.strip().split(" to ") pr = int(p[1].split('/')[2]) - int(p[0].split('/')[2]) for i in range(0, pr + 1): - untagged_ports.append(p[0][0:4] + str(int(p[0].split('/')[2]) + i)) + untagged_ports.append( + p[0][0:4] + str(int(p[0].split('/')[2]) + i)) else: untagged_ports.append(port.strip()) for lag in lags: @@ -364,7 +364,8 @@ def parse_vlan_brief(module, vlan_id): def extract_list_from_interface(interface): if 'ethernet' in interface: if 'to' in interface: - s = re.search(r"\d+\/\d+/(?P\d+)\sto\s+\d+\/\d+/(?P\d+)", interface) + s = re.search( + r"\d+\/\d+/(?P\d+)\sto\s+\d+\/\d+/(?P\d+)", interface) low = int(s.group('low')) high = int(s.group('high')) else: @@ -415,7 +416,8 @@ def spanning_tree(module, stp): if stp.get('priority') and stp.get('type') == 'rstp': module.fail_json(msg='spanning-tree 802-1w only can have priority') elif stp.get('priority'): - stp_cmd.append('spanning-tree' + ' ' + stp.get('type') + ' ' + 'priority' + ' ' + stp.get('priority')) + stp_cmd.append('spanning-tree' + ' ' + stp.get('type') + + ' ' + 'priority' + ' ' + stp.get('priority')) return stp_cmd @@ -500,14 +502,18 @@ def map_obj_to_commands(updates, module): commands.append('tagged {0}'.format(item)) if dhcp is True: - commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append( + 'ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: - commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append( + 'no ip dhcp snooping vlan {0}'.format(vlan_id)) if arp is True: - commands.append('ip arp inspection vlan {0}'.format(vlan_id)) + commands.append( + 'ip arp inspection vlan {0}'.format(vlan_id)) elif dhcp is False: - commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) + commands.append( + 'no ip arp inspection vlan {0}'.format(vlan_id)) if stp: if w.get('stp'): @@ -517,7 +523,8 @@ def map_obj_to_commands(updates, module): commands.append('vlan {0}'.format(vlan_id)) if name: if name != obj_in_have['name']: - commands.append('vlan {0} name {1}'.format(vlan_id, name)) + commands.append( + 'vlan {0} name {1}'.format(vlan_id, name)) if interfaces: if interfaces['name']: @@ -527,18 +534,22 @@ def map_obj_to_commands(updates, module): while(high >= low): if 'ethernet' in interface: - have_interfaces.append('ethernet ' + interface.split(" ")[1].split("/")[0]+'/'+interface.split(" ")[1].split("/")[1]+'/{0}'.format(low)) + have_interfaces.append('ethernet ' + interface.split(" ")[1].split( + "/")[0]+'/'+interface.split(" ")[1].split("/")[1]+'/{0}'.format(low)) if 'lag' in interface: - have_interfaces.append('lag {0}'.format(low)) + have_interfaces.append( + 'lag {0}'.format(low)) low = low + 1 if interfaces['purge'] is True: - remove_interfaces = list(set(obj_in_have['interfaces']) - set(have_interfaces)) + remove_interfaces = list( + set(obj_in_have['interfaces']) - set(have_interfaces)) for item in remove_interfaces: commands.append('no untagged {0}'.format(item)) if interfaces['name']: - add_interfaces = list(set(have_interfaces) - set(obj_in_have['interfaces'])) + add_interfaces = list( + set(have_interfaces) - set(obj_in_have['interfaces'])) for item in add_interfaces: commands.append('untagged {0}'.format(item)) @@ -550,31 +561,38 @@ def map_obj_to_commands(updates, module): while(high >= low): if 'ethernet' in tag: - have_tagged.append('ethernet ' + tag.split(" ")[1].split("/")[0]+'/'+tag.split(" ")[1].split("/")[1]+'/{0}'.format(low)) + have_tagged.append('ethernet ' + tag.split(" ")[1].split( + "/")[0]+'/'+tag.split(" ")[1].split("/")[1]+'/{0}'.format(low)) if 'lag' in tag: have_tagged.append('lag {0}'.format(low)) low = low + 1 if tagged['purge'] is True: - remove_tagged = list(set(obj_in_have['tagged']) - set(have_tagged)) + remove_tagged = list( + set(obj_in_have['tagged']) - set(have_tagged)) for item in remove_tagged: commands.append('no tagged {0}'.format(item)) if tagged['name']: - add_tagged = list(set(have_tagged) - set(obj_in_have['tagged'])) + add_tagged = list( + set(have_tagged) - set(obj_in_have['tagged'])) for item in add_tagged: commands.append('tagged {0}'.format(item)) if dhcp != obj_in_have['ip_dhcp_snooping']: if dhcp is True: - commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append( + 'ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: - commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append( + 'no ip dhcp snooping vlan {0}'.format(vlan_id)) if arp != obj_in_have['ip_arp_inspection']: if arp is True: - commands.append('ip arp inspection vlan {0}'.format(vlan_id)) + commands.append( + 'ip arp inspection vlan {0}'.format(vlan_id)) elif arp is False: - commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) + commands.append( + 'no ip arp inspection vlan {0}'.format(vlan_id)) if stp: if w.get('stp'): @@ -603,7 +621,8 @@ def parse_name_argument(module, item): def parse_interfaces_argument(module, item, port_type): - untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief(module, item) + untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief( + module, item) ports = list() if port_type == "interfaces": if untagged_ports: @@ -668,10 +687,12 @@ def parse_ports(interfaces, ports, lags): while(high >= low): if 'ethernet' in interface: if not (low in ports): - module.fail_json(msg='One or more conditional statements have not been satisfied ' + interface) + module.fail_json( + msg='One or more conditional statements have not been satisfied ' + interface) if 'lag' in interface: if not (low in lags): - module.fail_json(msg='One or more conditional statements have not been satisfied ' + interface) + module.fail_json( + msg='One or more conditional statements have not been satisfied ' + interface) low = low + 1 is_delay = False @@ -685,10 +706,12 @@ def parse_ports(interfaces, ports, lags): sleep(module.params['delay']) is_delay = True - untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief(module, w['vlan_id']) + untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief( + module, w['vlan_id']) if w['associated_interfaces']: - parse_ports(w.get('associated_interfaces'), untagged_ports, untagged_lags) + parse_ports(w.get('associated_interfaces'), + untagged_ports, untagged_lags) if w['associated_tagged']: parse_ports(w.get('associated_tagged'), tagged_ports, tagged_lags) @@ -722,7 +745,8 @@ def main(): delay=dict(default=10, type='int'), stp=dict(type='dict', options=stp_spec), state=dict(default='present', choices=['present', 'absent']), - check_running_config=dict(default=True, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG'])) + check_running_config=dict(default=True, type='bool', fallback=( + env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG'])) ) aggregate_spec = deepcopy(element_spec) aggregate_spec['vlan_id'] = dict(required=True) @@ -769,4 +793,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() From 6a0daee2ddcf95d7d1ade31906ff41c960d4fdfd Mon Sep 17 00:00:00 2001 From: Ratnesh Nagori Date: Wed, 21 Jul 2021 21:14:50 +1000 Subject: [PATCH 4/6] space for arithmetic operator --- plugins/modules/network/icx/icx_vlan.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/modules/network/icx/icx_vlan.py b/plugins/modules/network/icx/icx_vlan.py index 5b251651..4b898fa9 100644 --- a/plugins/modules/network/icx/icx_vlan.py +++ b/plugins/modules/network/icx/icx_vlan.py @@ -3,16 +3,6 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec -from ansible.module_utils.connection import Connection, ConnectionError, exec_command -from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig -from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible.module_utils._text import to_text -from copy import deepcopy -import itertools -from time import sleep -import re __metaclass__ = type @@ -295,6 +285,16 @@ - name test-vlan """ +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec +from ansible.module_utils.connection import Connection, ConnectionError, exec_command +from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig +from ansible.module_utils.basic import AnsibleModule, env_fallback +from ansible.module_utils._text import to_text +from copy import deepcopy +import itertools +from time import sleep +import re def search_obj_in_list(vlan_id, lst): obj = list() @@ -535,7 +535,7 @@ def map_obj_to_commands(updates, module): while(high >= low): if 'ethernet' in interface: have_interfaces.append('ethernet ' + interface.split(" ")[1].split( - "/")[0]+'/'+interface.split(" ")[1].split("/")[1]+'/{0}'.format(low)) + "/")[0] + '/' + interface.split(" ")[1].split("/")[1] + '/{0}'.format(low)) if 'lag' in interface: have_interfaces.append( 'lag {0}'.format(low)) @@ -562,7 +562,7 @@ def map_obj_to_commands(updates, module): while(high >= low): if 'ethernet' in tag: have_tagged.append('ethernet ' + tag.split(" ")[1].split( - "/")[0]+'/'+tag.split(" ")[1].split("/")[1]+'/{0}'.format(low)) + "/")[0] + '/' + tag.split(" ")[1].split("/")[1] + '/{0}'.format(low)) if 'lag' in tag: have_tagged.append('lag {0}'.format(low)) low = low + 1 From 81984148e146108f7ec9f6411ad27d682c5225ba Mon Sep 17 00:00:00 2001 From: Ratnesh Nagori Date: Wed, 21 Jul 2021 22:58:15 +1000 Subject: [PATCH 5/6] add extra line --- plugins/modules/network/icx/icx_vlan.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/network/icx/icx_vlan.py b/plugins/modules/network/icx/icx_vlan.py index 4b898fa9..134d4860 100644 --- a/plugins/modules/network/icx/icx_vlan.py +++ b/plugins/modules/network/icx/icx_vlan.py @@ -296,6 +296,7 @@ from time import sleep import re + def search_obj_in_list(vlan_id, lst): obj = list() for o in lst: From 4d9a7dd8f2ddd20031089dbeaf7609eedc2173a8 Mon Sep 17 00:00:00 2001 From: Deric Crago Date: Thu, 11 Nov 2021 09:24:25 -1000 Subject: [PATCH 6/6] reverted style changes --- plugins/modules/network/icx/icx_vlan.py | 107 ++++++++++-------------- 1 file changed, 46 insertions(+), 61 deletions(-) diff --git a/plugins/modules/network/icx/icx_vlan.py b/plugins/modules/network/icx/icx_vlan.py index 134d4860..4ca43227 100644 --- a/plugins/modules/network/icx/icx_vlan.py +++ b/plugins/modules/network/icx/icx_vlan.py @@ -225,18 +225,21 @@ interfaces: name: - ethernet 1/1/48 + - name: Add a single LAG 10 as access(untagged) port to vlan 20 community.network.icx_vlan: vlan_id: 20 interfaces: name: - lag 10 + - name: Add a range of ethernet ports as trunk(tagged) ports to vlan 20 by port community.network.icx_vlan: vlan_id: 20 tagged: name: - ethernet 1/1/40 to 1/1/48 + - name: Add discontinuous lags, ethernet ports as access(untagged) and trunk(tagged) port to vlan 20. community.network.icx_vlan: vlan_id: 20 @@ -250,6 +253,7 @@ name: - ethernet 1/1/20 to 1/1/25 - lag 1 to 3 + - name: Remove an access and range of trunk ports from vlan community.network.icx_vlan: vlan_id: 20 @@ -259,16 +263,19 @@ tagged: name: - ethernet 1/1/39 to 1/1/70 + - name: Enable dhcp snooping, disable arp inspection in vlan community.network.icx_vlan: vlan_id: 20 ip_dhcp_snooping: present ip_arp_inspection: absent + - name: Create vlan 20. Enable arp inspection in vlan. Purge all other vlans. community.network.icx_vlan: vlan_id: 20 ip_arp_inspection: present purge: present + - name: Remove vlan 20. community.network.icx_vlan: vlan_id: 20 @@ -285,16 +292,16 @@ - name test-vlan """ -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec -from ansible.module_utils.connection import Connection, ConnectionError, exec_command -from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig -from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible.module_utils._text import to_text -from copy import deepcopy -import itertools -from time import sleep import re +from time import sleep +import itertools +from copy import deepcopy +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule, env_fallback +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig +from ansible_collections.community.network.plugins.module_utils.network.icx.icx import load_config, get_config +from ansible.module_utils.connection import Connection, ConnectionError, exec_command +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import conditional, remove_default_spec def search_obj_in_list(vlan_id, lst): @@ -324,8 +331,7 @@ def parse_vlan_brief(module, vlan_id): p = port.strip().split(" to ") pr = int(p[1].split('/')[2]) - int(p[0].split('/')[2]) for i in range(0, pr + 1): - tagged_ports.append( - p[0][0:4] + str(int(p[0].split('/')[2]) + i)) + tagged_ports.append(p[0][0:4] + str(int(p[0].split('/')[2]) + i)) else: tagged_ports.append(port.strip()) for lag in lags: @@ -346,8 +352,7 @@ def parse_vlan_brief(module, vlan_id): p = port.strip().split(" to ") pr = int(p[1].split('/')[2]) - int(p[0].split('/')[2]) for i in range(0, pr + 1): - untagged_ports.append( - p[0][0:4] + str(int(p[0].split('/')[2]) + i)) + untagged_ports.append(p[0][0:4] + str(int(p[0].split('/')[2]) + i)) else: untagged_ports.append(port.strip()) for lag in lags: @@ -365,8 +370,7 @@ def parse_vlan_brief(module, vlan_id): def extract_list_from_interface(interface): if 'ethernet' in interface: if 'to' in interface: - s = re.search( - r"\d+\/\d+/(?P\d+)\sto\s+\d+\/\d+/(?P\d+)", interface) + s = re.search(r"\d+\/\d+/(?P\d+)\sto\s+\d+\/\d+/(?P\d+)", interface) low = int(s.group('low')) high = int(s.group('high')) else: @@ -417,8 +421,7 @@ def spanning_tree(module, stp): if stp.get('priority') and stp.get('type') == 'rstp': module.fail_json(msg='spanning-tree 802-1w only can have priority') elif stp.get('priority'): - stp_cmd.append('spanning-tree' + ' ' + stp.get('type') + - ' ' + 'priority' + ' ' + stp.get('priority')) + stp_cmd.append('spanning-tree' + ' ' + stp.get('type') + ' ' + 'priority' + ' ' + stp.get('priority')) return stp_cmd @@ -503,18 +506,14 @@ def map_obj_to_commands(updates, module): commands.append('tagged {0}'.format(item)) if dhcp is True: - commands.append( - 'ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: - commands.append( - 'no ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) if arp is True: - commands.append( - 'ip arp inspection vlan {0}'.format(vlan_id)) + commands.append('ip arp inspection vlan {0}'.format(vlan_id)) elif dhcp is False: - commands.append( - 'no ip arp inspection vlan {0}'.format(vlan_id)) + commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) if stp: if w.get('stp'): @@ -524,8 +523,7 @@ def map_obj_to_commands(updates, module): commands.append('vlan {0}'.format(vlan_id)) if name: if name != obj_in_have['name']: - commands.append( - 'vlan {0} name {1}'.format(vlan_id, name)) + commands.append('vlan {0} name {1}'.format(vlan_id, name)) if interfaces: if interfaces['name']: @@ -535,22 +533,20 @@ def map_obj_to_commands(updates, module): while(high >= low): if 'ethernet' in interface: - have_interfaces.append('ethernet ' + interface.split(" ")[1].split( - "/")[0] + '/' + interface.split(" ")[1].split("/")[1] + '/{0}'.format(low)) - if 'lag' in interface: have_interfaces.append( - 'lag {0}'.format(low)) + 'ethernet ' + interface.split(" ")[1].split("/")[0] + '/' + interface.split(" ")[1].split("/")[1] + '/{0}'.format(low) + ) + if 'lag' in interface: + have_interfaces.append('lag {0}'.format(low)) low = low + 1 if interfaces['purge'] is True: - remove_interfaces = list( - set(obj_in_have['interfaces']) - set(have_interfaces)) + remove_interfaces = list(set(obj_in_have['interfaces']) - set(have_interfaces)) for item in remove_interfaces: commands.append('no untagged {0}'.format(item)) if interfaces['name']: - add_interfaces = list( - set(have_interfaces) - set(obj_in_have['interfaces'])) + add_interfaces = list(set(have_interfaces) - set(obj_in_have['interfaces'])) for item in add_interfaces: commands.append('untagged {0}'.format(item)) @@ -562,38 +558,33 @@ def map_obj_to_commands(updates, module): while(high >= low): if 'ethernet' in tag: - have_tagged.append('ethernet ' + tag.split(" ")[1].split( - "/")[0] + '/' + tag.split(" ")[1].split("/")[1] + '/{0}'.format(low)) + have_tagged.append( + 'ethernet ' + tag.split(" ")[1].split("/")[0] + '/' + tag.split(" ")[1].split("/")[1] + '/{0}'.format(low) + ) if 'lag' in tag: have_tagged.append('lag {0}'.format(low)) low = low + 1 if tagged['purge'] is True: - remove_tagged = list( - set(obj_in_have['tagged']) - set(have_tagged)) + remove_tagged = list(set(obj_in_have['tagged']) - set(have_tagged)) for item in remove_tagged: commands.append('no tagged {0}'.format(item)) if tagged['name']: - add_tagged = list( - set(have_tagged) - set(obj_in_have['tagged'])) + add_tagged = list(set(have_tagged) - set(obj_in_have['tagged'])) for item in add_tagged: commands.append('tagged {0}'.format(item)) if dhcp != obj_in_have['ip_dhcp_snooping']: if dhcp is True: - commands.append( - 'ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append('ip dhcp snooping vlan {0}'.format(vlan_id)) elif dhcp is False: - commands.append( - 'no ip dhcp snooping vlan {0}'.format(vlan_id)) + commands.append('no ip dhcp snooping vlan {0}'.format(vlan_id)) if arp != obj_in_have['ip_arp_inspection']: if arp is True: - commands.append( - 'ip arp inspection vlan {0}'.format(vlan_id)) + commands.append('ip arp inspection vlan {0}'.format(vlan_id)) elif arp is False: - commands.append( - 'no ip arp inspection vlan {0}'.format(vlan_id)) + commands.append('no ip arp inspection vlan {0}'.format(vlan_id)) if stp: if w.get('stp'): @@ -622,8 +613,7 @@ def parse_name_argument(module, item): def parse_interfaces_argument(module, item, port_type): - untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief( - module, item) + untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief(module, item) ports = list() if port_type == "interfaces": if untagged_ports: @@ -688,12 +678,10 @@ def parse_ports(interfaces, ports, lags): while(high >= low): if 'ethernet' in interface: if not (low in ports): - module.fail_json( - msg='One or more conditional statements have not been satisfied ' + interface) + module.fail_json(msg='One or more conditional statements have not been satisfied ' + interface) if 'lag' in interface: if not (low in lags): - module.fail_json( - msg='One or more conditional statements have not been satisfied ' + interface) + module.fail_json(msg='One or more conditional statements have not been satisfied ' + interface) low = low + 1 is_delay = False @@ -707,12 +695,10 @@ def parse_ports(interfaces, ports, lags): sleep(module.params['delay']) is_delay = True - untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief( - module, w['vlan_id']) + untagged_ports, untagged_lags, tagged_ports, tagged_lags = parse_vlan_brief(module, w['vlan_id']) if w['associated_interfaces']: - parse_ports(w.get('associated_interfaces'), - untagged_ports, untagged_lags) + parse_ports(w.get('associated_interfaces'), untagged_ports, untagged_lags) if w['associated_tagged']: parse_ports(w.get('associated_tagged'), tagged_ports, tagged_lags) @@ -746,8 +732,7 @@ def main(): delay=dict(default=10, type='int'), stp=dict(type='dict', options=stp_spec), state=dict(default='present', choices=['present', 'absent']), - check_running_config=dict(default=True, type='bool', fallback=( - env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG'])) + check_running_config=dict(default=True, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG'])) ) aggregate_spec = deepcopy(element_spec) aggregate_spec['vlan_id'] = dict(required=True)