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 Feb 5, 2024
1 parent a053529 commit abeac64
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 48 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Name | Description
[cisco.iosxr.iosxr_static_routes](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_static_routes_module.rst)|Resource module to configure static routes.
[cisco.iosxr.iosxr_system](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_system_module.rst)|Module to manage the system attributes.
[cisco.iosxr.iosxr_user](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_user_module.rst)|Module to manage the aggregates of local users.
[cisco.iosxr.iosxr_vrfs](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_vrfs_module.rst)|Module to manage global VRF configuration.

<!--end collection content-->

Expand Down
26 changes: 13 additions & 13 deletions plugins/module_utils/network/iosxr/argspec/vrf/vrf.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 @@ -29,8 +30,7 @@


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

argument_spec = {
"config": {
Expand Down Expand Up @@ -70,16 +70,16 @@ class VrfArgs(object): # pylint: disable=R0903
"type": "dict",
"options": {
"route_policy": {
"type": "str"
}
"type": "str",
},
},
},
"vrf": {
"type": "dict",
"options": {
"allow_imported_vpn": {
"type": "bool"
}
"type": "bool",
},
},
},
},
Expand All @@ -98,24 +98,24 @@ class VrfArgs(object): # pylint: disable=R0903
"type": "dict",
"options": {
"advertise_as_vpn": {
"type": "bool"
}
"type": "bool",
},
},
},
"default_vrf": {
"type": "dict",
"options": {
"route_policy": {
"type": "str"
}
"type": "str",
},
},
},
"vrf": {
"type": "dict",
"options": {
"advertise_as_vpn": {
"type": "bool"
}
"type": "bool",
},
},
},
},
Expand Down Expand Up @@ -150,7 +150,7 @@ class VrfArgs(object): # pylint: disable=R0903
"options": {"id": {"type": "int"}},
},
},
}
},
},
},
"running_config": {"type": "str"},
Expand Down
27 changes: 12 additions & 15 deletions plugins/module_utils/network/iosxr/config/vrf/vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

"""
Expand All @@ -19,15 +20,14 @@
from copy import deepcopy

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.iosxr.plugins.module_utils.network.iosxr.facts.facts import (
Facts,
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
dict_merge,
)

from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.facts import Facts
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.rm_templates.vrf import (
VrfTemplate,
)
Expand Down Expand Up @@ -66,11 +66,10 @@ def __init__(self, module):
"rd",
"remote_route_filtering_disable",
"vpn_id",

]

def execute_module(self):
""" Execute the module
"""Execute the module
:rtype: A dictionary
:returns: The result from module execution
Expand All @@ -81,8 +80,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 All @@ -95,9 +94,7 @@ def generate_commands(self):

# if state is deleted, empty out wantd and set haved to wantd
if self.state == "deleted":
haved = {
k: v for k, v in iteritems(haved) if k in wantd or not wantd
}
haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd}
wantd = {}

# remove superfluous config for overridden and deleted
Expand All @@ -111,9 +108,9 @@ def generate_commands(self):

def _compare(self, want, have):
"""Leverages the base class `compare()` method and
populates the list of commands to be run by comparing
the `want` and `have` data with the `parsers` defined
for the Vrf network resource.
populates the list of commands to be run by comparing
the `want` and `have` data with the `parsers` defined
for the Vrf network resource.
"""
self.compare(parsers=self.parsers, want=want, have=have)
if self.commands and "vrf" not in self.commands[0]:
Expand Down
1 change: 0 additions & 1 deletion plugins/module_utils/network/iosxr/facts/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.static_routes.static_routes import (
Static_routesFacts,
)

from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.vrf.vrf import (
VrfFacts,
)
Expand Down
20 changes: 10 additions & 10 deletions plugins/module_utils/network/iosxr/facts/vrf/vrf.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 @@ -17,24 +18,23 @@
from copy import deepcopy

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.iosxr.plugins.module_utils.network.iosxr.argspec.vrf.vrf import (
VrfArgs,
)
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.rm_templates.vrf import (
VrfTemplate,
)
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.vrf.vrf import (
VrfArgs,
)
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.utils.utils import (
flatten_config,
)


class VrfFacts(object):
""" The iosxr vrf facts class"""
"""The iosxr vrf facts class"""

def __init__(self, module, subspec='config', options='options'):
def __init__(self, module, subspec="config", options="options"):
self._module = module
self.argument_spec = VrfArgs.argument_spec
spec = deepcopy(self.argument_spec)
Expand All @@ -52,7 +52,7 @@ def get_config(self, connection):
return connection.get("show running-config vrf")

def populate_facts(self, connection, ansible_facts, data=None):
""" Populate the facts for Vrf network resource
"""Populate the facts for Vrf network resource
:param connection: the device connection
:param ansible_facts: Facts dictionary
:param data: previously collected conf
Expand Down Expand Up @@ -82,14 +82,14 @@ def populate_facts(self, connection, ansible_facts, data=None):
else:
vrf["address_families"] = []

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

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

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

return ansible_facts

Expand Down
19 changes: 13 additions & 6 deletions plugins/module_utils/network/iosxr/rm_templates/vrf.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 @@ -36,7 +38,8 @@ def __init__(self, lines=None, module=None):
r"""
^vrf\s(?P<name>\S+)
\s+description\s(?P<description>.+$)
$""", re.VERBOSE),
$""", re.VERBOSE,
),
"setval": "vrf {{ name }} description {{ description }}",
"result": {
'{{ name }}': {
Expand Down Expand Up @@ -126,7 +129,8 @@ def __init__(self, lines=None, module=None):
^vrf\s(?P<name>\S+)
(?P<address_families>\s+address-family\s(?P<afi>\S+)\s(?P<safi>\S+))
\s+export\sto\sdefault-vrf\sroute-policy\s(?P<export_to_default_vrf_route_policy>\S+)
$""", re.VERBOSE),
$""", re.VERBOSE,
),
"setval": "vrf {{ name }} export to default-vrf route-policy {{ export to default-vrf route_policy }}",
"compval": "default_vrf",
"result": {
Expand Down Expand Up @@ -267,7 +271,8 @@ def __init__(self, lines=None, module=None):
^vrf\s(?P<name>\S+)
(?P<address_families>\s+address-family\s(?P<afi>\S+)\s(?P<safi>\S+))
\s+import\sfrom\sdefault-vrf\sroute-policy\s(?P<import_from_default_vrf_route_policy>\S+)
$""", re.VERBOSE),
$""", re.VERBOSE,
),
"setval": "vrf {{ name }} import from default-vrf route-policy {{ import from default-vrf route_policy }}",
"compval": "default_vrf",
"result": {
Expand Down Expand Up @@ -377,7 +382,8 @@ def __init__(self, lines=None, module=None):
r"""
^vrf\s(?P<name>\S+)
\s+evpn-route-sync\s(?P<evpn_route_sync>\d+)
$""", re.VERBOSE),
$""", re.VERBOSE,
),
"setval": "vrf {{ name }} evpn-route-sync {{ evpn_route_sync }}",
"result": {
'{{ name }}': {
Expand All @@ -392,7 +398,8 @@ def __init__(self, lines=None, module=None):
r"""
^vrf\s(?P<name>\S+)
\s+fallback-vrf\s\"(?P<fallback_vrf>\S+)\"
$""", re.VERBOSE),
$""", re.VERBOSE,
),
"setval": "vrf {{ name }} fallback-vrf {{ fallback_vrf }}",
"result": {
'{{ name }}': {
Expand Down Expand Up @@ -472,7 +479,7 @@ def __init__(self, lines=None, module=None):
'name': '{{ name }}',
"vpn": {
"id": "{{ id }}",
}
},
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/iosxr_vrf.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 @@ -209,12 +210,11 @@
"""

from ansible.module_utils.basic import AnsibleModule

from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.vrf.vrf import (
VrfArgs,
)
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.vrf.vrf import (
Vrf,
)
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.vrf.vrf import Vrf


def main():
Expand Down

0 comments on commit abeac64

Please sign in to comment.