From 87f956f464a6e2190af2da84ffbf79182d523048 Mon Sep 17 00:00:00 2001 From: Rohit Thakur Date: Wed, 15 Jul 2020 14:21:28 +0530 Subject: [PATCH] linter fixes Signed-off-by: Rohit Thakur --- .../network/iosxr/argspec/ospfv2/ospfv2.py | 4 ++- .../iosxr/config/interfaces/interfaces.py | 20 ++++++++++--- .../config/l2_interfaces/l2_interfaces.py | 10 +++++-- .../config/l3_interfaces/l3_interfaces.py | 5 +++- plugins/module_utils/network/iosxr/iosxr.py | 6 ++++ plugins/modules/iosxr_bgp.py | 29 ++++++++++--------- plugins/modules/iosxr_command.py | 4 +++ plugins/modules/iosxr_interface.py | 4 ++- plugins/modules/iosxr_user.py | 8 +++-- tests/sanity/ignore-2.10.txt | 5 ++++ tests/sanity/ignore-2.9.txt | 5 ++++ 11 files changed, 76 insertions(+), 24 deletions(-) create mode 100644 tests/sanity/ignore-2.10.txt create mode 100644 tests/sanity/ignore-2.9.txt diff --git a/plugins/module_utils/network/iosxr/argspec/ospfv2/ospfv2.py b/plugins/module_utils/network/iosxr/argspec/ospfv2/ospfv2.py index e2e7d053b..fb41a1e38 100644 --- a/plugins/module_utils/network/iosxr/argspec/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/iosxr/argspec/ospfv2/ospfv2.py @@ -104,7 +104,9 @@ def __init__(self, **kwargs): "fast_detect": { "options": { "set": {"type": "bool"}, - "strict_mode": {"type": "bool"}, + "strict_mode": { + "type": "bool" + }, }, "type": "dict", }, diff --git a/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py b/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py index 70921000f..ce3534b56 100644 --- a/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py @@ -167,7 +167,10 @@ def _state_replaced(self, want, have): for interface in want: for each in have: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: continue @@ -190,7 +193,10 @@ def _state_overridden(self, want, have): for each in have: for interface in want: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: # We didn't find a matching desired state, which means we can @@ -220,7 +226,10 @@ def _state_merged(self, want, have): commands.extend(self._set_config(interface, dict())) else: for each in have: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: continue @@ -239,7 +248,10 @@ def _state_deleted(self, want, have): if want: for interface in want: for each in have: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: continue diff --git a/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py index eb5108a5c..3002051e1 100644 --- a/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py @@ -229,7 +229,10 @@ def _state_merged(self, want, have, module): for interface in want: interface["name"] = normalize_interface(interface["name"]) for each in have: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: commands.extend(self._set_config(interface, {}, module)) @@ -250,7 +253,10 @@ def _state_deleted(self, want, have): for interface in want: interface["name"] = normalize_interface(interface["name"]) for each in have: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: continue diff --git a/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py index f31d122ca..8377e0150 100644 --- a/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py @@ -260,7 +260,10 @@ def _state_deleted(self, want, have): for interface in want: interface["name"] = normalize_interface(interface["name"]) for each in have: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + if ( + each["name"] == interface["name"] + or interface["name"] in each["name"] + ): break else: continue diff --git a/plugins/module_utils/network/iosxr/iosxr.py b/plugins/module_utils/network/iosxr/iosxr.py index 2d514cfc6..78e0544ff 100644 --- a/plugins/module_utils/network/iosxr/iosxr.py +++ b/plugins/module_utils/network/iosxr/iosxr.py @@ -122,6 +122,12 @@ ) } +command_spec = { + "command": dict(), + "prompt": dict(default=None), + "answer": dict(default=None), +} + CONFIG_MISPLACED_CHILDREN = [re.compile(r"^end-\s*(.+)$")] # Objects defined in Route-policy Language guide of IOS_XR. diff --git a/plugins/modules/iosxr_bgp.py b/plugins/modules/iosxr_bgp.py index 4fabe57ed..7f453ab67 100644 --- a/plugins/modules/iosxr_bgp.py +++ b/plugins/modules/iosxr_bgp.py @@ -270,9 +270,6 @@ from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.module import ( NetworkModule, ) -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.cli.config.bgp.process import ( - REDISTRIBUTE_PROTOCOLS, -) def main(): @@ -285,16 +282,22 @@ def main(): } redistribute_spec = { - "protocol": dict(type="str", choices=["ospf", - "ospfv3", - "eigrp", - "isis", - "static", - "connected", - "lisp", - "mobile", - "rip", - "subscriber"], required=True), + "protocol": dict( + type="str", + choices=[ + "ospf", + "ospfv3", + "eigrp", + "isis", + "static", + "connected", + "lisp", + "mobile", + "rip", + "subscriber", + ], + required=True, + ), "id": dict(), "metric": dict(type="int"), "route_map": dict(), diff --git a/plugins/modules/iosxr_command.py b/plugins/modules/iosxr_command.py index 425eab113..91f6df75b 100644 --- a/plugins/modules/iosxr_command.py +++ b/plugins/modules/iosxr_command.py @@ -131,6 +131,9 @@ run_commands, iosxr_argument_spec, ) +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.iosxr import ( + command_spec, +) def parse_commands(module, warnings): @@ -160,6 +163,7 @@ def main(): ) argument_spec.update(iosxr_argument_spec) + argument_spec.update(command_spec) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True diff --git a/plugins/modules/iosxr_interface.py b/plugins/modules/iosxr_interface.py index 753fe91e6..c1887b716 100644 --- a/plugins/modules/iosxr_interface.py +++ b/plugins/modules/iosxr_interface.py @@ -1001,7 +1001,9 @@ def main(): mtu=dict(), duplex=dict(choices=["full", "half"]), enabled=dict(default=True, type="bool"), - active=dict(type="str", choices=["active", "preconfigure"], default="active"), + active=dict( + type="str", choices=["active", "preconfigure"], default="active" + ), tx_rate=dict(), rx_rate=dict(), delay=dict(default=10, type="int"), diff --git a/plugins/modules/iosxr_user.py b/plugins/modules/iosxr_user.py index 6e4cedfd1..fb44f43d9 100644 --- a/plugins/modules/iosxr_user.py +++ b/plugins/modules/iosxr_user.py @@ -893,13 +893,17 @@ def main(): element_spec = dict( name=dict(type="str"), configured_password=dict(type="str", no_log=True), - update_password=dict(type="str", default="always", choices=["on_create", "always"]), + update_password=dict( + type="str", default="always", choices=["on_create", "always"] + ), admin=dict(type="bool", default=False), public_key=dict(type="str"), public_key_contents=dict(type="str"), group=dict(type="str", aliases=["role"]), groups=dict(type="list", elements="dict"), - state=dict(type="str", default="present", choices=["present", "absent"]), + state=dict( + type="str", default="present", choices=["present", "absent"] + ), ) aggregate_spec = deepcopy(element_spec) aggregate_spec["name"] = dict(required=True) diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt new file mode 100644 index 000000000..537afbf1b --- /dev/null +++ b/tests/sanity/ignore-2.10.txt @@ -0,0 +1,5 @@ +plugins/action/iosxr.py action-plugin-docs +plugins/modules/iosxr_command.py validate-modules:doc-missing-type +plugins/modules/iosxr_command.py validate-modules:undocumented-parameter +plugins/modules/iosxr_interface.py validate-modules:deprecation-mismatch +plugins/modules/iosxr_interface.py validate-modules:invalid-documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt new file mode 100644 index 000000000..537afbf1b --- /dev/null +++ b/tests/sanity/ignore-2.9.txt @@ -0,0 +1,5 @@ +plugins/action/iosxr.py action-plugin-docs +plugins/modules/iosxr_command.py validate-modules:doc-missing-type +plugins/modules/iosxr_command.py validate-modules:undocumented-parameter +plugins/modules/iosxr_interface.py validate-modules:deprecation-mismatch +plugins/modules/iosxr_interface.py validate-modules:invalid-documentation \ No newline at end of file