Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 2, 2024
1 parent 7aae164 commit a5c85b0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Name | Description
[cisco.ios.ios_user](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_user_module.rst)|Module to manage the aggregates of local users.
[cisco.ios.ios_vlans](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vlans_module.rst)|Resource module to configure VLANs.
[cisco.ios.ios_vrf](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_module.rst)|Module to configure VRF definitions.
[cisco.ios.ios_vrf_global](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_global_module.rst)|Resource module to configure VRF definitions.
[cisco.ios.ios_vxlan_vtep](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vxlan_vtep_module.rst)|Resource module to configure VXLAN VTEP interface.

<!--end collection content-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

#############################################
Expand All @@ -29,8 +30,7 @@


class Vrf_globalArgs(object): # pylint: disable=R0903
"""The arg spec for the ios_vrf_global module
"""
"""The arg spec for the ios_vrf_global module"""

argument_spec = {
"config": {
Expand All @@ -48,7 +48,7 @@ class Vrf_globalArgs(object): # pylint: disable=R0903
"multicast": {
"type": "dict",
"options": {"multitopology": {"type": "bool"}},
}
},
},
},
"ipv6": {
Expand All @@ -57,7 +57,7 @@ class Vrf_globalArgs(object): # pylint: disable=R0903
"multicast": {
"type": "dict",
"options": {"multitopology": {"type": "bool"}},
}
},
},
},
"rd": {"type": "str"},
Expand All @@ -78,7 +78,7 @@ class Vrf_globalArgs(object): # pylint: disable=R0903
"options": {"id": {"type": "str"}},
},
},
}
},
},
},
"running_config": {"type": "str"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
created.
"""
import q

from ansible.module_utils.six import iteritems
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import (
ResourceModule,
Expand Down
7 changes: 4 additions & 3 deletions plugins/module_utils/network/ios/facts/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.vlans.vlans import (
VlansFacts,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.vxlan_vtep.vxlan_vtep import (
Vxlan_vtepFacts,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.vrf_global.vrf_global import (
Vrf_globalFacts,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.vxlan_vtep.vxlan_vtep import (
Vxlan_vtepFacts,
)


FACT_LEGACY_SUBSETS = dict(
default=Default,
Expand Down
31 changes: 15 additions & 16 deletions plugins/module_utils/network/ios/facts/vrf_global/vrf_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

"""
Expand All @@ -14,22 +15,20 @@
based on the configuration.
"""

from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils

from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.vrf_global.vrf_global import (
Vrf_globalArgs,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.rm_templates.vrf_global import (
Vrf_globalTemplate,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.vrf_global.vrf_global import (
Vrf_globalArgs,
)


class Vrf_globalFacts(object):
""" The ios vrf_global facts class
"""
"""The ios vrf_global facts class"""

def __init__(self, module, subspec='config', options='options'):
def __init__(self, module, subspec="config", options="options"):
self._module = module
self.argument_spec = Vrf_globalArgs.argument_spec

Expand All @@ -51,7 +50,7 @@ def dict_to_list(self, vrf_data):
return facts_output

def populate_facts(self, connection, ansible_facts, data=None):
""" Populate the facts for Vrf_global network resource
"""Populate the facts for Vrf_global network resource
:param connection: the device connection
:param ansible_facts: Facts dictionary
Expand All @@ -71,18 +70,18 @@ def populate_facts(self, connection, ansible_facts, data=None):
objs = vrf_global_parser.parse()

# Convert the dictionary to a list of dictionaries
objs["vrfs"] = (
objs["vrfs"].values() if "vrfs" in objs else []
)
objs["vrfs"] = objs["vrfs"].values() if "vrfs" in objs else []

facts_output = self.dict_to_list(objs)

ansible_facts['ansible_network_resources'].pop('vrf_global', None)
ansible_facts["ansible_network_resources"].pop("vrf_global", None)

if objs["vrfs"]:
params = vrf_global_parser.validate_config(self.argument_spec, {"config": facts_output}, redact=True)
params = vrf_global_parser.validate_config(
self.argument_spec, {"config": facts_output}, redact=True
)
params = utils.remove_empties(params)
facts['vrf_global'] = params["config"]
ansible_facts['ansible_network_resources'].update(facts)
facts["vrf_global"] = params["config"]
ansible_facts["ansible_network_resources"].update(facts)

return ansible_facts
4 changes: 3 additions & 1 deletion plugins/module_utils/network/ios/rm_templates/vrf_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

"""
Expand All @@ -15,6 +16,7 @@
"""

import re

from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import (
NetworkTemplate,
)
Expand All @@ -25,7 +27,7 @@ def __init__(self, lines=None, module=None):
super(Vrf_globalTemplate, self).__init__(
lines=lines,
tmplt=self,
module=module
module=module,
)

# fmt: off
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/ios_vrf_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

DOCUMENTATION = """
Expand Down Expand Up @@ -174,6 +175,7 @@
"""

from ansible.module_utils.basic import AnsibleModule

from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.vrf_global.vrf_global import (
Vrf_globalArgs,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ vrf definition test
route-target export 23.1.3.4:400
route-target import 123.3.4.5:700
!
end
end
3 changes: 2 additions & 1 deletion tests/unit/modules/network/ios/test_ios_vrf_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class TestIosVrfGlobalModule(TestIosModule):
"""Test the ios_vrf_global module."""

module = ios_vrf_global

def setUp(self):
Expand Down Expand Up @@ -362,6 +363,6 @@ def test_ios_vrf_global_parsed(self):
"route_target": {"export": "23.1.3.4:400", "import_config": "123.3.4.5:700"},
"vnet": {"tag": 34},
"vpn": {"id": "3:4"},
}
},
]
self.assertEqual(parsed_list, result["parsed"])

0 comments on commit a5c85b0

Please sign in to comment.