From b7ab8f9411267bed4eb4d5ba62698af47b2461df Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Wed, 11 Sep 2019 09:35:09 -0400 Subject: [PATCH] Clean up more linting errors for nxos modules (#62069) This removes a few unused variables and duplicate functions being defined. Signed-off-by: Paul Belanger --- .../module_utils/network/nxos/config/telemetry/telemetry.py | 5 ----- lib/ansible/module_utils/network/nxos/facts/lacp/lacp.py | 1 - lib/ansible/module_utils/network/nxos/facts/legacy/base.py | 5 ----- lib/ansible/module_utils/network/nxos/nxos.py | 2 -- lib/ansible/modules/network/nxos/_nxos_interface.py | 3 +-- lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py | 5 ----- lib/ansible/modules/network/nxos/nxos_gir.py | 1 - lib/ansible/modules/network/nxos/nxos_igmp.py | 1 - lib/ansible/modules/network/nxos/nxos_pim_interface.py | 2 -- lib/ansible/modules/network/nxos/nxos_ping.py | 1 - lib/ansible/modules/network/nxos/nxos_user.py | 1 - lib/ansible/modules/network/nxos/nxos_vrf_interface.py | 5 ----- lib/ansible/modules/network/nxos/nxos_vrrp.py | 2 -- lib/ansible/plugins/action/nxos_file_copy.py | 1 - 14 files changed, 1 insertion(+), 34 deletions(-) diff --git a/lib/ansible/module_utils/network/nxos/config/telemetry/telemetry.py b/lib/ansible/module_utils/network/nxos/config/telemetry/telemetry.py index 082b1723094..80991e42fb1 100644 --- a/lib/ansible/module_utils/network/nxos/config/telemetry/telemetry.py +++ b/lib/ansible/module_utils/network/nxos/config/telemetry/telemetry.py @@ -152,11 +152,6 @@ class Telemetry(ConfigBase): ref.get_playvals() device_cache = ref.cache_existing - if device_cache is None: - device_cache_lines = [] - else: - device_cache_lines = device_cache.split("\n") - # Get Telemetry Destination Group Data if want.get('destination_groups'): td = {'name': 'destination_groups', 'type': 'TMS_DESTGROUP', diff --git a/lib/ansible/module_utils/network/nxos/facts/lacp/lacp.py b/lib/ansible/module_utils/network/nxos/facts/lacp/lacp.py index 9c8ebf1cc5d..90524503db7 100644 --- a/lib/ansible/module_utils/network/nxos/facts/lacp/lacp.py +++ b/lib/ansible/module_utils/network/nxos/facts/lacp/lacp.py @@ -45,7 +45,6 @@ class LacpFacts(object): :rtype: dictionary :returns: facts """ - obj = [] if not data: data = connection.get("show running-config | include lacp") resources = data.strip() diff --git a/lib/ansible/module_utils/network/nxos/facts/legacy/base.py b/lib/ansible/module_utils/network/nxos/facts/legacy/base.py index 6a8c3038d59..4b61a29d0b4 100644 --- a/lib/ansible/module_utils/network/nxos/facts/legacy/base.py +++ b/lib/ansible/module_utils/network/nxos/facts/legacy/base.py @@ -76,11 +76,6 @@ class Default(FactsBase): if match: return match.group(1) - def parse_license_hostid(self, data): - match = re.search(r'License hostid: VDH=(.+)$', data, re.M) - if match: - return match.group(1) - def platform_facts(self): platform_facts = {} diff --git a/lib/ansible/module_utils/network/nxos/nxos.py b/lib/ansible/module_utils/network/nxos/nxos.py index 826de6a7c1b..a755665cccd 100644 --- a/lib/ansible/module_utils/network/nxos/nxos.py +++ b/lib/ansible/module_utils/network/nxos/nxos.py @@ -1116,8 +1116,6 @@ class NxosCmdRef: # Multiple Instances: if isinstance(existing, dict) and multiple: - item_found = False - for ekey, evalue in existing.items(): if isinstance(evalue, dict): # Remove values set to string 'None' from dvalue diff --git a/lib/ansible/modules/network/nxos/_nxos_interface.py b/lib/ansible/modules/network/nxos/_nxos_interface.py index 32a1d895f94..0461734eed2 100644 --- a/lib/ansible/modules/network/nxos/_nxos_interface.py +++ b/lib/ansible/modules/network/nxos/_nxos_interface.py @@ -316,7 +316,7 @@ def is_default_interface(name, module): try: body = execute_show_command(command, module)[0] - except (IndexError, TypeError) as e: + except (IndexError, TypeError): body = '' if body: @@ -535,7 +535,6 @@ def map_config_to_obj(want, module): obj['description'] = interface_table.get('desc') obj['mtu'] = interface_table.get('eth_mtu') obj['duplex'] = interface_table.get('eth_duplex') - speed = interface_table.get('eth_speed') command = 'show run interface {0}'.format(obj['name']) body = execute_show_command(command, module)[0] diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py index ae795520da3..32e285138a5 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py @@ -338,11 +338,6 @@ def get_custom_value(arg, config, module): splitted_config = config.splitlines() value = '' - command_re = re.compile(r'\s+{0}\s*'.format(command), re.M) - has_command = command_re.search(config) - command_val_re = re.compile(r'(?:{0}\s)(?P.*)$'.format(command), re.M) - has_command_val = command_val_re.search(config) - if arg.startswith('additional_paths'): value = 'inherit' for line in splitted_config: diff --git a/lib/ansible/modules/network/nxos/nxos_gir.py b/lib/ansible/modules/network/nxos/nxos_gir.py index 822c600138b..a2241b00e35 100644 --- a/lib/ansible/modules/network/nxos/nxos_gir.py +++ b/lib/ansible/modules/network/nxos/nxos_gir.py @@ -188,7 +188,6 @@ def get_reset_reasons(module): def get_commands(module, state, mode): commands = list() - system_mode = '' if module.params['system_mode_maintenance'] is True and mode == 'normal': commands.append('system mode maintenance') elif (module.params['system_mode_maintenance'] is False and diff --git a/lib/ansible/modules/network/nxos/nxos_igmp.py b/lib/ansible/modules/network/nxos/nxos_igmp.py index fc57b3f8e38..7837f5c80c8 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp.py @@ -121,7 +121,6 @@ def main(): desired = get_desired(module) state = module.params['state'] - restart = module.params['restart'] commands = list() diff --git a/lib/ansible/modules/network/nxos/nxos_pim_interface.py b/lib/ansible/modules/network/nxos/nxos_pim_interface.py index 3634d25a126..fdd5d08c2c5 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_pim_interface.py @@ -289,7 +289,6 @@ def get_pim_interface(module, interface): elif 'sparse-mode' in each: pim_interface['sparse'] = True elif 'bfd-instance' in each: - value = 'default' m = re.search(r'ip pim bfd-instance(?P disable)?', each) if m: pim_interface['bfd'] = 'disable' if m.group('disable') else 'enable' @@ -509,7 +508,6 @@ def main(): jp_policy_out = module.params['jp_policy_out'] neighbor_policy = module.params['neighbor_policy'] neighbor_type = module.params['neighbor_type'] - hello_interval = module.params['hello_interval'] intf_type = get_interface_type(interface) if get_interface_mode(interface, intf_type, module) == 'layer2': diff --git a/lib/ansible/modules/network/nxos/nxos_ping.py b/lib/ansible/modules/network/nxos/nxos_ping.py index d2340e6a5f6..26056f84246 100644 --- a/lib/ansible/modules/network/nxos/nxos_ping.py +++ b/lib/ansible/modules/network/nxos/nxos_ping.py @@ -192,7 +192,6 @@ def main(): check_args(module, warnings) destination = module.params['dest'] - count = module.params['count'] state = module.params['state'] ping_command = 'ping {0}'.format(destination) diff --git a/lib/ansible/modules/network/nxos/nxos_user.py b/lib/ansible/modules/network/nxos/nxos_user.py index b9628420bac..5c2cc0abcb2 100644 --- a/lib/ansible/modules/network/nxos/nxos_user.py +++ b/lib/ansible/modules/network/nxos/nxos_user.py @@ -160,7 +160,6 @@ def validate_roles(value, module): def map_obj_to_commands(updates, module): commands = list() - state = module.params['state'] update_password = module.params['update_password'] for update in updates: diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py index 65a4323a11c..4dcb3bc71bd 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py @@ -210,12 +210,9 @@ def main(): 'configuring a VRF on an interface. You can ' 'use nxos_interface') - proposed = dict(interface=interface, vrf=vrf) - current_vrf = get_interface_info(interface, module) existing = dict(interface=interface, vrf=current_vrf) changed = False - end_state = existing if not existing['vrf']: pass @@ -247,8 +244,6 @@ def main(): else: load_config(module, commands) changed = True - changed_vrf = get_interface_info(interface, module) - end_state = dict(interface=interface, vrf=changed_vrf) if 'configure' in commands: commands.pop(0) diff --git a/lib/ansible/modules/network/nxos/nxos_vrrp.py b/lib/ansible/modules/network/nxos/nxos_vrrp.py index a1f393a3ec9..4e7b9ac1428 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrrp.py +++ b/lib/ansible/modules/network/nxos/nxos_vrrp.py @@ -377,8 +377,6 @@ def main(): proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_existing_vrrp(interface, group, module, name) - changed = False - end_state = existing commands = [] if state == 'present': diff --git a/lib/ansible/plugins/action/nxos_file_copy.py b/lib/ansible/plugins/action/nxos_file_copy.py index 82fbfbd1acd..848f29ee7bf 100644 --- a/lib/ansible/plugins/action/nxos_file_copy.py +++ b/lib/ansible/plugins/action/nxos_file_copy.py @@ -191,7 +191,6 @@ class ActionModule(ActionBase): timeout = self.socket_timeout local_file = self.playvals['local_file'] file_system = self.playvals['file_system'] - file_size = os.path.getsize(local_file) if not self.enough_space(local_file, file_system): raise AnsibleError('Could not transfer file. Not enough space on device.')