From c11d144302cf91f2a93a2778407ea258ca5fa3a7 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Sat, 17 Aug 2019 13:08:53 -0400 Subject: [PATCH] Remove unused imports / variables for junos (#60705) * Remove unused imports / variables for junos This is to help with the migration to collections. Signed-off-by: Paul Belanger * Remove duplicate execute_module() function for junos lacp_interfaces This seems to have passed lint checks, but something we caught in collection migration. Signed-off-by: Paul Belanger --- .../config/lacp_interfaces/lacp_interfaces.py | 28 +------------------ .../config/lag_interfaces/lag_interfaces.py | 2 +- .../junos/config/lldp_global/lldp_global.py | 2 +- .../config/lldp_interfaces/lldp_interfaces.py | 2 +- .../modules/network/junos/junos_command.py | 2 +- .../modules/network/junos/junos_netconf.py | 1 - .../modules/network/junos/junos_package.py | 2 +- .../network/junos/test_junos_netconf.py | 4 --- 8 files changed, 6 insertions(+), 37 deletions(-) diff --git a/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py b/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py index 8ac50a6c884..00d0a8af266 100644 --- a/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py @@ -14,7 +14,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.network.common.cfg.base import ConfigBase -from ansible.module_utils.network.common.utils import to_list, get_xml_conf_arg +from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.network.junos.facts.facts import Facts from ansible.module_utils.network.junos.junos import locked_config, load_config, commit_configuration, discard_changes, tostring from ansible.module_utils.network.common.netconf import build_root_xml_node, build_child_xml_node, build_subtree @@ -48,32 +48,6 @@ class Lacp_interfaces(ConfigBase): return [] return lacp_interfaces_facts - def execute_module(self): - """ Execute the module - :rtype: A dictionary - :returns: The result from module execution - """ - result = {'changed': False} - commands = list() - warnings = list() - - existing_lacp_interfaces_facts = self.get_lacp_interfaces_facts() - commands.extend(self.set_config(existing_lacp_interfaces_facts)) - if commands: - if not self._module.check_mode: - self._connection.edit_config(commands) - result['changed'] = True - result['commands'] = commands - - changed_lacp_interfaces_facts = self.get_lacp_interfaces_facts() - - result['before'] = existing_lacp_interfaces_facts - if result['changed']: - result['after'] = changed_lacp_interfaces_facts - - result['warnings'] = warnings - return result - def execute_module(self): """ Execute the module :rtype: A dictionary diff --git a/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py b/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py index e9eaa754c1c..0025175003c 100644 --- a/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py @@ -14,7 +14,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.network.common.cfg.base import ConfigBase -from ansible.module_utils.network.common.utils import to_list, get_xml_conf_arg +from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.network.junos.facts.facts import Facts from ansible.module_utils.network.junos.junos import locked_config, load_config, commit_configuration, discard_changes, tostring from ansible.module_utils.network.common.netconf import build_root_xml_node, build_child_xml_node, build_subtree diff --git a/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py b/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py index 6cc3c1c3ccd..3b33a667284 100644 --- a/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py +++ b/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py @@ -17,7 +17,7 @@ from ansible.module_utils.network.common.cfg.base import ConfigBase from ansible.module_utils.network.junos.junos import locked_config, load_config, commit_configuration, discard_changes, tostring from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.network.junos.facts.facts import Facts -from ansible.module_utils.network.common.netconf import build_root_xml_node, build_child_xml_node, build_subtree +from ansible.module_utils.network.common.netconf import build_root_xml_node, build_child_xml_node class Lldp_global(ConfigBase): diff --git a/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py b/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py index d7b39133c5a..008788cb662 100644 --- a/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py @@ -14,7 +14,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.network.common.cfg.base import ConfigBase -from ansible.module_utils.network.common.utils import to_list, get_xml_conf_arg +from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.network.junos.facts.facts import Facts from ansible.module_utils.network.junos.junos import locked_config, load_config, commit_configuration, discard_changes, tostring from ansible.module_utils.network.common.netconf import build_root_xml_node, build_child_xml_node, build_subtree diff --git a/lib/ansible/modules/network/junos/junos_command.py b/lib/ansible/modules/network/junos/junos_command.py index b01287d6ae4..5f8bc2c5df2 100644 --- a/lib/ansible/modules/network/junos/junos_command.py +++ b/lib/ansible/modules/network/junos/junos_command.py @@ -169,7 +169,7 @@ from ansible.module_utils.network.common.netconf import exec_rpc from ansible.module_utils.network.junos.junos import junos_argument_spec, get_configuration, get_connection, get_capabilities, tostring from ansible.module_utils.network.common.parsing import Conditional, FailedConditionalError from ansible.module_utils.network.common.utils import to_lines -from ansible.module_utils.six import string_types, iteritems +from ansible.module_utils.six import iteritems try: diff --git a/lib/ansible/modules/network/junos/junos_netconf.py b/lib/ansible/modules/network/junos/junos_netconf.py index 011935041ec..0ce21e2275d 100644 --- a/lib/ansible/modules/network/junos/junos_netconf.py +++ b/lib/ansible/modules/network/junos/junos_netconf.py @@ -81,7 +81,6 @@ from ansible.module_utils._text import to_text from ansible.module_utils.connection import ConnectionError from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.junos.junos import junos_argument_spec, get_connection -from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes from ansible.module_utils.network.common.utils import to_list from ansible.module_utils.six import iteritems diff --git a/lib/ansible/modules/network/junos/junos_package.py b/lib/ansible/modules/network/junos/junos_package.py index 6b2b73f466c..38b5231c2ac 100644 --- a/lib/ansible/modules/network/junos/junos_package.py +++ b/lib/ansible/modules/network/junos/junos_package.py @@ -211,7 +211,7 @@ def main(): device = connect(module) if not module.params['force']: - facts = device.facts_refresh() + device.facts_refresh() has_ver = device.facts.get('version') wants_ver = module.params['version'] do_upgrade = has_ver != wants_ver diff --git a/test/units/modules/network/junos/test_junos_netconf.py b/test/units/modules/network/junos/test_junos_netconf.py index 228cf9febc3..4c71ca09c80 100644 --- a/test/units/modules/network/junos/test_junos_netconf.py +++ b/test/units/modules/network/junos/test_junos_netconf.py @@ -38,9 +38,6 @@ class TestJunosCommandModule(TestJunosModule): self.mock_unlock_configuration = patch('ansible.module_utils.network.junos.junos.unlock_configuration') self.unlock_configuration = self.mock_unlock_configuration.start() - self.mock_commit_configuration = patch('ansible.modules.network.junos.junos_netconf.commit_configuration') - self.commit_configuration = self.mock_commit_configuration.start() - self.mock_conn = patch('ansible.module_utils.connection.Connection') self.conn = self.mock_conn.start() @@ -58,7 +55,6 @@ class TestJunosCommandModule(TestJunosModule): super(TestJunosCommandModule, self).tearDown() self.mock_lock_configuration.stop() self.mock_unlock_configuration.stop() - self.mock_commit_configuration.stop() self.mock_conn.stop() self.mock_netconf.stop() self.mock_netconf_rpc.stop()