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 Dec 19, 2024
1 parent b9a2451 commit c38a8f7
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,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_address_family](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_address_family_module.rst)|Resource 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 global VRF definitions.
[cisco.ios.ios_vrf_interfaces](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_interfaces_module.rst)|Manages VRF configuration on interfaces.
[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.
Expand Down
2 changes: 1 addition & 1 deletion changelogs/fragments/add_vrf_address_family.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
minor_changes:
- Adds a new module `ios_vrf_address_family` to manage VRFs address families on Cisco IOS devices.
- Adds a new module `ios_vrf_address_family` to manage VRFs address families on Cisco IOS devices.
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_address_familyArgs(object): # pylint: disable=R0903
"""The arg spec for the ios_vrf_address_family module
"""
"""The arg spec for the ios_vrf_address_family module"""

argument_spec = {
"config": {
Expand All @@ -53,7 +53,7 @@ class Vrf_address_familyArgs(object): # pylint: disable=R0903
"next_hop": {
"type": "dict",
"options": {"loopback": {"type": "int"}},
}
},
},
},
"export": {
Expand Down Expand Up @@ -119,12 +119,12 @@ class Vrf_address_familyArgs(object): # pylint: disable=R0903
"reinstall": {
"type": "dict",
"options": {
"threshold": {"type": "int"}
"threshold": {"type": "int"},
},
},
"warning_only": {"type": "bool"},
},
}
},
},
},
"inter_as_hybrid": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

"""
Expand All @@ -18,15 +19,14 @@
"""

from ansible.module_utils.six import iteritems
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
dict_merge,
)
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import (
ResourceModule,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import (
Facts,
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
dict_merge,
)

from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import Facts
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.rm_templates.vrf_address_family import (
Vrf_address_familyTemplate,
)
Expand Down Expand Up @@ -59,7 +59,7 @@ def __init__(self, module):
]

def execute_module(self):
""" Execute the module
"""Execute the module
:rtype: A dictionary
:returns: The result from module execution
Expand All @@ -70,8 +70,8 @@ def execute_module(self):
return self.result

def generate_commands(self):
""" Generate configuration commands to send based on
want, have and desired state.
"""Generate configuration commands to send based on
want, have and desired state.
"""
wantd = self.want
haved = self.have
Expand Down
6 changes: 3 additions & 3 deletions plugins/module_utils/network/ios/facts/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
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.vrf_address_family.vrf_address_family import (
Vrf_address_familyFacts,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.vrf_global.vrf_global import (
Vrf_globalFacts,
)
Expand All @@ -108,9 +111,6 @@
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_address_family.vrf_address_family import (
Vrf_address_familyFacts,
)


FACT_LEGACY_SUBSETS = dict(
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 @@ -15,29 +16,28 @@
"""

# from ansible.module_utils.six import iteritems
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_address_family.vrf_address_family import (
Vrf_address_familyArgs,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.rm_templates.vrf_address_family import (
Vrf_address_familyTemplate,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.vrf_address_family.vrf_address_family import (
Vrf_address_familyArgs,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.utils.utils import (
flatten_config,
)


# import debugpy
# debugpy.listen(3000)
# debugpy.wait_for_client()


class Vrf_address_familyFacts(object):
""" The ios vrf_address_family facts class
"""
"""The ios vrf_address_family 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_address_familyArgs.argument_spec

Expand All @@ -47,7 +47,7 @@ def get_config(self, connection):
return connection.get("show running-config | section ^vrf")

def populate_facts(self, connection, ansible_facts, data=None):
""" Populate the facts for Vrf_address_family network resource
"""Populate the facts for Vrf_address_family network resource
:param connection: the device connection
:param ansible_facts: Facts dictionary
Expand All @@ -69,7 +69,9 @@ def populate_facts(self, connection, ansible_facts, data=None):
data = flatten_config(address_data, "vrf")

# parse native config using the Vrf_address_family template
vrf_address_family_parser = Vrf_address_familyTemplate(lines=data.splitlines(), module=self._module)
vrf_address_family_parser = Vrf_address_familyTemplate(
lines=data.splitlines(), module=self._module
)
obj = vrf_address_family_parser.parse()
objs = list(obj.values())

Expand All @@ -80,14 +82,16 @@ def populate_facts(self, connection, ansible_facts, data=None):
else:
vrf["address_families"] = []

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

params = utils.remove_empties(
vrf_address_family_parser.validate_config(self.argument_spec, {"config": objs}, redact=True)
vrf_address_family_parser.validate_config(
self.argument_spec, {"config": objs}, redact=True
),
)

facts['vrf_address_family'] = params.get("config", [])
ansible_facts['ansible_network_resources'].update(facts)
facts["vrf_address_family"] = params.get("config", [])
ansible_facts["ansible_network_resources"].update(facts)

return ansible_facts

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 @@ -15,10 +16,12 @@
"""

import re

from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import (
NetworkTemplate,
)


# UNIQUE_AFI = "{{ 'address_families_'+ afi + '_' + safi }}"


Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/ios_vrf_address_family.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 @@ -839,6 +840,7 @@
"""

from ansible.module_utils.basic import AnsibleModule

from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.vrf_address_family.vrf_address_family import (
Vrf_address_familyArgs,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ vrf definition test
export map "testing-map"
export ipv4 multicast 345 map "single"
export ipv4 unicast 67 map "test-map" allow-evpn
exit-address-family
exit-address-family
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
- import ipv4 unicast 12 map "ran-map" allow-evpn
- export map "testing-map"
- export ipv4 multicast 345 map "single"
- export ipv4 unicast 67 map "test-map" allow-evpn
- export ipv4 unicast 67 map "test-map" allow-evpn

0 comments on commit c38a8f7

Please sign in to comment.