From abeac64e15e2cb9a252db1045c834ea52601977c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:40:40 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 1 + .../network/iosxr/argspec/vrf/vrf.py | 26 +++++++++--------- .../network/iosxr/config/vrf/vrf.py | 27 +++++++++---------- .../module_utils/network/iosxr/facts/facts.py | 1 - .../network/iosxr/facts/vrf/vrf.py | 20 +++++++------- .../network/iosxr/rm_templates/vrf.py | 19 ++++++++----- plugins/modules/iosxr_vrf.py | 6 ++--- 7 files changed, 52 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index d95ac05f..71ffd40f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/plugins/module_utils/network/iosxr/argspec/vrf/vrf.py b/plugins/module_utils/network/iosxr/argspec/vrf/vrf.py index 5da9d9cd..5b37ba8d 100644 --- a/plugins/module_utils/network/iosxr/argspec/vrf/vrf.py +++ b/plugins/module_utils/network/iosxr/argspec/vrf/vrf.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -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": { @@ -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", + }, }, }, }, @@ -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", + }, }, }, }, @@ -150,7 +150,7 @@ class VrfArgs(object): # pylint: disable=R0903 "options": {"id": {"type": "int"}}, }, }, - } + }, }, }, "running_config": {"type": "str"}, diff --git a/plugins/module_utils/network/iosxr/config/vrf/vrf.py b/plugins/module_utils/network/iosxr/config/vrf/vrf.py index 7356a2c0..2be3dd61 100644 --- a/plugins/module_utils/network/iosxr/config/vrf/vrf.py +++ b/plugins/module_utils/network/iosxr/config/vrf/vrf.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -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, ) @@ -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 @@ -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 @@ -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 @@ -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]: diff --git a/plugins/module_utils/network/iosxr/facts/facts.py b/plugins/module_utils/network/iosxr/facts/facts.py index a7ae820d..59378c1e 100644 --- a/plugins/module_utils/network/iosxr/facts/facts.py +++ b/plugins/module_utils/network/iosxr/facts/facts.py @@ -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, ) diff --git a/plugins/module_utils/network/iosxr/facts/vrf/vrf.py b/plugins/module_utils/network/iosxr/facts/vrf/vrf.py index 19dafe4c..5f896de2 100644 --- a/plugins/module_utils/network/iosxr/facts/vrf/vrf.py +++ b/plugins/module_utils/network/iosxr/facts/vrf/vrf.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -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) @@ -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 @@ -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 diff --git a/plugins/module_utils/network/iosxr/rm_templates/vrf.py b/plugins/module_utils/network/iosxr/rm_templates/vrf.py index 6cd19d7c..13d3b115 100644 --- a/plugins/module_utils/network/iosxr/rm_templates/vrf.py +++ b/plugins/module_utils/network/iosxr/rm_templates/vrf.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) @@ -36,7 +38,8 @@ def __init__(self, lines=None, module=None): r""" ^vrf\s(?P\S+) \s+description\s(?P.+$) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "vrf {{ name }} description {{ description }}", "result": { '{{ name }}': { @@ -126,7 +129,8 @@ def __init__(self, lines=None, module=None): ^vrf\s(?P\S+) (?P\s+address-family\s(?P\S+)\s(?P\S+)) \s+export\sto\sdefault-vrf\sroute-policy\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "vrf {{ name }} export to default-vrf route-policy {{ export to default-vrf route_policy }}", "compval": "default_vrf", "result": { @@ -267,7 +271,8 @@ def __init__(self, lines=None, module=None): ^vrf\s(?P\S+) (?P\s+address-family\s(?P\S+)\s(?P\S+)) \s+import\sfrom\sdefault-vrf\sroute-policy\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "vrf {{ name }} import from default-vrf route-policy {{ import from default-vrf route_policy }}", "compval": "default_vrf", "result": { @@ -377,7 +382,8 @@ def __init__(self, lines=None, module=None): r""" ^vrf\s(?P\S+) \s+evpn-route-sync\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "vrf {{ name }} evpn-route-sync {{ evpn_route_sync }}", "result": { '{{ name }}': { @@ -392,7 +398,8 @@ def __init__(self, lines=None, module=None): r""" ^vrf\s(?P\S+) \s+fallback-vrf\s\"(?P\S+)\" - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "vrf {{ name }} fallback-vrf {{ fallback_vrf }}", "result": { '{{ name }}': { @@ -472,7 +479,7 @@ def __init__(self, lines=None, module=None): 'name': '{{ name }}', "vpn": { "id": "{{ id }}", - } + }, }, }, }, diff --git a/plugins/modules/iosxr_vrf.py b/plugins/modules/iosxr_vrf.py index 822c84b7..898b97b6 100644 --- a/plugins/modules/iosxr_vrf.py +++ b/plugins/modules/iosxr_vrf.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -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():