Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Thakur <rohitthakur2590@outlook.com>
  • Loading branch information
rohitthakur2590 committed Jul 15, 2020
1 parent 26b7f55 commit 87f956f
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 24 deletions.
4 changes: 3 additions & 1 deletion plugins/module_utils/network/iosxr/argspec/ospfv2/ospfv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def __init__(self, **kwargs):
"fast_detect": {
"options": {
"set": {"type": "bool"},
"strict_mode": {"type": "bool"},
"strict_mode": {
"type": "bool"
},
},
"type": "dict",
},
Expand Down
20 changes: 16 additions & 4 deletions plugins/module_utils/network/iosxr/config/interfaces/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/module_utils/network/iosxr/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 16 additions & 13 deletions plugins/modules/iosxr_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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(),
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/iosxr_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion plugins/modules/iosxr_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
8 changes: 6 additions & 2 deletions plugins/modules/iosxr_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions tests/sanity/ignore-2.10.txt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 87f956f

Please sign in to comment.