Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting rid of Ignores for sanity tests #62

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/remove_ignores_for_sanity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Makes sure that docstring and argspec are in sync and removes sanity ignores (https://github.com/ansible-collections/cisco.iosxr/pull/62).
11 changes: 8 additions & 3 deletions plugins/doc_fragments/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ class ModuleDocFragment(object):
over the specified transport. The value of host is used as the destination
address for the transport.
type: str
required: true
port:
description:
- Specifies the port to use when building the connection to the remote device.
type: int
default: 22
username:
description:
- Configures the username to use to authenticate the connection to the remote
Expand All @@ -52,14 +50,21 @@ class ModuleDocFragment(object):
for either connecting or sending commands. If the timeout is exceeded before
the operation is completed, the module will error.
type: int
default: 10
ssh_keyfile:
description:
- Specifies the SSH key to use to authenticate the connection to the remote
device. This value is the path to the key used to authenticate the SSH
session. If the value is not specified in the task, the value of environment
variable C(ANSIBLE_NET_SSH_KEYFILE) will be used instead.
type: path
transport:
description:
- Specifies the type of connection based transport.
type: str
default: cli
choices:
- cli
- netconf
notes:
- For more information on using Ansible to manage network devices see the :ref:`Ansible
Network Guide <network_guide>`
Expand Down
6 changes: 4 additions & 2 deletions plugins/module_utils/network/iosxr/argspec/facts/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self, **kwargs):
pass

argument_spec = {
"gather_subset": dict(default=["!config"], type="list"),
"gather_network_resources": dict(type="list"),
"gather_subset": dict(
default=["!config"], type="list", elements="str"
),
"gather_network_resources": dict(type="list", elements="str"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, **kwargs):
"native_vlan": {"type": "int"},
"l2transport": {"type": "bool"},
"l2protocol": {
"element": "dict",
"elements": "dict",
"type": "list",
"options": {
"cdp": {
Expand All @@ -63,7 +63,7 @@ def __init__(self, **kwargs):
},
},
},
"q_vlan": {"type": "list"},
"q_vlan": {"type": "list", "elements": "int"},
"propagate": {"type": "bool"},
},
"type": "list",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def __init__(self, **kwargs):
"options": {
"name": {"type": "str", "required": True},
"ipv4": {
"element": "dict",
"elements": "dict",
"type": "list",
"options": {
"address": {"type": "str"},
"secondary": {"type": "bool"},
},
},
"ipv6": {
"element": "dict",
"elements": "dict",
"type": "list",
"options": {"address": {"type": "str"}},
},
Expand Down
26 changes: 16 additions & 10 deletions plugins/module_utils/network/iosxr/argspec/ospfv2/ospfv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,22 @@ def __init__(self, **kwargs):
},
"type": "dict",
},
"bfd": {"type": "dict"},
"bfd": {
"options": {
"fast_detect": {
"options": {
"set": {"type": "bool"},
"strict_mode": {
"type": "bool"
},
},
"type": "dict",
},
"minimum_interval": {"type": "int"},
"multiplier": {"type": "int"},
},
"type": "dict",
},
"cost": {"type": "int"},
"dead_interval": {"type": "int"},
"default_cost": {"type": "int"},
Expand Down Expand Up @@ -447,15 +462,6 @@ def __init__(self, **kwargs):
"type": "str",
},
"max_lsa": {
"mutually_exclusive": [
[
"warning_only",
"ignore_count",
"reset_time",
"ignore_time",
"ignore_count",
]
],
"options": {
"ignore_count": {"type": "int"},
"ignore_time": {"type": "int"},
Expand Down
28 changes: 16 additions & 12 deletions plugins/module_utils/network/iosxr/config/interfaces/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ def _state_replaced(self, want, have):

for interface in want:
for each in have:
if each["name"] == interface["name"]:
break
elif interface["name"] in each["name"]:
if (
each["name"] == interface["name"]
or interface["name"] in each["name"]
):
break
else:
continue
Expand All @@ -192,9 +193,10 @@ def _state_overridden(self, want, have):

for each in have:
for interface in want:
if each["name"] == interface["name"]:
break
elif 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 @@ -224,9 +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"]:
break
elif interface["name"] in each["name"]:
if (
each["name"] == interface["name"]
or interface["name"] in each["name"]
):
break
else:
continue
Expand All @@ -245,9 +248,10 @@ def _state_deleted(self, want, have):
if want:
for interface in want:
for each in have:
if each["name"] == interface["name"]:
break
elif 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 @@ -195,7 +195,7 @@ def _state_overridden(self, want, have, module):
if each["name"] == interface["name"]:
in_have.add(interface["name"])
break
elif interface["name"] != each["name"]:
if interface["name"] != each["name"]:
not_in_have.add(interface["name"])
else:
# We didn't find a matching desired state, which means we can
Expand Down Expand Up @@ -229,9 +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"]:
break
elif 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 @@ -252,9 +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"]:
break
elif 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 @@ -200,7 +200,7 @@ def _state_overridden(self, want, have, module):
if each["name"] == interface["name"]:
in_have.add(interface["name"])
break
elif interface["name"] != each["name"]:
if interface["name"] != each["name"]:
not_in_have.add(interface["name"])
else:
# We didn't find a matching desired state, which means we can
Expand Down Expand Up @@ -260,9 +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"]:
break
elif interface["name"] in each["name"]:
if (
each["name"] == interface["name"]
or interface["name"] in each["name"]
):
break
else:
continue
Expand Down Expand Up @@ -297,7 +298,7 @@ def verify_diff_again(self, want, have):
):
diff = True
break
elif each_want.get("address") != every_have.get(
if each_want.get("address") != every_have.get(
"address"
) and len(each_want.keys()) == len(every_have.keys()):
diff = True
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/network/iosxr/facts/legacy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def parse_interfaces(self, data):
for line in data.split("\n"):
if len(line) == 0:
continue
elif line[0] == " ":
if line[0] == " ":
parsed[key] += "\n%s" % line
else:
match = re.match(r"^(\S+)", line)
Expand Down
5 changes: 4 additions & 1 deletion plugins/module_utils/network/iosxr/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@

iosxr_argument_spec = {
"provider": dict(
type="dict", options=iosxr_provider_spec, removed_in_version=2.14
type="dict",
options=iosxr_provider_spec,
removed_at_date="2022-06-01",
removed_from_collection="cisco.iosxr",
)
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/network/iosxr/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def filter_dict_having_none_value(want, have):
for k, v in iteritems(want):
if isinstance(v, dict):
for key, value in iteritems(v):
if value is None:
if value is None and k in have and key in have.get(k):
dict_val = have.get(k).get(key)
test_key_dict.update({key: dict_val})
test_dict.update({k: test_key_dict})
if isinstance(v, list) and isinstance(v[0], dict):
for key, value in iteritems(v[0]):
if value is None:
if value is None and k in have and key in have.get(k):
dict_val = have.get(k).get(key)
test_key_dict.update({key: dict_val})
test_dict.update({k: test_key_dict})
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/iosxr_banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@
description:
- Specifies the type of banner to configure on remote device.
required: true
type: str
choices:
- login
- motd
text:
description:
- Banner text to be configured. Accepts multiline string, without empty lines.
- Banner text to be configured. Accepts multi line string, without empty lines.
Requires I(state=present).
type: str
state:
description:
- Existential state of the configuration on the device.
default: present
type: str
choices:
- present
- absent
Expand Down Expand Up @@ -84,7 +87,6 @@
description: NetConf rpc xml sent to device with transport C(netconf)
returned: always (empty list when no xml rpc to send)
type: list
version_added: 2.5
sample:
- '<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
<banners xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-infra-cfg">
Expand Down
Loading