diff options
| author | Nilashish Chakraborty <nilashishchakraborty8@gmail.com> | 2024-06-25 14:54:01 +0530 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-25 14:54:01 +0530 | 
| commit | b872b6f21d14ff10c221d84217eb568318e9ad8b (patch) | |
| tree | 0aacdea877a7e2b209735cd0f7c0b9d62a9446f7 /plugins | |
| parent | 37baff3d4d547911bec1387218edfd477ca79062 (diff) | |
| download | vyos.vyos-b872b6f21d14ff10c221d84217eb568318e9ad8b.tar.gz vyos.vyos-b872b6f21d14ff10c221d84217eb568318e9ad8b.zip | |
`vyos.vyos` is no longer deprecated! 🎉  (#348)
* Remove deprecation notice for vyos.vyos
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
* Add changelog
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
* fix review comments
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
* chore: auto fixes from pre-commit.com hooks
---------
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'plugins')
107 files changed, 2915 insertions, 2671 deletions
| diff --git a/plugins/action/vyos.py b/plugins/action/vyos.py index df8e7127..148d7c64 100644 --- a/plugins/action/vyos.py +++ b/plugins/action/vyos.py @@ -18,6 +18,7 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from ansible.utils.display import Display @@ -25,6 +26,7 @@ from ansible_collections.ansible.netcommon.plugins.action.network import (      ActionModule as ActionNetworkModule,  ) +  display = Display() diff --git a/plugins/cliconf/vyos.py b/plugins/cliconf/vyos.py index 4916d528..7e6b0b17 100644 --- a/plugins/cliconf/vyos.py +++ b/plugins/cliconf/vyos.py @@ -17,6 +17,7 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -85,7 +86,8 @@ class Cliconf(CliconfBase):              reply = self.get("show host name")              device_info["network_os_hostname"] = to_text( -                reply, errors="surrogate_or_strict" +                reply, +                errors="surrogate_or_strict",              ).strip()              self._device_info = device_info @@ -98,7 +100,7 @@ class Cliconf(CliconfBase):              if format not in option_values["format"]:                  raise ValueError(                      "'format' value %s is invalid. Valid values of format are %s" -                    % (format, ", ".join(option_values["format"])) +                    % (format, ", ".join(option_values["format"])),                  )          if not flags: @@ -213,7 +215,7 @@ class Cliconf(CliconfBase):          if diff_match not in option_values["diff_match"]:              raise ValueError(                  "'match' value %s in invalid, valid values are %s" -                % (diff_match, ", ".join(option_values["diff_match"])) +                % (diff_match, ", ".join(option_values["diff_match"])),              )          if diff_replace: diff --git a/plugins/doc_fragments/vyos.py b/plugins/doc_fragments/vyos.py index 698d0f5f..aaa7bf71 100644 --- a/plugins/doc_fragments/vyos.py +++ b/plugins/doc_fragments/vyos.py @@ -1,6 +1,7 @@  # -*- coding: utf-8 -*-  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  # Copyright: (c) 2015, Peter Sprygada <psprygada@ansible.com> diff --git a/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py index 8cbbc505..9868fc6b 100644 --- a/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py index da56aa9e..22af6394 100644 --- a/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/facts/facts.py b/plugins/module_utils/network/vyos/argspec/facts/facts.py index 45a4cb49..b274c507 100644 --- a/plugins/module_utils/network/vyos/argspec/facts/facts.py +++ b/plugins/module_utils/network/vyos/argspec/facts/facts.py @@ -6,6 +6,7 @@ The arg spec for the vyos facts module.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py index baafa899..2326bea1 100644 --- a/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py @@ -27,6 +27,7 @@ The arg spec for the vyos_firewall_global module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py b/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py index 16e66155..a613ccd3 100644 --- a/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py @@ -27,6 +27,7 @@ The arg spec for the vyos_firewall_interfaces module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py index 0e800310..eb285cfd 100644 --- a/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py @@ -27,6 +27,7 @@ The arg spec for the vyos_firewall_rules module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -182,7 +183,7 @@ class Firewall_rulesArgs(object):  # pylint: disable=R0903                                                  "kazaa",                                              ],                                              "type": "str", -                                        } +                                        },                                      },                                      "type": "list",                                  }, diff --git a/plugins/module_utils/network/vyos/argspec/hostname/hostname.py b/plugins/module_utils/network/vyos/argspec/hostname/hostname.py index 1a3cf91f..b69f2f10 100644 --- a/plugins/module_utils/network/vyos/argspec/hostname/hostname.py +++ b/plugins/module_utils/network/vyos/argspec/hostname/hostname.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py b/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py index 9ae4c65f..fecfb48f 100644 --- a/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py @@ -25,6 +25,7 @@ The arg spec for the vyos_interfaces module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py index d6d9e298..db333767 100644 --- a/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py @@ -27,6 +27,7 @@ The arg spec for the vyos_l3_interfaces module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py index 14ac7957..dce4fb7b 100644 --- a/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py @@ -24,6 +24,7 @@ The arg spec for the vyos_lag_interfaces module  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py index 635322b9..734274a1 100644 --- a/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py @@ -24,6 +24,7 @@ The arg spec for the vyos_lldp_global module  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py index b641aebc..672b7f0d 100644 --- a/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py @@ -27,6 +27,7 @@ The arg spec for the vyos_lldp_interfaces module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py b/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py index 503f723d..93b29f4a 100644 --- a/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# @@ -293,7 +294,7 @@ class Logging_globalArgs(object):  # pylint: disable=R0903                          "state": {                              "type": "str",                              "choices": ["enabled", "disabled"], -                        } +                        },                      },                  },                  "users": { diff --git a/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py b/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py index 7ace5bb7..fca9bf1e 100644 --- a/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py index 71ba63b6..1fd33700 100644 --- a/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py index 6c833720..bd7f94d9 100644 --- a/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py @@ -6,6 +6,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# @@ -53,7 +54,7 @@ class Ospfv2Args(object):  # pylint: disable=R0903                                  "route_map": {"type": "str"},                              },                              "type": "dict", -                        } +                        },                      },                      "type": "dict",                  }, @@ -85,7 +86,7 @@ class Ospfv2Args(object):  # pylint: disable=R0903                                  "on_startup": {"type": "int"},                              },                              "type": "dict", -                        } +                        },                      },                      "type": "dict",                  }, @@ -253,7 +254,7 @@ class Ospfv2Args(object):  # pylint: disable=R0903                                          "max_holdtime": {"type": "int"},                                      },                                      "type": "dict", -                                } +                                },                              },                              "type": "dict",                          }, diff --git a/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py index 7fac36c3..4ea88b6e 100644 --- a/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py @@ -6,6 +6,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py b/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py index c7d2e987..d2741446 100644 --- a/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py index 6baa4347..b2038a48 100644 --- a/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py index 2b10a515..7cea6887 100644 --- a/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py b/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py index f8602e33..916ad260 100644 --- a/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py @@ -27,6 +27,7 @@ The arg spec for the vyos_static_routes module  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -77,7 +78,7 @@ class Static_routesArgs(object):  # pylint: disable=R0903                          },                      },                      "type": "list", -                } +                },              },              "type": "list",          }, diff --git a/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py index 53defdec..1b075adb 100644 --- a/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -143,7 +144,7 @@ class Bgp_address_family(ResourceModule):                                      },                                      "address_family",                                      True, -                                ) +                                ),                              )              for neigh, neigh_entry in iteritems(entry.get("neighbors", {})):                  if have.get("neighbors"): @@ -158,7 +159,7 @@ class Bgp_address_family(ResourceModule):                                          },                                          "neighbors",                                          True, -                                    ) +                                    ),                                  )                              else:                                  for k in neigh_entry["address_family"].keys(): @@ -177,7 +178,7 @@ class Bgp_address_family(ResourceModule):                                                  },                                                  "neighbors.address_family",                                                  True, -                                            ) +                                            ),                                          )      def _compare_neighbors(self, want, have): @@ -248,7 +249,7 @@ class Bgp_address_family(ResourceModule):                              },                              "neighbors",                              True, -                        ) +                        ),                      )                  continue @@ -305,7 +306,7 @@ class Bgp_address_family(ResourceModule):                      + "address-family "                      + afi                      + " " -                    + attrib +                    + attrib,                  )                  hdict = {}              for key, entry in iteritems(hdict): diff --git a/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py index 55eca49f..c4a85020 100644 --- a/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -201,12 +202,12 @@ class Bgp_global(ResourceModule):              if name not in wneigh.keys():                  if self._check_af(name):                      msg = "Use the _bgp_address_family module to delete the address_family under neighbor {0}, before replacing/deleting the neighbor.".format( -                        name +                        name,                      )                      self._module.fail_json(msg=msg)                  else:                      self.commands.append( -                        "delete protocols bgp " + str(have["as_number"]) + " neighbor " + name +                        "delete protocols bgp " + str(have["as_number"]) + " neighbor " + name,                      )                      continue              for k, v in entry.items(): @@ -291,7 +292,7 @@ class Bgp_global(ResourceModule):          for name, entry in iteritems(hbgp):              if name == "confederation":                  self.commands.append( -                    "delete protocols bgp " + str(have["as_number"]) + " parameters confederation" +                    "delete protocols bgp " + str(have["as_number"]) + " parameters confederation",                  )              elif name == "distance":                  distance_parsers = [ @@ -339,7 +340,7 @@ class Bgp_global(ResourceModule):              if not wdict and hdict:                  attrib = re.sub("_", "-", attrib)                  self.commands.append( -                    "delete protocols bgp " + str(have["as_number"]) + " " + attrib +                    "delete protocols bgp " + str(have["as_number"]) + " " + attrib,                  )                  hdict = {}              for key, entry in iteritems(hdict): @@ -402,5 +403,5 @@ class Bgp_global(ResourceModule):      def _get_config(self, connection):          return connection.get( -            'show configuration commands |  match "set protocols bgp .* neighbor"' +            'show configuration commands |  match "set protocols bgp .* neighbor"',          ) diff --git a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py index 079cba60..8694f11b 100644 --- a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py @@ -12,6 +12,7 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -50,7 +51,9 @@ class Firewall_global(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          firewall_global_facts = facts["ansible_network_resources"].get("firewall_global")          if not firewall_global_facts: @@ -91,7 +94,7 @@ class Firewall_global(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_firewall_global_facts(data=running_config)          else: @@ -132,7 +135,7 @@ class Firewall_global(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "rendered") and not w:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "deleted":              commands.extend(self._state_deleted(want=None, have=h)) @@ -242,12 +245,12 @@ class Firewall_global(ConfigBase):              for key, val in iteritems(w_fg):                  if opr and key in l_set and not (h and self._is_w_same(w_fg, h, key)):                      commands.append( -                        self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr) +                        self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr),                      )                  elif not opr:                      if key and self._is_del(l_set, h):                          commands.append( -                            self._form_attr_cmd(attr=key, key=self._bool_to_str(val), opr=opr) +                            self._form_attr_cmd(attr=key, key=self._bool_to_str(val), opr=opr),                          )                          continue                      if ( @@ -256,7 +259,7 @@ class Firewall_global(ConfigBase):                          and not self._is_del(l_set, h)                      ):                          commands.append( -                            self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr) +                            self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr),                          )                  else:                      commands.extend(self._render_attr_config(w_fg, h, key, opr)) @@ -290,7 +293,7 @@ class Firewall_global(ConfigBase):                      and not (h_ping and self._is_w_same(w[attr], h_ping, item))                  ):                      commands.append( -                        self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr) +                        self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr),                      )                  elif (                      not opr @@ -361,19 +364,29 @@ class Firewall_global(ConfigBase):                                      + key                                      + " '"                                      + str(want[key]) -                                    + "'" +                                    + "'",                                  )                          elif not opr and key in l_set:                              if key == "name" and self._is_grp_del(h, want, key):                                  commands.append(cmd + " " + want["name"])                                  continue                              if not (h and self._in_target(h, key)) and not self._is_grp_del( -                                h, want, key +                                h, +                                want, +                                key,                              ):                                  commands.append(cmd + " " + want["name"] + " " + key)                          elif key == "members":                              commands.extend( -                                self._render_ports_addrs(key, want, h, opr, cmd, want["name"], attr) +                                self._render_ports_addrs( +                                    key, +                                    want, +                                    h, +                                    opr, +                                    cmd, +                                    want["name"], +                                    attr, +                                ),                              )          return commands @@ -407,7 +420,7 @@ class Firewall_global(ConfigBase):                          + " "                          + self._grp_type(type)                          + " " -                        + member[self._get_mem_type(type)] +                        + member[self._get_mem_type(type)],                      )              elif not opr and have:                  members = list_diff_want_only(want, have) @@ -419,7 +432,7 @@ class Firewall_global(ConfigBase):                          + " "                          + self._grp_type(type)                          + " " -                        + member[self._get_mem_type(type)] +                        + member[self._get_mem_type(type)],                      )          return commands @@ -462,18 +475,19 @@ class Firewall_global(ConfigBase):                                          attr=key,                                          val=self._bool_to_str(val),                                          opr=opr, -                                    ) +                                    ),                                  )                              elif not opr and key in l_set:                                  if not (h and self._in_target(h, key)) and not self._is_del( -                                    l_set, h +                                    l_set, +                                    h,                                  ):                                      if key == "action":                                          commands.append(                                              self._form_attr_cmd(                                                  attr=attr + " " + w["connection_type"],                                                  opr=opr, -                                            ) +                                            ),                                          )                                      else:                                          commands.append( @@ -481,7 +495,7 @@ class Firewall_global(ConfigBase):                                                  attr=attr + " " + w["connection_type"],                                                  val=self._bool_to_str(val),                                                  opr=opr, -                                            ) +                                            ),                                          )          return commands @@ -514,7 +528,7 @@ class Firewall_global(ConfigBase):                                      attr=key,                                      val=self._bool_to_str(val),                                      opr=opr, -                                ) +                                ),                              )                          elif not opr and key in l_set:                              if self._is_del(l_set, h): @@ -523,7 +537,7 @@ class Firewall_global(ConfigBase):                                          attr=key,                                          val=self._bool_to_str(val),                                          opr=opr, -                                    ) +                                    ),                                  )                                  continue                              if not (h and self._in_target(h, key)) and not self._is_del(l_set, h): @@ -532,7 +546,7 @@ class Firewall_global(ConfigBase):                                          attr=key,                                          val=self._bool_to_str(val),                                          opr=opr, -                                    ) +                                    ),                                  )                          elif key == "icmp_redirects":                              commands.extend(self._render_icmp_redirects(key, w, h, opr)) @@ -557,7 +571,7 @@ class Firewall_global(ConfigBase):              for item, value in iteritems(w[attr]):                  if opr and item in l_set and not (h_red and self._is_w_same(w[attr], h_red, item)):                      commands.append( -                        self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr) +                        self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr),                      )                  elif (                      not opr diff --git a/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py b/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py index 566bfebd..5c4db736 100644 --- a/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py +++ b/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py @@ -12,6 +12,7 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -52,7 +53,9 @@ class Firewall_interfaces(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          firewall_interfaces_facts = facts["ansible_network_resources"].get("firewall_interfaces")          if not firewall_interfaces_facts: @@ -93,7 +96,7 @@ class Firewall_interfaces(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_firewall_interfaces_facts(data=running_config)          else: @@ -134,7 +137,7 @@ class Firewall_interfaces(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not w:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "overridden":              commands.extend(self._state_overridden(w, h)) @@ -202,7 +205,7 @@ class Firewall_interfaces(ConfigBase):                                                  name=h_ar["name"],                                                  attrib=h[key],                                                  opr=False, -                                            ) +                                            ),                                          )          commands.extend(self._state_merged(want, have)) @@ -290,7 +293,7 @@ class Firewall_interfaces(ConfigBase):              for h in h_rules:                  if key in h:                      commands.append( -                        self._compute_command(afi=want["afi"], name=name, attrib=h[key], opr=opr) +                        self._compute_command(afi=want["afi"], name=name, attrib=h[key], opr=opr),                      )          for w in w_rules:              h = search_obj_in_list(w[key], h_rules, key=key) @@ -309,7 +312,7 @@ class Firewall_interfaces(ConfigBase):                          attrib=w[key],                          value=w["name"],                          opr=opr, -                    ) +                    ),                  )          return commands @@ -362,11 +365,11 @@ class Firewall_interfaces(ConfigBase):                                  name=name,                                  attrib=w[key],                                  value=w["name"], -                            ) +                            ),                          )                      elif not (h and key in h):                          commands.append( -                            self._compute_command(afi=want["afi"], name=name, attrib=w[key]) +                            self._compute_command(afi=want["afi"], name=name, attrib=w[key]),                          )                  elif not opr:                      if not h or key not in h or ("name" in w and h and "name" not in h): @@ -376,7 +379,7 @@ class Firewall_interfaces(ConfigBase):                                  name=name,                                  attrib=w[key],                                  opr=opr, -                            ) +                            ),                          )          return commands diff --git a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py index aa18a7ed..09e19d70 100644 --- a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py @@ -12,9 +12,11 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  import re +  from copy import deepcopy  from ansible.module_utils.six import iteritems @@ -56,7 +58,9 @@ class Firewall_rules(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          firewall_rules_facts = facts["ansible_network_resources"].get("firewall_rules")          if not firewall_rules_facts: @@ -97,7 +101,7 @@ class Firewall_rules(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_firewall_rules_facts(data=running_config)          else: @@ -138,7 +142,7 @@ class Firewall_rules(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not w:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "overridden":              commands.extend(self._state_overridden(w, h)) @@ -168,7 +172,10 @@ class Firewall_rules(ConfigBase):                      # already have (to be replaced by our desired                      # configuration's rule set).                      wanted_rule_set = self.search_r_sets_in_have( -                        want, rs["name"], "r_list", h["afi"] +                        want, +                        rs["name"], +                        "r_list", +                        h["afi"],                      )                      if wanted_rule_set is not None:                          # Remove the rules that we already have if the wanted @@ -179,7 +186,7 @@ class Firewall_rules(ConfigBase):                                  want=rs,                                  have=wanted_rule_set,                                  opr=False, -                            ) +                            ),                          )          # Merge the desired configuration into what we already have.          commands.extend(self._state_merged(want, have)) @@ -467,7 +474,7 @@ class Firewall_rules(ConfigBase):                              commands.append(cmd + (" " + "icmpv6" + " " + param_name + " " + val))                          else:                              commands.append( -                                cmd + (" " + attr + " " + item.replace("_", "-") + " " + val) +                                cmd + (" " + attr + " " + item.replace("_", "-") + " " + val),                              )                      else:                          commands.append(cmd + (" " + attr + " " + item + " " + str(val))) @@ -588,7 +595,7 @@ class Firewall_rules(ConfigBase):                                  + str(rate["number"])                                  + "/"                                  + rate["unit"] -                            ) +                            ),                          )                      if not opr and not (                          h_limit @@ -619,7 +626,7 @@ class Firewall_rules(ConfigBase):                      and not (h and attr in h.keys() and self._is_w_same(w[attr], h[attr], key))                  ):                      commands.append( -                        cmd + (" " + attr + " " + key.replace("_", "-") + " " + w[attr].get(key)) +                        cmd + (" " + attr + " " + key.replace("_", "-") + " " + w[attr].get(key)),                      )                  elif (                      not opr @@ -652,7 +659,7 @@ class Firewall_rules(ConfigBase):                                      + item.replace("_", "-")                                      + " "                                      + val -                                ) +                                ),                              )                          elif (                              not opr @@ -660,7 +667,7 @@ class Firewall_rules(ConfigBase):                              and not (h_group and self._in_target(h_group, item))                          ):                              commands.append( -                                cmd + (" " + attr + " " + key + " " + item.replace("_", "-")) +                                cmd + (" " + attr + " " + key + " " + item.replace("_", "-")),                              )          return commands @@ -779,7 +786,11 @@ class Firewall_rules(ConfigBase):          :return: generated command.          """          command = self._compute_command( -            afi=afi, name=name, attrib=attrib, value=rule[attrib], opr=opr +            afi=afi, +            name=name, +            attrib=attrib, +            value=rule[attrib], +            opr=opr,          )          return command diff --git a/plugins/module_utils/network/vyos/config/hostname/hostname.py b/plugins/module_utils/network/vyos/config/hostname/hostname.py index 8b30a693..36aba74f 100644 --- a/plugins/module_utils/network/vyos/config/hostname/hostname.py +++ b/plugins/module_utils/network/vyos/config/hostname/hostname.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ diff --git a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py index 852db464..731014cd 100644 --- a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py @@ -11,6 +11,7 @@ created  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -55,7 +56,9 @@ class Interfaces(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          interfaces_facts = facts["ansible_network_resources"].get("interfaces")          if not interfaces_facts: @@ -95,7 +98,7 @@ class Interfaces(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_interfaces_facts(data=running_config)          else: @@ -137,7 +140,7 @@ class Interfaces(ConfigBase):          if self.state in ("merged", "replaced", "overridden", "rendered") and not want:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "overridden": @@ -226,7 +229,7 @@ class Interfaces(ConfigBase):          if updates:              for key, value in iteritems(updates):                  commands.append( -                    self._compute_commands(key=key, value=value, interface=want_copy["name"]) +                    self._compute_commands(key=key, value=value, interface=want_copy["name"]),                  )          if want_vifs: @@ -247,7 +250,7 @@ class Interfaces(ConfigBase):                                  value=value,                                  interface=want_copy["name"],                                  vif=want_vif["vlan_id"], -                            ) +                            ),                          )          return commands @@ -270,11 +273,11 @@ class Interfaces(ConfigBase):              if key == "enabled":                  continue              commands.append( -                self._compute_commands(key=key, interface=want_copy["name"], remove=True) +                self._compute_commands(key=key, interface=want_copy["name"], remove=True),              )          if have_copy["enabled"] is False:              commands.append( -                self._compute_commands(key="enabled", value=True, interface=want_copy["name"]) +                self._compute_commands(key="enabled", value=True, interface=want_copy["name"]),              )          if have_vifs: @@ -295,7 +298,7 @@ class Interfaces(ConfigBase):                              interface=want_copy["name"],                              vif=want_vif["vlan_id"],                              remove=True, -                        ) +                        ),                      )                  if have_vif["enabled"] is False:                      commands.append( @@ -304,7 +307,7 @@ class Interfaces(ConfigBase):                              value=True,                              interface=want_copy["name"],                              vif=want_vif["vlan_id"], -                        ) +                        ),                      )          return commands diff --git a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py index 61dd1f47..6e0c005f 100644 --- a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py @@ -13,6 +13,7 @@ created  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -59,7 +60,9 @@ class L3_interfaces(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          l3_interfaces_facts = facts["ansible_network_resources"].get("l3_interfaces")          if not l3_interfaces_facts: @@ -100,7 +103,7 @@ class L3_interfaces(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_l3_interfaces_facts(data=running_config)          else: @@ -143,7 +146,7 @@ class L3_interfaces(ConfigBase):          if state in ("merged", "replaced", "overridden", "rendered") and not want:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(state) +                msg="value of config parameter must not be empty for state {0}".format(state),              )          if state == "overridden": @@ -225,7 +228,7 @@ class L3_interfaces(ConfigBase):          for update in self._get_updates(want_copy, have_copy):              for key, value in iteritems(update):                  commands.append( -                    self._compute_commands(key=key, value=value, interface=want_copy["name"]) +                    self._compute_commands(key=key, value=value, interface=want_copy["name"]),                  )          if want_vifs: @@ -242,7 +245,7 @@ class L3_interfaces(ConfigBase):                                  value=value,                                  interface=want_copy["name"],                                  vif=want_vif["vlan_id"], -                            ) +                            ),                          )          return commands @@ -269,7 +272,7 @@ class L3_interfaces(ConfigBase):                          value=value,                          interface=want_copy["name"],                          remove=True, -                    ) +                    ),                  )          if have_vifs: @@ -287,7 +290,7 @@ class L3_interfaces(ConfigBase):                                  value=value,                                  vif=want_vif["vlan_id"],                                  remove=True, -                            ) +                            ),                          )          return commands diff --git a/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py index 314ff933..835615b9 100644 --- a/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py @@ -10,6 +10,7 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from ansible.module_utils.six import iteritems  from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( @@ -62,7 +63,9 @@ class Lag_interfaces(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          lag_interfaces_facts = facts["ansible_network_resources"].get("lag_interfaces")          if not lag_interfaces_facts: @@ -103,7 +106,7 @@ class Lag_interfaces(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_lag_interfaces_facts(data=running_config)          else: @@ -144,7 +147,7 @@ class Lag_interfaces(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not want:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "overridden":              commands.extend(self._state_overridden(want, have)) @@ -301,7 +304,7 @@ class Lag_interfaces(ConfigBase):                          "bond-group",                          want["name"],                          type="ethernet", -                    ) +                    ),                  )          return commands @@ -316,7 +319,7 @@ class Lag_interfaces(ConfigBase):                      key=want["name"] + " arp-monitor",                      attrib="interval",                      value=str(arp_monitor["interval"]), -                ) +                ),              )          if diff_targets:              for target in diff_targets: @@ -325,7 +328,7 @@ class Lag_interfaces(ConfigBase):                          key=want["name"] + " arp-monitor",                          attrib="target",                          value=target, -                    ) +                    ),                  )          return commands @@ -339,7 +342,7 @@ class Lag_interfaces(ConfigBase):                      have["name"],                      remove=True,                      type="ethernet", -                ) +                ),              )          return commands @@ -362,7 +365,7 @@ class Lag_interfaces(ConfigBase):                      key=have["name"] + " arp-monitor",                      attrib="interval",                      remove=True, -                ) +                ),              )          if "target" in have_arp_monitor:              target_diff = list_diff_have_only(want_arp_target, have_arp_target) @@ -374,7 +377,7 @@ class Lag_interfaces(ConfigBase):                              attrib="target",                              value=target,                              remove=True, -                        ) +                        ),                      )          return commands @@ -394,7 +397,7 @@ class Lag_interfaces(ConfigBase):                          have["name"],                          True,                          "ethernet", -                    ) +                    ),                  )          return commands diff --git a/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py index b2571e0a..1afda782 100644 --- a/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py @@ -10,6 +10,7 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from ansible.module_utils.six import iteritems  from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( @@ -53,7 +54,9 @@ class Lldp_global(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          lldp_global_facts = facts["ansible_network_resources"].get("lldp_global")          if not lldp_global_facts: @@ -94,7 +97,7 @@ class Lldp_global(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_lldp_global_facts(data=running_config)          else: @@ -135,7 +138,7 @@ class Lldp_global(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "rendered") and not want:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "deleted":              commands.extend(self._state_deleted(want=None, have=have)) diff --git a/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py index 11b950b4..53e9aed0 100644 --- a/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py @@ -13,6 +13,7 @@ created  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from ansible.module_utils.six import iteritems @@ -59,7 +60,9 @@ class Lldp_interfaces(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          lldp_interfaces_facts = facts["ansible_network_resources"].get("lldp_interfaces")          if not lldp_interfaces_facts: @@ -100,7 +103,7 @@ class Lldp_interfaces(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_lldp_interfaces_facts(data=running_config)          else: @@ -141,7 +144,7 @@ class Lldp_interfaces(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not want:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "overridden":              commands.extend(self._state_overridden(want=want, have=have)) @@ -300,7 +303,7 @@ class Lldp_interfaces(ConfigBase):                              set_cmd + location_type,                              "country-code",                              str(want_dict["country_code"]), -                        ) +                        ),                      )              else:                  commands.append( @@ -308,7 +311,7 @@ class Lldp_interfaces(ConfigBase):                          set_cmd + location_type,                          "country-code",                          str(want_dict["country_code"]), -                    ) +                    ),                  )              commands.extend(self._add_civic_address(name, want_ca, have_ca)) @@ -320,14 +323,14 @@ class Lldp_interfaces(ConfigBase):                          self._compute_command(                              set_cmd + location_type,                              value=str(want_location_type["elin"]), -                        ) +                        ),                      )              else:                  commands.append(                      self._compute_command(                          set_cmd + location_type,                          value=str(want_location_type["elin"]), -                    ) +                    ),                  )          return commands @@ -346,7 +349,7 @@ class Lldp_interfaces(ConfigBase):                      only_in_have = key_value_in_dict(key, value, want_dict)                      if not only_in_have:                          commands.append( -                            self._compute_command(del_cmd + location_type, key, str(value), True) +                            self._compute_command(del_cmd + location_type, key, str(value), True),                          )              else:                  commands.append(self._compute_command(del_cmd, remove=True)) @@ -381,7 +384,7 @@ class Lldp_interfaces(ConfigBase):                          key=name + " location civic-based ca-type",                          attrib=str(ca_type) + " ca-value",                          value=ca_value, -                    ) +                    ),                  )          return commands @@ -398,7 +401,7 @@ class Lldp_interfaces(ConfigBase):                          "location civic-based ca-type",                          str(ca_type),                          remove=True, -                    ) +                    ),                  )          return commands diff --git a/plugins/module_utils/network/vyos/config/logging_global/logging_global.py b/plugins/module_utils/network/vyos/config/logging_global/logging_global.py index 27c33b30..d8bfa182 100644 --- a/plugins/module_utils/network/vyos/config/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/config/logging_global/logging_global.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -173,7 +174,7 @@ class Logging_global(ResourceModule):                                  element: {                                      "facilities": dat,                                      self.pkey.get(element): v.get(self.pkey.get(element)), -                                } +                                },                              }                          del v["facilities"]                          if len(list(v.keys())) > 1: diff --git a/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py b/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py index 3ce6ec2c..106faac5 100644 --- a/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -89,12 +90,12 @@ class Ntp_global(ResourceModule):                      for hk, hval in iteritems(have):                          if hk == "allow_clients" and hk in commandlist:                              self.commands.append( -                                self._tmplt.render({"": hk}, "allow_clients_delete", True) +                                self._tmplt.render({"": hk}, "allow_clients_delete", True),                              )                              commandlist.remove(hk)                          elif hk == "listen_addresses" and hk in commandlist:                              self.commands.append( -                                self._tmplt.render({"": hk}, "listen_addresses_delete", True) +                                self._tmplt.render({"": hk}, "listen_addresses_delete", True),                              )                              commandlist.remove(hk)                          elif hk == "server" and have["server"] in servernames: diff --git a/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py index 527f062a..a7652a6b 100644 --- a/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """  The vyos_ospf_interfaces config file. diff --git a/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py index 3f9e4e64..a9c1de1b 100644 --- a/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py @@ -12,6 +12,7 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -54,7 +55,9 @@ class Ospfv2(ConfigBase):          """          (facts, _warnings) = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          ospfv2_facts = facts["ansible_network_resources"].get("ospfv2", {})          return ospfv2_facts @@ -94,7 +97,7 @@ class Ospfv2(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_ospfv2_facts(data=running_config)          else: @@ -137,7 +140,7 @@ class Ospfv2(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not w:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "deleted": @@ -298,7 +301,7 @@ class Ospfv2(ConfigBase):                          commands.append(self._form_attr_cmd(key=attr, attr=item, opr=opr))                      else:                          commands.append( -                            self._form_attr_cmd(key=attr, attr=item, val=value, opr=opr) +                            self._form_attr_cmd(key=attr, attr=item, val=value, opr=opr),                          )                  elif not opr and item in leaf and not _in_target(h, item):                      if item == "enabled": @@ -342,7 +345,7 @@ class Ospfv2(ConfigBase):                          if attr == "network":                              if not self.search_obj_in_have(h, member, "address"):                                  commands.append( -                                    cmd + attr.replace("_", "-") + " " + member["address"] +                                    cmd + attr.replace("_", "-") + " " + member["address"],                                  )                          elif member not in h:                              commands.append(cmd + attr.replace("_", "-") + " " + member) @@ -372,7 +375,7 @@ class Ospfv2(ConfigBase):                  "transmit_delay",                  "hello_interval",                  "retransmit_interval", -            ) +            ),          }          leaf = leaf_dict[attr]          w = want.get(attr) or [] @@ -398,14 +401,14 @@ class Ospfv2(ConfigBase):                                  + " "                                  + key.replace("_", "-")                                  + " " -                                + str(val) +                                + str(val),                              )                      elif not opr and key in leaf and not _in_target(h_item, key):                          if key in "address":                              commands.append(cmd + attr.replace("_", "-") + " " + str(val))                          else:                              commands.append( -                                cmd + attr.replace("_", "-") + " " + w_item[name[attr]] + " " + key +                                cmd + attr.replace("_", "-") + " " + w_item[name[attr]] + " " + key,                              )                      elif key == "authentication":                          commands.extend( @@ -417,7 +420,7 @@ class Ospfv2(ConfigBase):                                  w_item["address"],                                  cmd,                                  opr, -                            ) +                            ),                          )          return commands @@ -504,11 +507,11 @@ class Ospfv2(ConfigBase):                              commands.append(cmd + attr + " " + str(val))                          elif key == "cost":                              commands.append( -                                cmd + attr + " " + w_item[name[attr]] + " " + key + " " + str(val) +                                cmd + attr + " " + w_item[name[attr]] + " " + key + " " + str(val),                              )                          elif key == "not_advertise":                              commands.append( -                                cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-") +                                cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-"),                              )                          elif key == "md5_key":                              commands.append( @@ -521,7 +524,7 @@ class Ospfv2(ConfigBase):                                  + " "                                  + key.replace("_", "-")                                  + " " -                                + w_item[key] +                                + w_item[key],                              )                          else:                              commands.append( @@ -532,7 +535,7 @@ class Ospfv2(ConfigBase):                                  + " "                                  + key.replace("_", "-")                                  + " " -                                + str(val) +                                + str(val),                              )                      elif not opr and key in leaf and not _in_target(h_item, key):                          if key in ( @@ -596,7 +599,7 @@ class Ospfv2(ConfigBase):                                  + " "                                  + key.replace("_", "-")                                  + " " -                                + item.replace("_", "-") +                                + item.replace("_", "-"),                              )                          elif item not in ("administrative", "always"):                              commands.append( @@ -607,7 +610,7 @@ class Ospfv2(ConfigBase):                                  + " "                                  + item.replace("_", "-")                                  + " " -                                + str(val) +                                + str(val),                              )                      elif not opr and item in leaf and not _in_target(h_attrib, item):                          commands.append(cmd + attr + " " + item) @@ -645,7 +648,7 @@ class Ospfv2(ConfigBase):                  h_area = self.search_obj_in_have(h_lst, w_area, "area_id")                  if not opr and not h_area:                      commands.append( -                        self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr) +                        self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr),                      )                  else:                      for key, val in iteritems(w_area): @@ -656,11 +659,11 @@ class Ospfv2(ConfigBase):                                          attr="area",                                          val=_bool_to_str(val),                                          opr=opr, -                                    ) +                                    ),                                  )                              else:                                  commands.append( -                                    cmd + key + " " + _bool_to_str(val).replace("_", "-") +                                    cmd + key + " " + _bool_to_str(val).replace("_", "-"),                                  )                          elif not opr and key in l_set:                              if key == "area_id" and not _in_target(h_area, key): @@ -674,7 +677,7 @@ class Ospfv2(ConfigBase):                              commands.extend(self._render_list_param(key, w_area, h_area, cmd, opr))                          elif key == "range":                              commands.extend( -                                self._render_list_dict_param(key, w_area, h_area, cmd, opr) +                                self._render_list_dict_param(key, w_area, h_area, cmd, opr),                              )                          elif key == "virtual_link":                              commands.extend(self._render_vlink(key, w_area, h_area, cmd, opr)) @@ -704,7 +707,7 @@ class Ospfv2(ConfigBase):              if opr and key in w_type.keys() and not _is_w_same(w_type, h_type, key):                  if not w_type[key] and h_type and h_type[key]:                      commands.append( -                        cmd.replace("set", "delete") + attr.replace("_", "-") + " " + key +                        cmd.replace("set", "delete") + attr.replace("_", "-") + " " + key,                      )                  elif w_type[key]:                      commands.append(cmd + attr.replace("_", "-") + " " + key) @@ -734,7 +737,7 @@ class Ospfv2(ConfigBase):                                      cmd.replace("set", "delete")                                      + attr.replace("_", "-")                                      + " " -                                    + key +                                    + key,                                  )                              elif item != "set":                                  commands.append( @@ -745,7 +748,7 @@ class Ospfv2(ConfigBase):                                      + " "                                      + item.replace("_", "-")                                      + " " -                                    + str(val) +                                    + str(val),                                  )                          elif not opr and item in a_type[key] and not (h_type and key in h_type):                              if item == "set": @@ -759,7 +762,7 @@ class Ospfv2(ConfigBase):                                      + " "                                      + key                                      + " " -                                    + item.replace("_", "-") +                                    + item.replace("_", "-"),                                  )          return commands diff --git a/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py index abafc902..25d9a0ea 100644 --- a/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py @@ -12,6 +12,7 @@ created  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -58,7 +59,9 @@ class Ospfv3(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          ospfv3_facts = facts["ansible_network_resources"].get("ospfv3", {})          return ospfv3_facts @@ -97,7 +100,7 @@ class Ospfv3(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_ospfv3_facts(data=running_config)          else: @@ -138,7 +141,7 @@ class Ospfv3(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not w:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "deleted":              commands.extend(self._state_deleted(w, h)) @@ -289,7 +292,7 @@ class Ospfv3(ConfigBase):                              commands.append(cmd + attr + " " + str(val))                          elif key in leaf_dict["range"] and key != "address":                              commands.append( -                                cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-") +                                cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-"),                              )                          elif key == "route_map":                              commands.append( @@ -300,7 +303,7 @@ class Ospfv3(ConfigBase):                                  + " "                                  + key.replace("_", "-")                                  + " " -                                + str(val) +                                + str(val),                              )                      elif not opr and key in leaf and not _in_target(h_item, key):                          if key in ("route_type", "address"): @@ -340,7 +343,7 @@ class Ospfv3(ConfigBase):                  h_area = search_obj_in_list(w_area["area_id"], h_lst, "area_id")                  if not opr and not h_area:                      commands.append( -                        self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr) +                        self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr),                      )                  else:                      for key, val in iteritems(w_area): @@ -351,14 +354,14 @@ class Ospfv3(ConfigBase):                                          attr="area",                                          val=_bool_to_str(val),                                          opr=opr, -                                    ) +                                    ),                                  )                              else:                                  commands.append(                                      cmd                                      + key.replace("_", "-")                                      + " " -                                    + _bool_to_str(val).replace("_", "-") +                                    + _bool_to_str(val).replace("_", "-"),                                  )                          elif not opr and key in l_set:                              if key == "area_id" and not _in_target(h_area, key): @@ -368,7 +371,7 @@ class Ospfv3(ConfigBase):                                  commands.append(cmd + val + " " + key)                          elif key == "range":                              commands.extend( -                                self._render_list_dict_param(key, w_area, h_area, cmd, opr) +                                self._render_list_dict_param(key, w_area, h_area, cmd, opr),                              )          return commands diff --git a/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py b/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py index a8cc69ed..9da27c15 100644 --- a/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -120,8 +121,9 @@ class Prefix_lists(ResourceModule):              for h in hplists.values():                  self.commands.append(                      "delete policy prefix-{0} {1}".format( -                        "list" if h["afi"] == "ipv4" else "list6", h["name"] -                    ) +                        "list" if h["afi"] == "ipv4" else "list6", +                        h["name"], +                    ),                  )      def _compare_plists(self, want, have): @@ -158,7 +160,7 @@ class Prefix_lists(ResourceModule):                      "list" if hr["afi"] == "ipv4" else "list6",                      hr["name"],                      hr["sequence"], -                ) +                ),              )      def _prefix_list_list_to_dict(self, entry): diff --git a/plugins/module_utils/network/vyos/config/route_maps/route_maps.py b/plugins/module_utils/network/vyos/config/route_maps/route_maps.py index dd6fbf6f..9b6c3e9d 100644 --- a/plugins/module_utils/network/vyos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/vyos/config/route_maps/route_maps.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ diff --git a/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py b/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py index b942f8be..9497d7fa 100644 --- a/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py @@ -7,6 +7,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -137,7 +138,7 @@ class Snmp_server(ResourceModule):                                      "communities": {                                          k: hdict[key].pop(k, ""),                                          "name": key, -                                    } +                                    },                                  }                              self.compare(                                  parsers="communities", @@ -200,8 +201,8 @@ class Snmp_server(ResourceModule):                                          attribute_dict[attrib]: hattrib[key][                                              attribute_dict[attrib]                                          ], -                                    } -                                } +                                    }, +                                },                              }                          self.compare(                              parsers=parsers, @@ -210,8 +211,8 @@ class Snmp_server(ResourceModule):                                      attrib: {                                          k: v,                                          attribute_dict[attrib]: entry[attribute_dict[attrib]], -                                    } -                                } +                                    }, +                                },                              },                              have=h,                          ) @@ -252,16 +253,16 @@ class Snmp_server(ResourceModule):                                  attrib: {                                      key: entry,                                      primary_key: wattrib[primary_key], -                                } -                            } +                                }, +                            },                          },                          have={                              "snmp_v3": {                                  attrib: {                                      key: hattrib.pop(key, {}),                                      primary_key: wattrib[primary_key], -                                } -                            } +                                }, +                            },                          },                      )              for key, entry in iteritems(hattrib): @@ -274,8 +275,8 @@ class Snmp_server(ResourceModule):                                  attrib: {                                      key: entry,                                      primary_key: hattrib[primary_key], -                                } -                            } +                                }, +                            },                          },                      ) diff --git a/plugins/module_utils/network/vyos/config/static_routes/static_routes.py b/plugins/module_utils/network/vyos/config/static_routes/static_routes.py index 230a47c8..9230bdd9 100644 --- a/plugins/module_utils/network/vyos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/config/static_routes/static_routes.py @@ -13,6 +13,7 @@ created  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -54,7 +55,9 @@ class Static_routes(ConfigBase):          :returns: The current configuration as a dictionary          """          facts, _warnings = Facts(self._module).get_facts( -            self.gather_subset, self.gather_network_resources, data=data +            self.gather_subset, +            self.gather_network_resources, +            data=data,          )          static_routes_facts = facts["ansible_network_resources"].get("static_routes")          if not static_routes_facts: @@ -95,7 +98,7 @@ class Static_routes(ConfigBase):              running_config = self._module.params["running_config"]              if not running_config:                  self._module.fail_json( -                    msg="value of running_config parameter must not be empty for state parsed" +                    msg="value of running_config parameter must not be empty for state parsed",                  )              result["parsed"] = self.get_static_routes_facts(data=running_config)          else: @@ -136,7 +139,7 @@ class Static_routes(ConfigBase):          commands = []          if self.state in ("merged", "replaced", "overridden", "rendered") and not want:              self._module.fail_json( -                msg="value of config parameter must not be empty for state {0}".format(self.state) +                msg="value of config parameter must not be empty for state {0}".format(self.state),              )          if self.state == "overridden":              commands.extend(self._state_overridden(want=want, have=have)) @@ -290,7 +293,7 @@ class Static_routes(ConfigBase):                                  attrib=attrib,                                  remove=False,                                  value=str(value), -                            ) +                            ),                          )                      elif attrib == "type":                          commands.append(self._compute_command(dest=want["dest"], key="blackhole")) @@ -321,7 +324,7 @@ class Static_routes(ConfigBase):                                  key="next-hop",                                  value=hop[element],                                  opr=opr, -                            ) +                            ),                          )                      elif element == "enabled" and not hop[element]:                          commands.append( @@ -331,7 +334,7 @@ class Static_routes(ConfigBase):                                  attrib=hop["forward_router_address"],                                  value="disable",                                  opr=opr, -                            ) +                            ),                          )                      elif element == "admin_distance":                          commands.append( @@ -341,7 +344,7 @@ class Static_routes(ConfigBase):                                  attrib=hop["forward_router_address"] + " " + "distance",                                  value=str(hop[element]),                                  opr=opr, -                            ) +                            ),                          )                      elif element == "interface":                          commands.append( @@ -351,7 +354,7 @@ class Static_routes(ConfigBase):                                  attrib=hop["forward_router_address"] + " " + "next-hop-interface",                                  value=hop[element],                                  opr=opr, -                            ) +                            ),                          )          return commands @@ -385,11 +388,11 @@ class Static_routes(ConfigBase):                                  attrib=attrib,                                  remove=True,                                  value=str(value), -                            ) +                            ),                          )                      elif attrib == "type" and "distance" not in want_blackhole.keys():                          commands.append( -                            self._compute_command(dest=want["dest"], key="blackhole", remove=True) +                            self._compute_command(dest=want["dest"], key="blackhole", remove=True),                          )          return commands @@ -417,7 +420,7 @@ class Static_routes(ConfigBase):                                  key="next-hop",                                  value=hop[element],                                  remove=True, -                            ) +                            ),                          )                      elif element == "enabled":                          commands.append( @@ -427,7 +430,7 @@ class Static_routes(ConfigBase):                                  attrib=hop["forward_router_address"],                                  value="disable",                                  remove=True, -                            ) +                            ),                          )                      elif element == "admin_distance":                          commands.append( @@ -437,7 +440,7 @@ class Static_routes(ConfigBase):                                  attrib=hop["forward_router_address"] + " " + "distance",                                  value=str(hop[element]),                                  remove=True, -                            ) +                            ),                          )                      elif element == "interface":                          commands.append( @@ -447,7 +450,7 @@ class Static_routes(ConfigBase):                                  attrib=hop["forward_router_address"] + " " + "next-hop-interface",                                  value=hop[element],                                  remove=True, -                            ) +                            ),                          )          return commands diff --git a/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py index 5d60184c..629ffc50 100644 --- a/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -68,7 +69,8 @@ class Bgp_address_familyFacts(object):                          af["networks"] = sorted(af["networks"], key=lambda k: k["prefix"])                      if "aggregate_address" in af:                          af["aggregate_address"] = sorted( -                            af["aggregate_address"], key=lambda k: k["prefix"] +                            af["aggregate_address"], +                            key=lambda k: k["prefix"],                          )              if "neighbors" in objs:                  objs["neighbors"] = list(objs["neighbors"].values()) diff --git a/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py index c6105a04..fe341357 100644 --- a/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -71,7 +72,7 @@ class Bgp_globalFacts(object):          ansible_facts["ansible_network_resources"].pop("bgp_global", None)          params = utils.remove_empties( -            bgp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) +            bgp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),          )          facts["bgp_global"] = params.get("config", []) diff --git a/plugins/module_utils/network/vyos/facts/facts.py b/plugins/module_utils/network/vyos/facts/facts.py index f7b2b4ec..74bbda74 100644 --- a/plugins/module_utils/network/vyos/facts/facts.py +++ b/plugins/module_utils/network/vyos/facts/facts.py @@ -8,6 +8,7 @@ calls the appropriate facts gathering function  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts import ( @@ -80,6 +81,7 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.stati      Static_routesFacts,  ) +  FACT_LEGACY_SUBSETS = dict(default=Default, neighbors=Neighbors, config=Config)  FACT_RESOURCE_SUBSETS = dict(      interfaces=InterfacesFacts, diff --git a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py index 6441c26c..5b472222 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py @@ -11,6 +11,7 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -80,7 +81,7 @@ class Firewall_globalFacts(object):              filter(                  lambda x: ("firewall ipv6-name" and "firewall name" not in x),                  conf, -            ) +            ),          )          a_lst = [ @@ -209,10 +210,12 @@ class Firewall_globalFacts(object):          cfg_dict = {}          cfg_dict["port_group"] = self.parse_group_lst(conf, "port-group", False)          cfg_dict["address_group"] = self.parse_group_lst( -            conf, "address-group" +            conf, +            "address-group",          ) + self.parse_group_lst(conf, "ipv6-address-group")          cfg_dict["network_group"] = self.parse_group_lst( -            conf, "network-group" +            conf, +            "network-group",          ) + self.parse_group_lst(conf, "ipv6-network-group")          return cfg_dict diff --git a/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py b/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py index 3e0d3232..b9804692 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py @@ -11,6 +11,7 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py index 69daad9a..ead038a5 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py @@ -11,9 +11,11 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  import re +  from copy import deepcopy  from re import M, findall, search diff --git a/plugins/module_utils/network/vyos/facts/hostname/hostname.py b/plugins/module_utils/network/vyos/facts/hostname/hostname.py index 77ecc8ce..b4f7c529 100644 --- a/plugins/module_utils/network/vyos/facts/hostname/hostname.py +++ b/plugins/module_utils/network/vyos/facts/hostname/hostname.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -62,7 +63,7 @@ class HostnameFacts(object):          ansible_facts["ansible_network_resources"].pop("hostname", None)          params = utils.remove_empties( -            hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) +            hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),          )          facts["hostname"] = params.get("config", {}) diff --git a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py index 51c3a10a..995be911 100644 --- a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py @@ -12,6 +12,7 @@ based on the configuration.  from __future__ import absolute_import, division, print_function +  __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py index 845d79e7..be467a0a 100644 --- a/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py @@ -12,10 +12,12 @@ based on the configuration.  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  import re +  from copy import deepcopy  from ansible.module_utils.six import iteritems diff --git a/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py index 251178a7..78638bb7 100644 --- a/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py @@ -11,6 +11,7 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/legacy/base.py b/plugins/module_utils/network/vyos/facts/legacy/base.py index 59666e19..30978e0e 100644 --- a/plugins/module_utils/network/vyos/facts/legacy/base.py +++ b/plugins/module_utils/network/vyos/facts/legacy/base.py @@ -11,6 +11,7 @@ based on the configuration.  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  import platform  import re diff --git a/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py index e5639998..b2afe590 100644 --- a/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py @@ -11,6 +11,7 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py index bfe684f3..5f439e78 100644 --- a/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py @@ -12,6 +12,7 @@ based on the configuration.  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -90,7 +91,8 @@ class Lldp_interfacesFacts(object):          disable = "\n".join(filter(lambda x: ("disable" in x), conf))          coordinate_based_conf = self.parse_attribs( -            ["altitude", "datum", "longitude", "latitude"], coordinate_conf +            ["altitude", "datum", "longitude", "latitude"], +            coordinate_conf,          )          elin_based_conf = self.parse_lldp_elin_based(elin_conf)          civic_based_conf = self.parse_lldp_civic_based(civic_conf) diff --git a/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py b/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py index e0434d99..8b60bef9 100644 --- a/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -87,7 +88,11 @@ class Logging_globalFacts(object):          objs = self.process_facts(objs)          params = utils.remove_empties( -            logging_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) +            logging_global_parser.validate_config( +                self.argument_spec, +                {"config": objs}, +                redact=True, +            ),          )          facts["logging_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py b/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py index cead2415..880bc79f 100644 --- a/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -81,7 +82,7 @@ class Ntp_globalFacts(object):          ansible_facts["ansible_network_resources"].pop("ntp_global", None)          params = utils.remove_empties( -            ntp_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) +            ntp_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),          )          if params.get("config"): diff --git a/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py index c89e2bd8..af6c5770 100644 --- a/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -76,7 +77,8 @@ class Ospf_interfacesFacts(object):          resources = self.get_config_set(data)          for resource in resources:              ospf_interfaces_parser = Ospf_interfacesTemplate( -                lines=resource.split("\n"), module=self._module +                lines=resource.split("\n"), +                module=self._module,              )              objs = ospf_interfaces_parser.parse()              for key, sortv in [("address_family", "afi")]: @@ -91,7 +93,7 @@ class Ospf_interfacesFacts(object):                  self.argument_spec,                  {"config": ospf_interfaces_facts},                  redact=True, -            ) +            ),          )          if params.get("config"):              for cfg in params["config"]: diff --git a/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py index 5121c980..bdc7c9f8 100644 --- a/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py @@ -11,6 +11,7 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy @@ -101,7 +102,8 @@ class Ospfv2Facts(object):          config["passive_interface"] = self.parse_leaf_list(conf, "passive-interface")          config["redistribute"] = self.parse_attrib_list(conf, "redistribute", "route_type")          config["passive_interface_exclude"] = self.parse_leaf_list( -            conf, "passive-interface-exclude" +            conf, +            "passive-interface-exclude",          )          return config diff --git a/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py index d4b3e448..547ff793 100644 --- a/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py @@ -11,6 +11,7 @@ based on the configuration.  """  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py b/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py index 19004c8d..17f63fb2 100644 --- a/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -76,7 +77,7 @@ class Prefix_listsFacts(object):          ansible_facts["ansible_network_resources"].pop("prefix_lists", None)          params = utils.remove_empties( -            prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) +            prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),          )          if params.get("config"): diff --git a/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py b/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py index 9f53264b..2ad54e63 100644 --- a/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py +++ b/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ diff --git a/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py b/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py index 54339f57..e70a15f9 100644 --- a/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -104,7 +105,7 @@ class Snmp_serverFacts(object):          ansible_facts["ansible_network_resources"].pop("snmp_server", None)          params = utils.remove_empties( -            snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) +            snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),          )          facts["snmp_server"] = params.get("config", {}) diff --git a/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py b/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py index 019706b3..b8ffa30d 100644 --- a/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py @@ -12,6 +12,7 @@ based on the configuration.  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from copy import deepcopy  from re import M, findall, search diff --git a/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py b/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py index b1bb27c0..c996a74a 100644 --- a/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -27,11 +28,11 @@ def _tmplt_bgp_af_aggregate_address(config_data):      config_data = config_data["address_family"]      if config_data["aggregate_address"].get("as_set"):          command += afi + " aggregate-address {prefix} as-set".format( -            **config_data["aggregate_address"] +            **config_data["aggregate_address"],          )      if config_data["aggregate_address"].get("summary_only"):          command += afi + " aggregate-address {prefix} summary-only".format( -            **config_data["aggregate_address"] +            **config_data["aggregate_address"],          )      return command @@ -42,7 +43,7 @@ def _tmplt_bgp_af_redistribute_metric(config_data):          command = "protocols bgp {as_number} address-family ".format(**config_data)          if config_data["address_family"]["redistribute"].get("metric"):              command += afi + " redistribute {protocol} metric {metric}".format( -                **config_data["address_family"]["redistribute"] +                **config_data["address_family"]["redistribute"],              )          return command @@ -53,7 +54,7 @@ def _tmplt_bgp_af_redistribute_route_map(config_data):          command = "protocols bgp {as_number} address-family ".format(**config_data)          if config_data["address_family"]["redistribute"].get("route_map"):              command += afi + " redistribute {protocol} route-map {route_map}".format( -                **config_data["address_family"]["redistribute"] +                **config_data["address_family"]["redistribute"],              )          return command @@ -64,7 +65,7 @@ def _tmplt_bgp_af_redistribute_table(config_data):          command = "protocols bgp {as_number} address-family ".format(**config_data)          if config_data["address_family"]["redistribute"].get("table"):              command += afi + " table {table}".format( -                **config_data["address_family"]["redistribute"] +                **config_data["address_family"]["redistribute"],              )          return command @@ -85,7 +86,7 @@ def _tmplt_bgp_af_neighbor_distribute_list(config_data):      config_data = config_data["neighbors"]["address_family"]      for list_el in config_data["distribute_list"]:          command.append( -            cmd + afi + " distribute-list " + list_el["action"] + " " + str(list_el["acl"]) +            cmd + afi + " distribute-list " + list_el["action"] + " " + str(list_el["acl"]),          )      return command @@ -98,7 +99,7 @@ def _tmplt_bgp_af_neighbor_route_map(config_data):      config_data = config_data["neighbors"]["address_family"]      for list_el in config_data["route_map"]:          command.append( -            cmd + afi + " route-map " + list_el["action"] + " " + str(list_el["route_map"]) +            cmd + afi + " route-map " + list_el["action"] + " " + str(list_el["route_map"]),          )      return command @@ -111,7 +112,7 @@ def _tmplt_bgp_af_neighbor_prefix_list(config_data):      config_data = config_data["neighbors"]["address_family"]      for list_el in config_data["prefix_list"]:          command.append( -            cmd + afi + " prefix-list " + list_el["action"] + " " + str(list_el["prefix_list"]) +            cmd + afi + " prefix-list " + list_el["action"] + " " + str(list_el["prefix_list"]),          )      return command @@ -124,7 +125,7 @@ def _tmplt_bgp_af_neighbor_filter_list(config_data):      config_data = config_data["neighbors"]["address_family"]      for list_el in config_data["filter_list"]:          command.append( -            cmd + afi + " filter-list " + list_el["action"] + " " + str(list_el["path_list"]) +            cmd + afi + " filter-list " + list_el["action"] + " " + str(list_el["path_list"]),          )      return command @@ -237,7 +238,10 @@ class Bgp_address_familyTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(Bgp_address_familyTemplate, self).__init__( -            lines=lines, tmplt=self, prefix=prefix, module=module +            lines=lines, +            tmplt=self, +            prefix=prefix, +            module=module,          )      # fmt: off @@ -262,9 +266,9 @@ class Bgp_address_familyTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": "{{ afi }}", -                    } -                } -            } +                    }, +                }, +            },          },          {              "name": "aggregate_address", @@ -296,12 +300,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                              {                                  "prefix": "{{ address }}",                                  "as_set": "{{ True if as_set is defined }}", -                                "summary_only": "{{ True if summary_only is defined }}" -                            } -                        ] -                    } -                } -            } +                                "summary_only": "{{ True if summary_only is defined }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "network.backdoor", @@ -330,12 +334,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "networks": [                              {                                  "prefix": "{{ address }}", -                                "backdoor": "{{ True }}" -                            } -                        ] -                    } -                } -            } +                                "backdoor": "{{ True }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "network.path_limit", @@ -366,12 +370,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "networks": [                              {                                  "prefix": "{{ address }}", -                                "path_limit": "{{ limit|int }}" -                            } -                        ] -                    } -                } -            } +                                "path_limit": "{{ limit|int }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "network.route_map", @@ -402,12 +406,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "networks": [                              {                                  "prefix": "{{ address }}", -                                "route_map": "{{ map }}" -                            } -                        ] -                    } -                } -            } +                                "route_map": "{{ map }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "redistribute.metric", @@ -437,12 +441,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "redistribute": [                              {                                  "protocol": "{{ proto }}", -                                "metric": "{{ val|int }}" -                            } -                        ] -                    } -                } -            } +                                "metric": "{{ val|int }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "redistribute.route_map", @@ -472,12 +476,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "redistribute": [                              {                                  "protocol": "{{ proto }}", -                                "route_map": "{{ map }}" -                            } -                        ] -                    } -                } -            } +                                "route_map": "{{ map }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "redistribute.table", @@ -505,12 +509,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "afi": "{{ afi }}",                          "redistribute": [                              { -                                "table": "{{ tab }}" -                            } -                        ] -                    } -                } -            } +                                "table": "{{ tab }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "neighbors", @@ -533,9 +537,9 @@ class Bgp_address_familyTemplate(NetworkTemplate):                  "neighbors": {                      "{{ address }}": {                          "neighbor_address": "{{ address }}", -                    } -                } -            } +                    }, +                }, +            },          },          {              "name": "neighbors.address_family", @@ -562,11 +566,11 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                            } -                        } -                    } -                } -            } +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.allowas_in", @@ -597,12 +601,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "allowas_in": "{{ num }}" -                            } -                        } -                    } -                } -            } +                                "allowas_in": "{{ num }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.as_override", @@ -631,12 +635,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "as_override": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "as_override": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.attribute_unchanged.as_path", @@ -667,13 +671,13 @@ class Bgp_address_familyTemplate(NetworkTemplate):                              "{{ afi }}": {                                  "afi": "{{ afi }}",                                  "attribute_unchanged": { -                                    "as_path": "{{ True }}" -                                } -                            } -                        } -                    } -                } -            } +                                    "as_path": "{{ True }}", +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.attribute_unchanged.med", @@ -704,13 +708,13 @@ class Bgp_address_familyTemplate(NetworkTemplate):                              "{{ afi }}": {                                  "afi": "{{ afi }}",                                  "attribute_unchanged": { -                                    "med": "{{ True }}" -                                } -                            } -                        } -                    } -                } -            } +                                    "med": "{{ True }}", +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.attribute_unchanged.next_hop", @@ -741,13 +745,13 @@ class Bgp_address_familyTemplate(NetworkTemplate):                              "{{ afi }}": {                                  "afi": "{{ afi }}",                                  "attribute_unchanged": { -                                    "next_hop": "{{ True }}" -                                } -                            } -                        } -                    } -                } -            } +                                    "next_hop": "{{ True }}", +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.capability_dynamic", @@ -778,13 +782,13 @@ class Bgp_address_familyTemplate(NetworkTemplate):                              "{{ afi }}": {                                  "afi": "{{ afi }}",                                  "capability": { -                                    "dynamic": "{{ true }}" -                                } -                            } -                        } -                    } -                } -            } +                                    "dynamic": "{{ true }}", +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.capability_orf", @@ -816,13 +820,13 @@ class Bgp_address_familyTemplate(NetworkTemplate):                              "{{ afi }}": {                                  "afi": "{{ afi }}",                                  "capability": { -                                    "orf": "{{ orf }}" -                                } -                            } -                        } -                    } -                } -            } +                                    "orf": "{{ orf }}", +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.default_originate", @@ -853,12 +857,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "default_originate": "{{ map }}" -                            } -                        } -                    } -                } -            } +                                "default_originate": "{{ map }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.distribute_list", @@ -892,14 +896,14 @@ class Bgp_address_familyTemplate(NetworkTemplate):                                  "distribute_list": [                                      {                                          "action": "{{ action }}", -                                        "acl": "{{ list }}" -                                    } -                                ] -                            } -                        } -                    } -                } -            } +                                        "acl": "{{ list }}", +                                    }, +                                ], +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.prefix_list", @@ -933,14 +937,14 @@ class Bgp_address_familyTemplate(NetworkTemplate):                                  "prefix_list": [                                      {                                          "action": "{{ action }}", -                                        "prefix_list": "{{ list }}" -                                    } -                                ] -                            } -                        } -                    } -                } -            } +                                        "prefix_list": "{{ list }}", +                                    }, +                                ], +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.filter_list", @@ -974,14 +978,14 @@ class Bgp_address_familyTemplate(NetworkTemplate):                                  "filter_list": [                                      {                                          "action": "{{ action }}", -                                        "path_list": "{{ list }}" -                                    } -                                ] -                            } -                        } -                    } -                } -            } +                                        "path_list": "{{ list }}", +                                    }, +                                ], +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.maximum_prefix", @@ -1011,12 +1015,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "maximum_prefix": "{{ num }}" -                            } -                        } -                    } -                } -            } +                                "maximum_prefix": "{{ num }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.nexthop_local", @@ -1045,12 +1049,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "nexthop_local": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "nexthop_local": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.nexthop_self", @@ -1079,12 +1083,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "nexthop_self": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "nexthop_self": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.peer_group", @@ -1114,12 +1118,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "peer_group": "{{ name }}" -                            } -                        } -                    } -                } -            } +                                "peer_group": "{{ name }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.remove_private_as", @@ -1148,12 +1152,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "remove_private_as": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "remove_private_as": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.route_map", @@ -1187,14 +1191,14 @@ class Bgp_address_familyTemplate(NetworkTemplate):                                  "route_map": [                                      {                                          "action": "{{ action }}", -                                        "route_map": "{{ map }}" -                                    } -                                ] -                            } -                        } -                    } -                } -            } +                                        "route_map": "{{ map }}", +                                    }, +                                ], +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.route_reflector_client", @@ -1223,12 +1227,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "route_reflector_client": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "route_reflector_client": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.route_server_client", @@ -1257,12 +1261,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "route_server_client": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "route_server_client": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.soft_reconfiguration", @@ -1292,12 +1296,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "soft_reconfiguration": "{{ True }}" -                            } -                        } -                    } -                } -            } +                                "soft_reconfiguration": "{{ True }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.unsuppress_map", @@ -1327,12 +1331,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "unsuppress_map": "{{ map }}" -                            } -                        } -                    } -                } -            } +                                "unsuppress_map": "{{ map }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "neighbors.weight", @@ -1362,12 +1366,12 @@ class Bgp_address_familyTemplate(NetworkTemplate):                          "address_family": {                              "{{ afi }}": {                                  "afi": "{{ afi }}", -                                "weight": "{{ num }}" -                            } -                        } -                    } -                } -            } +                                "weight": "{{ num }}", +                            }, +                        }, +                    }, +                }, +            },          },      ]      # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/bgp_global.py b/plugins/module_utils/network/vyos/rm_templates/bgp_global.py index 69cccce0..bd95e082 100644 --- a/plugins/module_utils/network/vyos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/bgp_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -30,7 +31,7 @@ def _tmplt_bgp_params_confederation(config_data):                  "protocols bgp {as_number} parameters confederation ".format(**config_data)                  + k                  + " " -                + str(v) +                + str(v),              )      return command @@ -43,7 +44,7 @@ def _tmplt_bgp_maximum_paths(config_data):              "protocols bgp {as_number} maximum-paths ".format(**config_data)              + list_el["path"]              + " " -            + str(list_el["count"]) +            + str(list_el["count"]),          )      return command @@ -88,7 +89,7 @@ def _tmplt_bgp_neighbor_timers(config_data):              + " timers "              + k              + " " -            + str(v) +            + str(v),          )      return command @@ -98,7 +99,7 @@ def _tmplt_bgp_timers(config_data):      command = []      for k, v in iteritems(config_data["timers"]):          command.append( -            "protocols bgp {as_number} ".format(**config_data) + "timers " + k + " " + str(v) +            "protocols bgp {as_number} ".format(**config_data) + "timers " + k + " " + str(v),          )      return command @@ -106,21 +107,21 @@ def _tmplt_bgp_timers(config_data):  def _tmplt_bgp_neighbor_attribute_unchanged_as_path(config_data):      command = "protocols bgp {as_number} ".format( -        **config_data +        **config_data,      ) + "neighbor {address} attribute-unchanged as-path".format(**config_data["neighbor"])      return command  def _tmplt_bgp_neighbor_attribute_unchanged_med(config_data):      command = "protocols bgp {as_number} ".format( -        **config_data +        **config_data,      ) + "neighbor {address} attribute-unchanged med".format(**config_data["neighbor"])      return command  def _tmplt_bgp_neighbor_attribute_unchanged_next_hop(config_data):      command = "protocols bgp {as_number} ".format( -        **config_data +        **config_data,      ) + "neighbor {address} attribute-unchanged next-hop".format(**config_data["neighbor"])      return command @@ -133,7 +134,7 @@ def _tmplt_bgp_neighbor_distribute_list(config_data):              + "neighbor {address} distribute-list ".format(**config_data["neighbor"])              + list_el["action"]              + " " -            + str(list_el["acl"]) +            + str(list_el["acl"]),          )      return command @@ -146,7 +147,7 @@ def _tmplt_bgp_neighbor_route_map(config_data):              + "neighbor {address} route-map ".format(**config_data["neighbor"])              + list_el["action"]              + " " -            + str(list_el["route_map"]) +            + str(list_el["route_map"]),          )      return command @@ -159,7 +160,7 @@ def _tmplt_bgp_neighbor_prefix_list(config_data):              + "neighbor {address} prefix-list ".format(**config_data["neighbor"])              + list_el["action"]              + " " -            + str(list_el["prefix_list"]) +            + str(list_el["prefix_list"]),          )      return command @@ -172,7 +173,7 @@ def _tmplt_bgp_neighbor_filter_list(config_data):              + "neighbor {address} filter-list ".format(**config_data["neighbor"])              + list_el["action"]              + " " -            + str(list_el["path_list"]) +            + str(list_el["path_list"]),          )      return command @@ -191,7 +192,10 @@ class Bgp_globalTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(Bgp_globalTemplate, self).__init__( -            lines=lines, tmplt=self, prefix=prefix, module=module +            lines=lines, +            tmplt=self, +            prefix=prefix, +            module=module,          )      # fmt: off @@ -211,7 +215,7 @@ class Bgp_globalTemplate(NetworkTemplate):              "compval": "as_number",              "result": {                  "as_number": "{{ as_num }}", -            } +            },          },          {              "name": "aggregate_address", @@ -237,10 +241,10 @@ class Bgp_globalTemplate(NetworkTemplate):                      {                          "prefix": "{{ address }}",                          "as_set": "{{ True if as_set is defined }}", -                        "summary_only": "{{ True if summary_only is defined }}" -                    } -                ] -            } +                        "summary_only": "{{ True if summary_only is defined }}", +                    }, +                ], +            },          },          {              "name": "maximum_paths", @@ -265,9 +269,9 @@ class Bgp_globalTemplate(NetworkTemplate):                      {                          "path": "{{ path }}",                          "count": "{{ count }}", -                    } -                ] -            } +                    }, +                ], +            },          },          {              "name": "neighbor.advertisement_interval", @@ -292,10 +296,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "advertisement_interval": "{{ interval }}" -                    } -                } -            } +                        "advertisement_interval": "{{ interval }}", +                    }, +                }, +            },          },          {              "name": "neighbor.allowas_in", @@ -320,10 +324,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "allowas_in": "{{ count }}" -                    } -                } -            } +                        "allowas_in": "{{ count }}", +                    }, +                }, +            },          },          {              "name": "neighbor.as_override", @@ -346,10 +350,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "as_override": "{{ True }}" -                    } -                } -            } +                        "as_override": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.attribute_unchanged.as_path", @@ -374,11 +378,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "{{ address }}": {                          "address": "{{ address }}",                          "attribute_unchanged": { -                            "{{ 'as_path' }}": "{{ True }}" -                        } -                    } -                } -            } +                            "{{ 'as_path' }}": "{{ True }}", +                        }, +                    }, +                }, +            },          },          {              "name": "neighbor.attribute_unchanged.med", @@ -403,11 +407,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "{{ address }}": {                          "address": "{{ address }}",                          "attribute_unchanged": { -                            "{{ 'med' }}": "{{ True }}" -                        } -                    } -                } -            } +                            "{{ 'med' }}": "{{ True }}", +                        }, +                    }, +                }, +            },          },          {              "name": "neighbor.attribute_unchanged.next_hop", @@ -432,11 +436,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "{{ address }}": {                          "address": "{{ address }}",                          "attribute_unchanged": { -                            "{{ 'next_hop' }}": "{{ True }}" -                        } -                    } -                } -            } +                            "{{ 'next_hop' }}": "{{ True }}", +                        }, +                    }, +                }, +            },          },          {              "name": "neighbor.capability_dynamic", @@ -461,11 +465,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "{{ address }}": {                          "address": "{{ address }}",                          "capability": { -                            "dynamic": "{{ True if dynamic is defined}}" -                        } -                    } -                } -            } +                            "dynamic": "{{ True if dynamic is defined}}", +                        }, +                    }, +                }, +            },          },          {              "name": "neighbor.capability_orf", @@ -492,11 +496,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "{{ address }}": {                          "address": "{{ address }}",                          "capability": { -                            "orf": "{{ orf }}" -                        } -                    } -                } -            } +                            "orf": "{{ orf }}", +                        }, +                    }, +                }, +            },          },          {              "name": "neighbor.default_originate", @@ -521,10 +525,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "default_originate": "{{ map }}" -                    } -                } -            } +                        "default_originate": "{{ map }}", +                    }, +                }, +            },          },          {              "name": "neighbor.description", @@ -548,10 +552,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "description": "{{ desc }}" -                    } -                } -            } +                        "description": "{{ desc }}", +                    }, +                }, +            },          },          {              "name": "neighbor.disable_capability_negotiation", @@ -574,10 +578,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "disable_capability_negotiation": "{{ True }}" -                    } -                } -            } +                        "disable_capability_negotiation": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.disable_connected_check", @@ -600,10 +604,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "disable_connected_check": "{{ True }}" -                    } -                } -            } +                        "disable_connected_check": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.disable_send_community", @@ -627,10 +631,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "disable_send_community": "{{ comm }}" -                    } -                } -            } +                        "disable_send_community": "{{ comm }}", +                    }, +                }, +            },          },          {              "name": "neighbor.distribute_list", @@ -658,12 +662,12 @@ class Bgp_globalTemplate(NetworkTemplate):                          "distribute_list": [                              {                                  "action": "{{ action }}", -                                "acl": "{{ list }}" -                            } -                        ] -                    } -                } -            } +                                "acl": "{{ list }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "neighbor.ebgp_multihop", @@ -687,10 +691,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "ebgp_multihop": "{{ hop|int }}" -                    } -                } -            } +                        "ebgp_multihop": "{{ hop|int }}", +                    }, +                }, +            },          },          {              "name": "neighbor.filter_list", @@ -718,12 +722,12 @@ class Bgp_globalTemplate(NetworkTemplate):                          "filter_list": [                              {                                  "action": "{{ action }}", -                                "path_list": "{{ list }}" -                            } -                        ] -                    } -                } -            } +                                "path_list": "{{ list }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "neighbor.local_as", @@ -748,10 +752,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "local_as": "{{ as }}" -                    } -                } -            } +                        "local_as": "{{ as }}", +                    }, +                }, +            },          },          {              "name": "neighbor.maximum_prefix", @@ -775,10 +779,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "maximum_prefix": "{{ num }}" -                    } -                } -            } +                        "maximum_prefix": "{{ num }}", +                    }, +                }, +            },          },          {              "name": "neighbor.nexthop_self", @@ -801,10 +805,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "nexthop_self": "{{ True }}" -                    } -                } -            } +                        "nexthop_self": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.override_capability", @@ -827,10 +831,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "override_capability": "{{ True }}" -                    } -                } -            } +                        "override_capability": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.passive", @@ -853,10 +857,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "passive": "{{ True }}" -                    } -                } -            } +                        "passive": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.password", @@ -880,10 +884,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "password": "{{ pwd }}" -                    } -                } -            } +                        "password": "{{ pwd }}", +                    }, +                }, +            },          },          {              "name": "neighbor.peer_group_name", @@ -907,10 +911,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "peer_group_name": "{{ name }}" -                    } -                } -            } +                        "peer_group_name": "{{ name }}", +                    }, +                }, +            },          },          {              "name": "neighbor.port", @@ -934,10 +938,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "port": "{{ num|int }}" -                    } -                } -            } +                        "port": "{{ num|int }}", +                    }, +                }, +            },          },          {              "name": "neighbor.prefix_list", @@ -965,12 +969,12 @@ class Bgp_globalTemplate(NetworkTemplate):                          "prefix_list": [                              {                                  "action": "{{ action }}", -                                "prefix_list": "{{ list }}" -                            } -                        ] -                    } -                } -            } +                                "prefix_list": "{{ list }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "neighbor.remote_as", @@ -994,10 +998,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "remote_as": "{{ num|int }}" -                    } -                } -            } +                        "remote_as": "{{ num|int }}", +                    }, +                }, +            },          },          {              "name": "neighbor.remove_private_as", @@ -1020,10 +1024,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "remove_private_as": "{{ True }}" -                    } -                } -            } +                        "remove_private_as": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.route_map", @@ -1051,12 +1055,12 @@ class Bgp_globalTemplate(NetworkTemplate):                          "route_map": [                              {                                  "action": "{{ action }}", -                                "route_map": "{{ map }}" -                            } -                        ] -                    } -                } -            } +                                "route_map": "{{ map }}", +                            }, +                        ], +                    }, +                }, +            },          },          {              "name": "neighbor.route_reflector_client", @@ -1079,10 +1083,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "route_reflector_client": "{{ True }}" -                    } -                } -            } +                        "route_reflector_client": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.route_server_client", @@ -1105,10 +1109,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "route_server_client": "{{ True }}" -                    } -                } -            } +                        "route_server_client": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.shutdown", @@ -1131,10 +1135,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "shutdown": "{{ True }}" -                    } -                } -            } +                        "shutdown": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.soft_reconfiguration", @@ -1158,10 +1162,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "soft_reconfiguration": "{{ True }}" -                    } -                } -            } +                        "soft_reconfiguration": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.strict_capability_match", @@ -1184,10 +1188,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "strict_capability_match": "{{ True }}" -                    } -                } -            } +                        "strict_capability_match": "{{ True }}", +                    }, +                }, +            },          },          {              "name": "neighbor.unsuppress_map", @@ -1211,10 +1215,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "unsuppress_map": "{{ map }}" -                    } -                } -            } +                        "unsuppress_map": "{{ map }}", +                    }, +                }, +            },          },          {              "name": "neighbor.update_source", @@ -1238,10 +1242,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "update_source": "{{ src }}" -                    } -                } -            } +                        "update_source": "{{ src }}", +                    }, +                }, +            },          },          {              "name": "neighbor.weight", @@ -1265,10 +1269,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "weight": "{{ num }}" -                    } -                } -            } +                        "weight": "{{ num }}", +                    }, +                }, +            },          },          {              "name": "neighbor.ttl_security", @@ -1292,10 +1296,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "neighbor": {                      "{{ address }}": {                          "address": "{{ address }}", -                        "ttl_security": "{{ ttl|int }}" -                    } -                } -            } +                        "ttl_security": "{{ ttl|int }}", +                    }, +                }, +            },          },          {              "name": "neighbor.timers", @@ -1322,11 +1326,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "{{ address }}": {                          "address": "{{ address }}",                          "timers": { -                            "{{ type }}": "{{ sec }}" -                        } -                    } -                } -            } +                            "{{ type }}": "{{ sec }}", +                        }, +                    }, +                }, +            },          },          {              "name": "network.backdoor", @@ -1350,10 +1354,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "network": [                      {                          "address": "{{ address }}", -                        "backdoor": "{{ True }}" -                    } -                ] -            } +                        "backdoor": "{{ True }}", +                    }, +                ], +            },          },          {              "name": "network.route_map", @@ -1378,10 +1382,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "network": [                      {                          "address": "{{ address }}", -                        "route_map": "{{ map }}" -                    } -                ] -            } +                        "route_map": "{{ map }}", +                    }, +                ], +            },          },          {              "name": "redistribute.metric", @@ -1406,10 +1410,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "redistribute": [                      {                          "protocol": "{{ proto }}", -                        "metric": "{{ val|int }}" -                    } -                ] -            } +                        "metric": "{{ val|int }}", +                    }, +                ], +            },          },          {              "name": "redistribute.route_map", @@ -1434,10 +1438,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "redistribute": [                      {                          "protocol": "{{ proto }}", -                        "route_map": "{{ val }}" -                    } -                ] -            } +                        "route_map": "{{ val }}", +                    }, +                ], +            },          },          {              "name": "timers", @@ -1460,8 +1464,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "timers": {                      "{{ type }}": "{{ val }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.always_compare_med", @@ -1482,8 +1486,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "always_compare_med": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.bestpath.as_path", @@ -1507,9 +1511,9 @@ class Bgp_globalTemplate(NetworkTemplate):                  "bgp_params": {                      "bestpath": {                          "as_path": "{{ path }}", -                    } -                } -            } +                    }, +                }, +            },          },          {              "name": "bgp_params.bestpath.compare_routerid", @@ -1532,9 +1536,9 @@ class Bgp_globalTemplate(NetworkTemplate):                  "bgp_params": {                      "bestpath": {                          "compare_routerid": "{{ True }}", -                    } -                } -            } +                    }, +                }, +            },          },          {              "name": "bgp_params.bestpath.med", @@ -1558,9 +1562,9 @@ class Bgp_globalTemplate(NetworkTemplate):                  "bgp_params": {                      "bestpath": {                          "med": "{{ path }}", -                    } -                } -            } +                    }, +                }, +            },          },          {              "name": "bgp_params.cluster_id", @@ -1582,8 +1586,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "cluster_id": "{{ id }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.confederation", @@ -1608,11 +1612,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "confederation": [                          {                              "peers": "{{ val if type == 'peers' }}", -                            "identifier": "{{ val if type == 'identifier' }}" -                        } -                    ] -                } -            } +                            "identifier": "{{ val if type == 'identifier' }}", +                        }, +                    ], +                }, +            },          },          {              "name": "bgp_params.dampening_half_life", @@ -1635,10 +1639,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "dampening": { -                        "half_life": "{{ val }}" -                    } -                } -            } +                        "half_life": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "bgp_params.dampening_max_suppress_time", @@ -1661,10 +1665,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "dampening": { -                        "max_suppress_time": "{{ val }}" -                    } -                } -            } +                        "max_suppress_time": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "bgp_params.dampening_re_use", @@ -1687,10 +1691,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "dampening": { -                        "re_use": "{{ val }}" -                    } -                } -            } +                        "re_use": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "bgp_params.dampening_start_suppress_time", @@ -1713,10 +1717,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "dampening": { -                        "start_suppress_time": "{{ val }}" -                    } -                } -            } +                        "start_suppress_time": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "bgp_params.default", @@ -1741,10 +1745,10 @@ class Bgp_globalTemplate(NetworkTemplate):                  "bgp_params": {                      "default": {                          "no_ipv4_unicast": "{{ True if no_ipv4_unicast is defined }}", -                        "local_pref": "{{ local_pref.split(" " )[1] if local_pref is defined }}" -                    } -                } -            } +                        "local_pref": "{{ local_pref.split(" " )[1] if local_pref is defined }}", +                    }, +                }, +            },          },          {              "name": "bgp_params.deterministic_med", @@ -1765,8 +1769,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "deterministic_med": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.disbale_network_import_check", @@ -1787,8 +1791,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "disable_network_import_check": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.distance.prefix", @@ -1815,11 +1819,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "distance": [                          {                              "prefix": "{{ prefix }}", -                            "value": "{{ val }}" -                        } -                    ] -                } -            } +                            "value": "{{ val }}", +                        }, +                    ], +                }, +            },          },          {              "name": "bgp_params.distance.global", @@ -1845,11 +1849,11 @@ class Bgp_globalTemplate(NetworkTemplate):                      "distance": [                          {                              "type": "{{ type }}", -                            "value": "{{ val }}" -                        } -                    ] -                } -            } +                            "value": "{{ val }}", +                        }, +                    ], +                }, +            },          },          {              "name": "bgp_params.enforce_first_as", @@ -1870,8 +1874,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "enforce_first_as": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.graceful_restart", @@ -1893,8 +1897,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "graceful_restart": "{{ val }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.log_neighbor_changes", @@ -1915,8 +1919,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "log_neighbor_changes": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.no_client_to_client_reflection", @@ -1937,8 +1941,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "no_client_to_client_reflection": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.no_fast_external_failover", @@ -1959,8 +1963,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "no_fast_external_failover": "{{ True }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.routerid", @@ -1982,8 +1986,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "router_id": "{{ id }}", -                } -            } +                }, +            },          },          {              "name": "bgp_params.scan_time", @@ -2005,8 +2009,8 @@ class Bgp_globalTemplate(NetworkTemplate):                  "as_number": "{{ as_num }}",                  "bgp_params": {                      "scan_time": "{{ val }}", -                } -            } +                }, +            },          },      ] diff --git a/plugins/module_utils/network/vyos/rm_templates/hostname.py b/plugins/module_utils/network/vyos/rm_templates/hostname.py index 73527941..29ab00f6 100644 --- a/plugins/module_utils/network/vyos/rm_templates/hostname.py +++ b/plugins/module_utils/network/vyos/rm_templates/hostname.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -25,7 +26,10 @@ class HostnameTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(HostnameTemplate, self).__init__( -            lines=lines, tmplt=self, prefix=prefix, module=module +            lines=lines, +            tmplt=self, +            prefix=prefix, +            module=module,          )      # fmt: off @@ -38,11 +42,12 @@ class HostnameTemplate(NetworkTemplate):                  ^set\ssystem\shost-name                  \s+(?P<name>\S+)                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system host-name {{ hostname }}",              "result": { -                "hostname": "{{ name }}" -            } +                "hostname": "{{ name }}", +            },          },      ]      # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/logging_global.py b/plugins/module_utils/network/vyos/rm_templates/logging_global.py index 82a49638..6c692cfd 100644 --- a/plugins/module_utils/network/vyos/rm_templates/logging_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/logging_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -66,7 +67,10 @@ class Logging_globalTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(Logging_globalTemplate, self).__init__( -            lines=lines, tmplt=self, prefix=prefix, module=module +            lines=lines, +            tmplt=self, +            prefix=prefix, +            module=module,          )      # fmt: off @@ -77,13 +81,14 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem                  (\s(?P<syslog>syslog)) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog",              "result": {                  "syslog": {                      "state": "{{ 'enabled' if syslog is defined else 'disabled' }}", -                } -            } +                }, +            },          },          {              "name": "console.facilities", @@ -92,17 +97,19 @@ class Logging_globalTemplate(NetworkTemplate):                  ^set\ssystem\ssyslog\sconsole\sfacility                  (\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))?                  (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": tmplt_params,              "remval": "system syslog console facility {{ console.facilities.facility }}",              "result": {                  "console": { -                    "facilities": [{ -                        "facility": "{{ facility }}", -                        "severity": "{{ level }}", -                    }, ] -                } -            } +                    "facilities": [ +                        { +                            "facility": "{{ facility }}", +                            "severity": "{{ level }}", +                        }, ], +                }, +            },          },          {              "name": "console.state", @@ -110,13 +117,14 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog                  (\s(?P<console>console)) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog console",              "result": {                  "console": {                      "state": "{{ 'enabled' if console is defined else 'disabled' }}", -                } -            } +                }, +            },          },          {              "name": "files.archive.state", @@ -125,7 +133,8 @@ class Logging_globalTemplate(NetworkTemplate):                  ^set\ssystem\ssyslog\sfile                  (\s(?P<path>\S+))?                  (\s(?P<archive>archive)) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog file {{ files.path }} archive",              "result": {                  "files": { @@ -135,8 +144,8 @@ class Logging_globalTemplate(NetworkTemplate):                              "state": "{{ 'enabled' if archive is defined else 'disabled' }}",                          },                      }, -                } -            } +                }, +            },          },          {              "name": "files.archive.size", @@ -145,7 +154,8 @@ class Logging_globalTemplate(NetworkTemplate):                  ^set\ssystem\ssyslog\sfile                  (\s(?P<path>\S+))?                  (\sarchive\ssize\s(?P<size>'(\d+)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog file {{ files.path }} archive size {{ files.archive.size }}",              "result": {                  "files": { @@ -155,8 +165,8 @@ class Logging_globalTemplate(NetworkTemplate):                              "size": "{{ size }}",                          },                      }, -                } -            } +                }, +            },          },          {              "name": "files.archive.file_num", @@ -165,7 +175,8 @@ class Logging_globalTemplate(NetworkTemplate):                  ^set\ssystem\ssyslog\sfile                  (\s(?P<path>\S+))?                  (\sarchive\sfile\s(?P<file_num>'(\d+)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog file {{ files.path }} archive file {{ files.archive.file_num }}",              "result": {                  "files": { @@ -175,8 +186,8 @@ class Logging_globalTemplate(NetworkTemplate):                              "file_num": "{{ file_num }}",                          },                      }, -                } -            } +                }, +            },          },          {              "name": "files", @@ -186,20 +197,22 @@ class Logging_globalTemplate(NetworkTemplate):                  (\s(?P<path>\S+))?                  (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))?                  (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": tmplt_params,              "remval": "system syslog file{{ (' ' + files.path) if files.path|d('') is defined else '' }}",              "result": {                  "files": {                      "{{ path }}": {                          "path": "{{ path }}", -                        "facilities": [{ -                            "facility": "{{ facility }}", -                            "severity": "{{ level }}", -                        }, ] +                        "facilities": [ +                            { +                                "facility": "{{ facility }}", +                                "severity": "{{ level }}", +                            }, ],                      }, -                } -            } +                }, +            },          },          {              "name": "global_params.state", @@ -207,13 +220,14 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog                  (\s(?P<global>global)) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog global",              "result": {                  "global_params": {                      "state": "{{ 'enabled' if global is defined else 'disabled' }}", -                } -            } +                }, +            },          },          {              "name": "global_params.archive.state", @@ -221,15 +235,16 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog\sglobal                  (\s(?P<archive>archive)) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog global archive",              "result": {                  "global_params": {                      "archive": {                          "state": "{{ 'enabled' if archive is defined else 'disabled' }}",                      }, -                } -            } +                }, +            },          },          {              "name": "global_params.archive.file_num", @@ -237,15 +252,16 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog\sglobal\sarchive\sfile                  (\s(?P<file_num>'(\d+)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog global archive file {{ global_params.archive.file_num }}",              "result": {                  "global_params": {                      "archive": {                          "file_num": "{{ file_num }}",                      }, -                } -            } +                }, +            },          },          {              "name": "global_params.archive.size", @@ -253,15 +269,16 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog\sglobal\sarchive\ssize                  (\s(?P<size>'(\d+)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog global archive size {{ global_params.archive.size }}",              "result": {                  "global_params": {                      "archive": {                          "size": "{{ size }}",                      }, -                } -            } +                }, +            },          },          {              "name": "global_params.marker_interval", @@ -269,14 +286,15 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog\sglobal\smarker\sinterval                  (\s(?P<marker_interval>'(\d+)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog global marker interval {{ global_params.marker_interval }}",              "remval": "system syslog global marker",              "result": {                  "global_params": {                      "marker_interval": "{{ marker_interval }}", -                } -            } +                }, +            },          },          {              "name": "global_params.preserve_fqdn", @@ -284,13 +302,14 @@ class Logging_globalTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\ssyslog\sglobal                  (\s(?P<preserve_fqdn>preserve-fqdn)) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog global preserve-fqdn",              "result": {                  "global_params": {                      "preserve_fqdn": "{{ True if preserve_fqdn is defined }}", -                } -            } +                }, +            },          },          {              "name": "global_params.facilities", @@ -299,17 +318,19 @@ class Logging_globalTemplate(NetworkTemplate):                  ^set\ssystem\ssyslog\sglobal\sfacility                  (\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))?                  (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": tmplt_params,              "remval": "system syslog global facility {{ global_params.facilities.facility }}",              "result": {                  "global_params": { -                    "facilities": [{ -                        "facility": "{{ facility }}", -                        "severity": "{{ level }}", -                    }, ], -                } -            } +                    "facilities": [ +                        { +                            "facility": "{{ facility }}", +                            "severity": "{{ level }}", +                        }, ], +                }, +            },          },          {              "name": "hosts.port", @@ -318,7 +339,8 @@ class Logging_globalTemplate(NetworkTemplate):                  ^set\ssystem\ssyslog\shost                  (\s(?P<hostname>\S+))                  (\sport\s(?P<port>'(\d+)')) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "system syslog host {{ hosts.hostname }} port {{ hosts.port }}",              "result": {                  "hosts": { @@ -326,8 +348,8 @@ class Logging_globalTemplate(NetworkTemplate):                          "hostname": "{{ hostname }}",                          "port": "{{ port }}",                      }, -                } -            } +                }, +            },          },          {              "name": "hosts", @@ -338,21 +360,23 @@ class Logging_globalTemplate(NetworkTemplate):                  (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))                  (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))?                  (\sprotocol\s(?P<protocol>'(udp|tcp)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": tmplt_params,              "remval": "system syslog host {{ hosts.hostname }}",              "result": {                  "hosts": {                      "{{ hostname }}": {                          "hostname": "{{ hostname }}", -                        "facilities": [{ -                            "facility": "{{ facility }}", -                            "severity": "{{ level }}", -                            "protocol": "{{ protocol }}", -                        }, ] +                        "facilities": [ +                            { +                                "facility": "{{ facility }}", +                                "severity": "{{ level }}", +                                "protocol": "{{ protocol }}", +                            }, ],                      }, -                } -            } +                }, +            },          },          {              "name": "users", @@ -362,20 +386,22 @@ class Logging_globalTemplate(NetworkTemplate):                  (\s(?P<username>\S+))?                  (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))?                  (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": tmplt_params,              "remval": "system syslog user {{ users.username }}",              "result": {                  "users": {                      "{{ username }}": {                          "username": "{{ username }}", -                        "facilities": [{ -                            "facility": "{{ facility }}", -                            "severity": "{{ level }}", -                        }, ] -                    } -                } -            } +                        "facilities": [ +                            { +                                "facility": "{{ facility }}", +                                "severity": "{{ level }}", +                            }, ], +                    }, +                }, +            },          },      ]      # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/ntp_global.py b/plugins/module_utils/network/vyos/rm_templates/ntp_global.py index 52540352..33d173e0 100644 --- a/plugins/module_utils/network/vyos/rm_templates/ntp_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/ntp_global.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -36,11 +37,12 @@ class NtpTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\sntp\sallow-clients\saddress (\s(?P<ipaddress>\S+))?                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system ntp allow-clients address {{allow_clients}}",              "result": { -                "allow_clients": ["{{ipaddress}}"] -            } +                "allow_clients": ["{{ipaddress}}"], +            },          },          # set system ntp allow_clients @@ -50,11 +52,12 @@ class NtpTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\sntp\sallow-clients                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system ntp allow-clients",              "result": { -            } +            },          }, @@ -65,11 +68,12 @@ class NtpTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\sntp\slisten-address (\s(?P<ip_address>\S+))?                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system ntp listen-address {{listen_addresses}}",              "result": { -                "listen_addresses": ["{{ip_address}}"] -            } +                "listen_addresses": ["{{ip_address}}"], +            },          },          # set system ntp listen_address @@ -79,10 +83,11 @@ class NtpTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\sntp\slisten-address                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system ntp listen-address",              "result": { -            } +            },          },          # set system ntp server <name> @@ -92,16 +97,17 @@ class NtpTemplate(NetworkTemplate):                  r"""                  ^set\ssystem\sntp\sserver (\s(?P<name>\S+))?                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system ntp server {{server}}",              "result": {                  "servers": {                      "{{name}}": { -                        "server": "{{name}}" -                    } -                } +                        "server": "{{name}}", +                    }, +                }, -            } +            },          },          # set system ntp server <name> <options> @@ -113,16 +119,17 @@ class NtpTemplate(NetworkTemplate):                  \s(?P<name>\S+)                  \s(?P<options>noselect|dynamic|pool|preempt|prefer)?                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "system ntp server {{server}} {{options}}",              "result": {                  "servers": {                      "{{name}}": {                          "server": "{{name}}", -                        "options": ["{{options}}"] -                    } -                } -            } -        } +                        "options": ["{{options}}"], +                    }, +                }, +            }, +        },      ]      # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py b/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py index de3beba7..aaaf7ff2 100644 --- a/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -70,7 +71,7 @@ def _tmplt_ospf_int_auth_password(config_data):          + " "          + params[0]          + " authentication plaintext-password {plaintext_password}".format( -            **config_data["address_family"]["authentication"] +            **config_data["address_family"]["authentication"],          )      )      return command @@ -87,7 +88,7 @@ def _tmplt_ospf_int_auth_md5(config_data):          + " "          + params[0]          + " authentication md5 key-id {key_id} ".format( -            **config_data["address_family"]["authentication"]["md5_key"] +            **config_data["address_family"]["authentication"]["md5_key"],          )          + "md5-key {key}".format(**config_data["address_family"]["authentication"]["md5_key"])      ) @@ -291,7 +292,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(Ospf_interfacesTemplate, self).__init__( -            lines=lines, tmplt=self, prefix=prefix, module=module +            lines=lines, +            tmplt=self, +            prefix=prefix, +            module=module,          )      # fmt: off @@ -316,9 +320,9 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                    } -                } -            } +                    }, +                }, +            },          },          {              "name": "authentication_password", @@ -344,11 +348,11 @@ class Ospf_interfacesTemplate(NetworkTemplate):                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}',                          "authentication": { -                            "plaintext_password": "{{ text }}" -                        } -                    } -                } -            } +                            "plaintext_password": "{{ text }}", +                        }, +                    }, +                }, +            },          },          {              "name": "authentication_md5", @@ -380,12 +384,12 @@ class Ospf_interfacesTemplate(NetworkTemplate):                          "authentication": {                              "md5_key": {                                  "key_id": "{{ id }}", -                                "key": "{{ text }}" -                            } -                        } -                    } -                } -            } +                                "key": "{{ text }}", +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "bandwidth", @@ -409,10 +413,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "bandwidth": "{{ bw }}" -                    } -                } -            } +                        "bandwidth": "{{ bw }}", +                    }, +                }, +            },          },          {              "name": "cost", @@ -436,10 +440,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "cost": "{{ val }}" -                    } -                } -            } +                        "cost": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "hello_interval", @@ -463,10 +467,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "hello_interval": "{{ val }}" -                    } -                } -            } +                        "hello_interval": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "dead_interval", @@ -490,10 +494,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "dead_interval": "{{ val }}" -                    } -                } -            } +                        "dead_interval": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "mtu_ignore", @@ -516,10 +520,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "mtu_ignore": "{{ True if mtu is defined }}" -                    } -                } -            } +                        "mtu_ignore": "{{ True if mtu is defined }}", +                    }, +                }, +            },          },          {              "name": "network", @@ -543,10 +547,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "network": "{{ val }}" -                    } -                } -            } +                        "network": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "priority", @@ -570,10 +574,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "priority": "{{ val }}" -                    } -                } -            } +                        "priority": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "retransmit_interval", @@ -597,10 +601,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "retransmit_interval": "{{ val }}" -                    } -                } -            } +                        "retransmit_interval": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "transmit_delay", @@ -624,10 +628,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "transmit_delay": "{{ val }}" -                    } -                } -            } +                        "transmit_delay": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "ifmtu", @@ -651,10 +655,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "ifmtu": "{{ val }}" -                    } -                } -            } +                        "ifmtu": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "instance", @@ -678,10 +682,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "instance": "{{ val }}" -                    } -                } -            } +                        "instance": "{{ val }}", +                    }, +                }, +            },          },          {              "name": "passive", @@ -704,10 +708,10 @@ class Ospf_interfacesTemplate(NetworkTemplate):                  "address_family": {                      "{{ afi }}": {                          "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', -                        "passive": "{{ True if pass is defined }}" -                    } -                } -            } +                        "passive": "{{ True if pass is defined }}", +                    }, +                }, +            },          },          {              "name": "interface_name", @@ -723,7 +727,7 @@ class Ospf_interfacesTemplate(NetworkTemplate):              "setval": "set interface {{ type }} {{ name }}",              "result": {                  "name": "{{ name }}", -            } +            },          },      ]      # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py b/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py index 00a157e4..0e99cfea 100644 --- a/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py +++ b/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -25,7 +26,10 @@ class Prefix_listsTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(Prefix_listsTemplate, self).__init__( -            lines=lines, tmplt=self, module=module, prefix=prefix +            lines=lines, +            tmplt=self, +            module=module, +            prefix=prefix,          )      # fmt: off @@ -39,7 +43,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \spolicy                  \sprefix-(?P<afi>\S+)                  \s(?P<name>\S+) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }}",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -47,9 +52,9 @@ class Prefix_listsTemplate(NetworkTemplate):                      "prefix_lists": {                          "{{ name }}": {                              "name": "{{ name }}", -                        } -                    } -                } +                        }, +                    }, +                },              },          }, @@ -63,7 +68,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \sprefix-(?P<afi>\S+)                  \s(?P<name>\S+)                  \sdescription\s'(?P<description>.+)' -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} description '{{ description }}'",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -71,10 +77,10 @@ class Prefix_listsTemplate(NetworkTemplate):                      "prefix_lists": {                          "{{ name }}": {                              "name": "{{ name }}", -                            "description": "{{ description }}" -                        } -                    } -                } +                            "description": "{{ description }}", +                        }, +                    }, +                },              },          }, @@ -88,7 +94,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \sprefix-(?P<afi>\S+)                  \s(?P<name>\S+)                  \srule\s(?P<sequence>\d+) -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }}",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -98,12 +105,12 @@ class Prefix_listsTemplate(NetworkTemplate):                              "name": "{{ name }}",                              "entries": {                                  "{{ sequence }}": { -                                    "sequence": "{{ sequence }}" -                                } -                            } -                        } -                    } -                } +                                    "sequence": "{{ sequence }}", +                                }, +                            }, +                        }, +                    }, +                },              },          }, @@ -118,7 +125,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \s(?P<name>\S+)                  \srule\s(?P<sequence>\d+)                  \saction\s'(?P<action>permit|deny)' -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} action '{{ action }}'",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -129,12 +137,12 @@ class Prefix_listsTemplate(NetworkTemplate):                              "entries": {                                  "{{ sequence }}": {                                      "sequence": "{{ sequence }}", -                                    "action": "{{ action }}" -                                } -                            } -                        } -                    } -                } +                                    "action": "{{ action }}", +                                }, +                            }, +                        }, +                    }, +                },              },          }, @@ -149,7 +157,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \s(?P<name>\S+)                  \srule\s(?P<sequence>\d+)                  \sdescription\s'(?P<rule_description>.+)' -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "compval": "description",              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} description '{{ description }}'",              "result": { @@ -161,12 +170,12 @@ class Prefix_listsTemplate(NetworkTemplate):                              "entries": {                                  "{{ sequence }}": {                                      "sequence": "{{ sequence }}", -                                    "description": "{{ rule_description }}" -                                } -                            } -                        } -                    } -                } +                                    "description": "{{ rule_description }}", +                                }, +                            }, +                        }, +                    }, +                },              },          }, @@ -181,7 +190,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \s(?P<name>\S+)                  \srule\s(?P<sequence>\d+)                  \sge\s'(?P<ge>\d+)' -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} ge '{{ ge }}'",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -192,12 +202,12 @@ class Prefix_listsTemplate(NetworkTemplate):                              "entries": {                                  "{{ sequence }}": {                                      "sequence": "{{ sequence }}", -                                    "ge": "{{ ge }}" -                                } -                            } -                        } -                    } -                } +                                    "ge": "{{ ge }}", +                                }, +                            }, +                        }, +                    }, +                },              },          }, @@ -212,7 +222,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \s(?P<name>\S+)                  \srule\s(?P<sequence>\d+)                  \sle\s'(?P<le>\d+)' -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} le '{{ le }}'",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -223,12 +234,12 @@ class Prefix_listsTemplate(NetworkTemplate):                              "entries": {                                  "{{ sequence }}": {                                      "sequence": "{{ sequence }}", -                                    "le": "{{ le }}" -                                } -                            } -                        } -                    } -                } +                                    "le": "{{ le }}", +                                }, +                            }, +                        }, +                    }, +                },              },          }, @@ -243,7 +254,8 @@ class Prefix_listsTemplate(NetworkTemplate):                  \s(?P<name>\S+)                  \srule\s(?P<sequence>\d+)                  \sprefix\s'(?P<prefix>\S+)' -                $""", re.VERBOSE), +                $""", re.VERBOSE, +            ),              "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} prefix '{{ prefix }}'",              "result": {                  "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -254,12 +266,12 @@ class Prefix_listsTemplate(NetworkTemplate):                              "entries": {                                  "{{ sequence }}": {                                      "sequence": "{{ sequence }}", -                                    "prefix": "{{ prefix }}" -                                } -                            } -                        } -                    } -                } +                                    "prefix": "{{ prefix }}", +                                }, +                            }, +                        }, +                    }, +                },              },          },      ] diff --git a/plugins/module_utils/network/vyos/rm_templates/route_maps.py b/plugins/module_utils/network/vyos/rm_templates/route_maps.py index 1652a23c..8f218a6b 100644 --- a/plugins/module_utils/network/vyos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/vyos/rm_templates/route_maps.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -42,8 +43,8 @@ class Route_mapsTemplate(NetworkTemplate):                  "route_maps": {                      "{{ route_map }}": {                          "route_map": '{{ route_map }}', -                    } -                } +                    }, +                },              },          },          { @@ -63,12 +64,12 @@ class Route_mapsTemplate(NetworkTemplate):                          "entries": {                              "{{sequence}}":                                  { -                                    "sequence": "{{sequence}}" -                                } -                        } -                    } -                } -            } +                                    "sequence": "{{sequence}}", +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "call", @@ -87,12 +88,12 @@ class Route_mapsTemplate(NetworkTemplate):                              "{{sequence}}":                                  {                                      "sequence": "{{sequence}}", -                                    "call": "{{call}}" -                                } -                        } -                    } -                } -            } +                                    "call": "{{call}}", +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "description", @@ -111,12 +112,12 @@ class Route_mapsTemplate(NetworkTemplate):                              "{{sequence}}":                                  {                                      "sequence": "{{sequence}}", -                                    "description": "{{description}}" -                                } -                        } -                    } -                } -            } +                                    "description": "{{description}}", +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "action", @@ -135,12 +136,12 @@ class Route_mapsTemplate(NetworkTemplate):                              "{{sequence}}":                                  {                                      "sequence": "{{sequence}}", -                                    "action": "{{action}}" -                                } -                        } -                    } -                } -            } +                                    "action": "{{action}}", +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "continue_sequence", @@ -159,12 +160,12 @@ class Route_mapsTemplate(NetworkTemplate):                              "{{sequence}}":                                  {                                      "sequence": "{{sequence}}", -                                    "continue_sequence": "{{continue}}" -                                } -                        } -                    } -                } -            } +                                    "continue_sequence": "{{continue}}", +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "on_match_next", @@ -185,13 +186,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "on_match": { -                                        "next": "{{True if next is defined}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "next": "{{True if next is defined}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "on_match_goto", @@ -212,13 +213,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "on_match": { -                                        "goto": "{{goto}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "goto": "{{goto}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_aggregator_ip", @@ -240,14 +241,14 @@ class Route_mapsTemplate(NetworkTemplate):                                      "sequence": "{{sequence}}",                                      "set": {                                          "aggregator": { -                                            "ip": "{{ip}}" -                                        } -                                    } -                                } -                        } -                    } -                } -            } +                                            "ip": "{{ip}}", +                                        }, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_aggregator_as", @@ -269,14 +270,14 @@ class Route_mapsTemplate(NetworkTemplate):                                      "sequence": "{{sequence}}",                                      "set": {                                          "aggregator": { -                                            "as": "{{as}}" -                                        } -                                    } -                                } -                        } -                    } -                } -            } +                                            "as": "{{as}}", +                                        }, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_as_path_exclude", @@ -297,13 +298,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "as_path_exclude": "{{as}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "as_path_exclude": "{{as}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_as_path_prepend", @@ -324,13 +325,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "as_path_prepend": "{{as}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "as_path_prepend": "{{as}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_atomic_aggregate", @@ -350,13 +351,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "atomic_aggregate": "{{True if as is defined}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "atomic_aggregate": "{{True if as is defined}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_bgp_extcommunity_rt", @@ -378,13 +379,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "bgp_extcommunity_rt": "{{bgp}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "bgp_extcommunity_rt": "{{bgp}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_comm_list", @@ -406,13 +407,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "comm_list": {"comm_list": "{{comm_list}}"} -                                    } -                                } -                        } -                    } -                } -            } +                                        "comm_list": {"comm_list": "{{comm_list}}"}, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_comm_list_delete", @@ -434,13 +435,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "comm_list": {"delete": "{{True if delete is defined}}"} -                                    } -                                } -                        } -                    } -                } -            } +                                        "comm_list": {"delete": "{{True if delete is defined}}"}, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_extcommunity_rt", @@ -462,13 +463,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "extcommunity_rt": "{{extcommunity_rt}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "extcommunity_rt": "{{extcommunity_rt}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_extcommunity_soo", @@ -490,13 +491,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "extcommunity_soo": "{{set.extcommunity_soo}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "extcommunity_soo": "{{set.extcommunity_soo}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_ip_next_hop", @@ -518,13 +519,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "ip_next_hop": "{{ip_next_hop}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "ip_next_hop": "{{ip_next_hop}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_ipv6_next_hop", @@ -550,14 +551,14 @@ class Route_mapsTemplate(NetworkTemplate):                                      "set": {                                          "ipv6_next_hop": {                                              "ip_type": "{{type}}", -                                            "value": "{{value}}" -                                        } -                                    } -                                } -                        } -                    } -                } -            } +                                            "value": "{{value}}", +                                        }, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_large_community", @@ -579,13 +580,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "large_community": "{{large_community}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "large_community": "{{large_community}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_local_preference", @@ -607,13 +608,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "local_preference": "{{local_preference}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "local_preference": "{{local_preference}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_metric", @@ -635,13 +636,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "metric": "{{metric}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "metric": "{{metric}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_metric_type", @@ -663,13 +664,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "metric_type": "{{metric_type}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "metric_type": "{{metric_type}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_origin", @@ -691,13 +692,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "origin": "{{origin}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "origin": "{{origin}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_originator_id", @@ -719,13 +720,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "originator_id": "{{originator_id}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "originator_id": "{{originator_id}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_src", @@ -747,13 +748,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "src": "{{src}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "src": "{{src}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_tag", @@ -775,13 +776,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "tag": "{{tag}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "tag": "{{tag}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_weight", @@ -803,13 +804,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "set": { -                                        "weight": "{{weight}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "weight": "{{weight}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "set_community", @@ -833,13 +834,13 @@ class Route_mapsTemplate(NetworkTemplate):                                      "set": {                                          "community": {                                              "value": "{{value}}", -                                        } -                                    } -                                } -                        } -                    } -                } -            } +                                        }, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_as_path", @@ -861,13 +862,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "as_path": "{{as_path}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "as_path": "{{as_path}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_community_community_list", @@ -889,13 +890,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "community": {"community_list": "{{community_list}}"} -                                    } -                                } -                        } -                    } -                } -            } +                                        "community": {"community_list": "{{community_list}}"}, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_community_exact_match", @@ -917,13 +918,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "community": {"exact_match": "{{True if exact_match is defined}}"} -                                    } -                                } -                        } -                    } -                } -            } +                                        "community": {"exact_match": "{{True if exact_match is defined}}"}, +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_extcommunity", @@ -945,13 +946,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "extcommunity": "{{extcommunity}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "extcommunity": "{{extcommunity}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_interface", @@ -973,13 +974,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "interface": "{{interface}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "interface": "{{interface}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_large_community_large_community_list", @@ -1001,13 +1002,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "large_community_large_community_list": "{{lc}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "large_community_large_community_list": "{{lc}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_metric", @@ -1029,13 +1030,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "metric": "{{metric}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "metric": "{{metric}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_origin", @@ -1057,13 +1058,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "origin": "{{origin}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "origin": "{{origin}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_peer", @@ -1085,13 +1086,13 @@ class Route_mapsTemplate(NetworkTemplate):                                  {                                      "sequence": "{{sequence}}",                                      "match": { -                                        "peer": "{{peer}}" -                                    } -                                } -                        } -                    } -                } -            } +                                        "peer": "{{peer}}", +                                    }, +                                }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_ip_address", @@ -1117,15 +1118,15 @@ class Route_mapsTemplate(NetworkTemplate):                                      "ip": {                                          "address": {                                              "list_type": "{{list_type}}", -                                            "value": "{{value}}" -                                        } -                                    } -                                } -                            } -                        } -                    } -                } -            } +                                            "value": "{{value}}", +                                        }, +                                    }, +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_ip_next_hop", @@ -1151,15 +1152,15 @@ class Route_mapsTemplate(NetworkTemplate):                                      "ip": {                                          "next_hop": {                                              "list_type": "{{list_type}}", -                                            "value": "{{value}}" -                                        } -                                    } -                                } -                            } -                        } -                    } -                } -            } +                                            "value": "{{value}}", +                                        }, +                                    }, +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_ip_route_source", @@ -1185,15 +1186,15 @@ class Route_mapsTemplate(NetworkTemplate):                                      "ip": {                                          "route_source": {                                              "list_type": "{{list_type}}", -                                            "value": "{{value}}" -                                        } -                                    } -                                } -                            } -                        } -                    } -                } -            } +                                            "value": "{{value}}", +                                        }, +                                    }, +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_ipv6_address", @@ -1219,15 +1220,15 @@ class Route_mapsTemplate(NetworkTemplate):                                      "ipv6": {                                          "address": {                                              "list_type": "{{list_type}}", -                                            "value": "{{value}}" -                                        } -                                    } -                                } -                            } -                        } -                    } -                } -            } +                                            "value": "{{value}}", +                                        }, +                                    }, +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_ipv6_nexthop", @@ -1250,14 +1251,14 @@ class Route_mapsTemplate(NetworkTemplate):                                  "sequence": "{{sequence}}",                                  "match": {                                      "ipv6": { -                                        "next_hop": "{{value}}" -                                    } -                                } -                            } -                        } -                    } -                } -            } +                                        "next_hop": "{{value}}", +                                    }, +                                }, +                            }, +                        }, +                    }, +                }, +            },          },          {              "name": "match_rpki", @@ -1279,13 +1280,13 @@ class Route_mapsTemplate(NetworkTemplate):                              "{{sequence}}": {                                  "sequence": "{{sequence}}",                                  "match": { -                                    "rpki": "{{value}}" -                                } -                            } -                        } -                    } -                } -            } +                                    "rpki": "{{value}}", +                                }, +                            }, +                        }, +                    }, +                }, +            },          },      ] diff --git a/plugins/module_utils/network/vyos/rm_templates/snmp_server.py b/plugins/module_utils/network/vyos/rm_templates/snmp_server.py index 15a08040..724be228 100644 --- a/plugins/module_utils/network/vyos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/vyos/rm_templates/snmp_server.py @@ -5,6 +5,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """ @@ -124,7 +125,10 @@ class Snmp_serverTemplate(NetworkTemplate):      def __init__(self, lines=None, module=None):          prefix = {"set": "set", "remove": "delete"}          super(Snmp_serverTemplate, self).__init__( -            lines=lines, tmplt=self, prefix=prefix, module=module +            lines=lines, +            tmplt=self, +            prefix=prefix, +            module=module,          )      # fmt: off @@ -140,7 +144,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(client\s(?P<client>\S+))*                  \s*(network\s(?P<network>\S+))*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_communities,              "result": {                  "communities": { @@ -148,10 +153,10 @@ class Snmp_serverTemplate(NetworkTemplate):                          "name": "{{ name }}",                          "clients": ['{{ client if client is defined else "None" }}'],                          "networks": ['{{ network if network is defined else "None" }}'], -                        "authorization_type": '{{ auth.split(" ")[1] if auth is defined else None }}' -                    } -                } -            } +                        "authorization_type": '{{ auth.split(" ")[1] if auth is defined else None }}', +                    }, +                }, +            },          },          # service snmp contact <>          { @@ -161,11 +166,12 @@ class Snmp_serverTemplate(NetworkTemplate):                  ^set\sservice\ssnmp\scontact                  \s+(?P<name>\S+)                  *$""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp contact {{ contact }}",              "result": { -                "contact": "{{ name }}" -            } +                "contact": "{{ name }}", +            },          },          # service snmp description <>          { @@ -175,11 +181,12 @@ class Snmp_serverTemplate(NetworkTemplate):                  ^set\sservice\ssnmp\sdescription                  \s+(?P<name>\S+)                  *$""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp description {{ description }}",              "result": { -                "description": "{{ name }}" -            } +                "description": "{{ name }}", +            },          },          # service snmp listen-address <> port <>          { @@ -191,17 +198,18 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(port)*                  \s*(?P<port>\d+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp listen-address {{ listen_addresses.address }}"                        "{{ (' port ' + listen_addresses.port|string) if listen_addresses.port is defined else '' }}",              "result": {                  "listen_addresses": {                      "{{ addr }}": {                          "address": "{{ addr }}", -                        "port": "{{ port }}" -                    } -                } -            } +                        "port": "{{ port }}", +                    }, +                }, +            },          },          # service snmp location <>          { @@ -211,11 +219,12 @@ class Snmp_serverTemplate(NetworkTemplate):                  ^set\sservice\ssnmp\slocation                  \s(?P<name>.*)                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp location {{ '\\'' + location + '\\''}}",              "result": { -                "location": "{{ name }}" -            } +                "location": "{{ name }}", +            },          },          # service snmp smux-peer <>          { @@ -225,11 +234,12 @@ class Snmp_serverTemplate(NetworkTemplate):                  ^set\sservice\ssnmp\ssmux-peer                  \s+(?P<name>\S+)                  *$""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp smux-peer {{ smux_peer }}",              "result": { -                "smux_peer": "{{ name }}" -            } +                "smux_peer": "{{ name }}", +            },          },          # service snmp trap-source <>          { @@ -239,11 +249,12 @@ class Snmp_serverTemplate(NetworkTemplate):                  ^set\sservice\ssnmp\strap-source                  \s+(?P<name>\S+)                  *$""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp trap-source {{ trap_source }}",              "result": { -                "trap_source": "{{ name }}" -            } +                "trap_source": "{{ name }}", +            },          },          # service snmp trap-target <>          { @@ -255,15 +266,16 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<comm>community\s\S+)*                  \s*(?P<port>port\s\d+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_trap_target,              "result": {                  "trap_target": {                      "address": "{{ name }}",                      "community": "{{ comm.split(" ")[1] if comm is defined else None }}",                      "port": "{{ port.split(" ")[1] if port is defined else None }}", -                } -            } +                }, +            },          },          # service snmp v3 engineid <>          { @@ -273,13 +285,14 @@ class Snmp_serverTemplate(NetworkTemplate):                  ^set\sservice\ssnmp\sv3\sengineid                  \s+(?P<name>\S+)                  *$""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 engineid {{ snmp_v3.engine_id }}",              "result": {                  "snmp_v3": {                      "engine_id": "{{ name }}", -                } -            } +                }, +            },          },          # service snmp v3 group <>          { @@ -292,7 +305,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<sec>seclevel\s\S+)*                  \s*(?P<view>view\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_v3_groups,              "result": {                  "snmp_v3": { @@ -302,10 +316,10 @@ class Snmp_serverTemplate(NetworkTemplate):                              "mode": '{{ mode.split(" ")[1] if mode is defined else None }}',                              "seclevel": '{{ sec.split(" ")[1] if sec is defined else None }}',                              "view": '{{ view.split(" ")[1] if view is defined else None }}', -                        } -                    } -                } -            } +                        }, +                    }, +                }, +            },          },          # service snmp v3 trap-target <> auth <>          { @@ -319,7 +333,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<plain>plaintext-key\s\S+)*                  \s*(?P<type>type\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_v3_trap_target,              "result": {                  "snmp_v3": { @@ -330,11 +345,11 @@ class Snmp_serverTemplate(NetworkTemplate):                                  "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}',                                  "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}',                                  "type": '{{ type.split(" ")[1] if type is defined else None }}', -                            } -                        } -                    } -                } -            } +                            }, +                        }, +                    }, +                }, +            },          },          # service snmp v3 trap-target <> port <>          { @@ -345,18 +360,19 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s+(?P<name>\S+)                  \s+(?P<port>port\s\d+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 trap-target port {{ snmp_v3.trap_targets.port }}",              "result": {                  "snmp_v3": {                      "trap_targets": {                          "{{ name }}": {                              "address": "{{ name }}", -                            "port": "{{ port }}" -                        } -                    } -                } -            } +                            "port": "{{ port }}", +                        }, +                    }, +                }, +            },          },          # service snmp v3 trap-target <> protocol <>          { @@ -367,18 +383,19 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s+(?P<name>\S+)                  \s+(?P<protocol>protocol\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 trap-target protocol {{ snmp_v3.trap_targets.protocol }}",              "result": {                  "snmp_v3": {                      "trap_targets": {                          "{{ name }}": {                              "address": "{{ name }}", -                            "protocol": "{{ protocol }}" -                        } -                    } -                } -            } +                            "protocol": "{{ protocol }}", +                        }, +                    }, +                }, +            },          },          # service snmp v3 trap-target <> type <>          { @@ -389,18 +406,19 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s+(?P<name>\S+)                  \s+(?P<type>type\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 trap-target type {{ snmp_v3.trap_targets.type }}",              "result": {                  "snmp_v3": {                      "trap_targets": {                          "{{ name }}": {                              "address": "{{ name }}", -                            "type": "{{ type }}" -                        } -                    } -                } -            } +                            "type": "{{ type }}", +                        }, +                    }, +                }, +            },          },          # service snmp v3 trap-target <> user <>          { @@ -411,18 +429,19 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s+(?P<name>\S+)                  \s+(?P<user>user\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 trap-target user {{ snmp_v3.trap_targets.user }}",              "result": {                  "snmp_v3": {                      "trap_targets": {                          "{{ name }}": {                              "address": "{{ name }}", -                            "user": "{{ user }}" -                        } -                    } -                } -            } +                            "user": "{{ user }}", +                        }, +                    }, +                }, +            },          },          # service snmp v3 trap-target <> privacy <>          { @@ -436,7 +455,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<plain>plaintext-key\s\S+)*                  \s*(?P<type>type\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_v3_trap_target,              "result": {                  "snmp_v3": { @@ -447,11 +467,11 @@ class Snmp_serverTemplate(NetworkTemplate):                                  "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}',                                  "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}',                                  "type": '{{ type.split(" ")[1] if type is defined else None }}', -                            } -                        } -                    } -                } -            } +                            }, +                        }, +                    }, +                }, +            },          },          # service snmp v3 user <> auth <>          { @@ -465,7 +485,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<plain>plaintext-key\s\S+)*                  \s*(?P<type>type\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_v3_user,              "result": {                  "snmp_v3": { @@ -476,11 +497,11 @@ class Snmp_serverTemplate(NetworkTemplate):                                  "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}',                                  "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}',                                  "type": '{{ type.split(" ")[1] if type is defined else None }}', -                            } -                        } -                    } -                } -            } +                            }, +                        }, +                    }, +                }, +            },          },          # service snmp v3 user <> privacy <>          { @@ -494,7 +515,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<plain>plaintext-key\s\S+)*                  \s*(?P<type>type\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_v3_user,              "result": {                  "snmp_v3": { @@ -505,11 +527,11 @@ class Snmp_serverTemplate(NetworkTemplate):                                  "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}',                                  "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}',                                  "type": '{{ type.split(" ")[1] if type is defined else None }}', -                            } -                        } -                    } -                } -            } +                            }, +                        }, +                    }, +                }, +            },          },          # service snmp v3 user <> group <>          { @@ -520,18 +542,19 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s+(?P<name>\S+)                  \s+(?P<group>group\s.+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 user {{ snmp_v3.users.user }} group {{ snmp_v3.users.group }}",              "result": {                  "snmp_v3": {                      "users": {                          "{{ name }}": {                              "user": "{{ name }}", -                            "group": "{{ group.split(" ")[1] if group is defined else None }}" -                        } -                    } -                } -            } +                            "group": "{{ group.split(" ")[1] if group is defined else None }}", +                        }, +                    }, +                }, +            },          },          # service snmp v3  user <> mode <>          { @@ -542,18 +565,19 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s+(?P<name>\S+)                  \s+(?P<mode>mode\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": "service snmp v3 user {{ snmp_v3.users.user }} mode {{ snmp_v3.users.mode }}",              "result": {                  "snmp_v3": {                      "users": {                          "{{ name }}": {                              "user": "{{ name }}", -                            "mode": "{{ mode }}" -                        } -                    } -                } -            } +                            "mode": "{{ mode }}", +                        }, +                    }, +                }, +            },          },          # service snmp v3 view <>          { @@ -566,7 +590,8 @@ class Snmp_serverTemplate(NetworkTemplate):                  \s*(?P<ex>exclude\s\S+)*                  \s*(?P<mask>mask\s\S+)*                  $""", -                re.VERBOSE), +                re.VERBOSE, +            ),              "setval": _tmplt_snmp_server_v3_views,              "result": {                  "snmp_v3": { @@ -576,10 +601,10 @@ class Snmp_serverTemplate(NetworkTemplate):                              "oid": '{{ oid.split(" ")[1] if oid is defined else None }}',                              "exclude": '{{ ex.split(" ")[1] if ex is defined else None }}',                              "mask": '{{ mask.split(" ")[1] if mask is defined else None }}', -                        } -                    } -                } -            } +                        }, +                    }, +                }, +            },          },      ]      # fmt: on diff --git a/plugins/module_utils/network/vyos/utils/utils.py b/plugins/module_utils/network/vyos/utils/utils.py index d2ca7038..8722251e 100644 --- a/plugins/module_utils/network/vyos/utils/utils.py +++ b/plugins/module_utils/network/vyos/utils/utils.py @@ -6,10 +6,12 @@  # utils  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  from ansible.module_utils.basic import missing_required_lib  from ansible.module_utils.six import iteritems +  try:      import ipaddress diff --git a/plugins/module_utils/network/vyos/vyos.py b/plugins/module_utils/network/vyos/vyos.py index da364f99..4fcb3317 100644 --- a/plugins/module_utils/network/vyos/vyos.py +++ b/plugins/module_utils/network/vyos/vyos.py @@ -27,12 +27,14 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  import json  from ansible.module_utils._text import to_text  from ansible.module_utils.connection import Connection, ConnectionError +  _DEVICE_CONFIGS = {} diff --git a/plugins/modules/vyos_banner.py b/plugins/modules/vyos_banner.py index 0ee10f5f..6b1da84b 100644 --- a/plugins/modules/vyos_banner.py +++ b/plugins/modules/vyos_banner.py @@ -2,6 +2,7 @@  # -*- coding: utf-8 -*-  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  # (c) 2017, Ansible by Red Hat, inc diff --git a/plugins/modules/vyos_bgp_address_family.py b/plugins/modules/vyos_bgp_address_family.py index ba56309c..d6f89259 100644 --- a/plugins/modules/vyos_bgp_address_family.py +++ b/plugins/modules/vyos_bgp_address_family.py @@ -28,6 +28,7 @@ The module file for vyos_bgp_address_family  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -264,39 +265,39 @@ EXAMPLES = """  # vyos@vyos:~$ show configuration commands |  match "set protocols bgp"  # vyos@vyos:~$ -  - name: Merge provided configuration with device configuration -    vyos.vyos.vyos_bgp_address_family: -      config: -        as_number: "100" -        address_family: -          - afi: "ipv4" -            redistribute: -              - protocol: "static" -                metric: 50 -        neighbors: -          - neighbor_address: "20.33.1.1/24" -            address_family: -              - afi: "ipv4" -                allowas_in: 4 -                as_override: True -                attribute_unchanged: -                  med: True -              - afi: "ipv6" -                default_originate: "map01" -                distribute_list: -                  - action: "export" -                    acl: 10 -          - neighbor_address: "100.11.34.12" -            address_family: -              - afi: "ipv4" -                maximum_prefix: 45 -                nexthop_self: True -                route_map: -                  - action: "export" -                    route_map: "map01" -                  - action: "import" -                    route_map: "map01" -                weight: 50 +- name: Merge provided configuration with device configuration +  vyos.vyos.vyos_bgp_address_family: +    config: +      as_number: "100" +      address_family: +        - afi: "ipv4" +          redistribute: +            - protocol: "static" +              metric: 50 +      neighbors: +        - neighbor_address: "20.33.1.1/24" +          address_family: +            - afi: "ipv4" +              allowas_in: 4 +              as_override: true +              attribute_unchanged: +                med: true +            - afi: "ipv6" +              default_originate: "map01" +              distribute_list: +                - action: "export" +                  acl: 10 +        - neighbor_address: "100.11.34.12" +          address_family: +            - afi: "ipv4" +              maximum_prefix: 45 +              nexthop_self: true +              route_map: +                - action: "export" +                  route_map: "map01" +                - action: "import" +                  route_map: "map01" +              weight: 50  # After State:  # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -410,33 +411,32 @@ EXAMPLES = """  # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight '50'  # vyos@vyos:~$ -  - name: Replace provided configuration with device configuration -    vyos.vyos.vyos_bgp_address_family: -      config: -        as_number: "100" -        neighbors: -          - neighbor_address: "100.11.34.12" -            address_family: -              - afi: "ipv4" -                allowas_in: 4 -                as_override: True -                attribute_unchanged: -                  med: True -              - afi: "ipv6" -                default_originate: "map01" -                distribute_list: -                  - action: "export" -                    acl: 10 -          - neighbor_address: "20.33.1.1/24" -            address_family: -              - afi: "ipv6" -                maximum_prefix: 45 -                nexthop_self: True - -      state: replaced +- name: Replace provided configuration with device configuration +  vyos.vyos.vyos_bgp_address_family: +    config: +      as_number: "100" +      neighbors: +        - neighbor_address: "100.11.34.12" +          address_family: +            - afi: "ipv4" +              allowas_in: 4 +              as_override: true +              attribute_unchanged: +                med: true +            - afi: "ipv6" +              default_originate: "map01" +              distribute_list: +                - action: "export" +                  acl: 10 +        - neighbor_address: "20.33.1.1/24" +          address_family: +            - afi: "ipv6" +              maximum_prefix: 45 +              nexthop_self: true +    state: replaced  # After State: - +#  # vyos@vyos:~$ show configuration commands | match "set protocols bgp"  # set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50'  # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast @@ -600,31 +600,31 @@ EXAMPLES = """  # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list export '10'  # vyos@vyos:~$ -  - name: Override -    vyos.vyos.vyos_bgp_address_family: -      config: -        as_number: "100" -        neighbors: -          - neighbor_address: "100.11.34.12" -            address_family: -              - afi: "ipv6" -                maximum_prefix: 45 -                nexthop_self: True -                route_map: -                  - action: "import" -                    route_map: "map01" -        address_family: -          - afi: "ipv4" -            aggregate_address: -              - prefix: "60.9.2.0/24" -                summary_only: True -          - afi: "ipv6" -            redistribute: -              - protocol: "static" -                metric: 50 -      state: overridden +- name: Override +  vyos.vyos.vyos_bgp_address_family: +    config: +      as_number: "100" +      neighbors: +        - neighbor_address: "100.11.34.12" +          address_family: +            - afi: "ipv6" +              maximum_prefix: 45 +              nexthop_self: true +              route_map: +                - action: "import" +                  route_map: "map01" +      address_family: +        - afi: "ipv4" +          aggregate_address: +            - prefix: "60.9.2.0/24" +              summary_only: true +        - afi: "ipv6" +          redistribute: +            - protocol: "static" +              metric: 50 +    state: overridden -# Aft=validate-moduleser State +# After State  # vyos@vyos:~$ show configuration commands | match "set protocols bgp"  # set protocols bgp 100 address-family ipv4-unicast aggregate-address 60.9.2.0/24 summary-only @@ -799,18 +799,18 @@ EXAMPLES = """  # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast route-map import 'map01'  # vyos@vyos:~$ -  - name: Delete -    vyos.vyos.vyos_bgp_address_family: -      config: -        as_number: "100" -        neighbors: -          - neighbor_address: "20.33.1.1/24" -            address_family: -              - afi: "ipv6" -          - neighbor_address: "100.11.34.12" -        address_family: -          - afi: "ipv4" -      state: deleted +- name: Delete +  vyos.vyos.vyos_bgp_address_family: +    config: +      as_number: "100" +      neighbors: +        - neighbor_address: "20.33.1.1/24" +          address_family: +            - afi: "ipv6" +        - neighbor_address: "100.11.34.12" +      address_family: +        - afi: "ipv4" +    state: deleted  # After State: @@ -961,12 +961,13 @@ EXAMPLES = """  # set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop -  - name: parse configs -    vyos.vyos.vyos_bgp_address_family: -      running_config: "{{ lookup('file', './parsed.cfg') }}" -      state: parsed +- name: parse configs +  vyos.vyos.vyos_bgp_address_family: +    running_config: "{{ lookup('file', './parsed.cfg') }}" +    state: parsed -# Module Execution: +# Module execution result: +#  # "parsed": {  #         "address_family": [  #             { @@ -1044,12 +1045,12 @@ EXAMPLES = """  # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med  # set protocols bgp 100 neighbor 100.11.34.12 -  - name: gather configs -    vyos.vyos.vyos_bgp_address_family: -      state: gathered - -# Module Execution: +- name: gather configs +  vyos.vyos.vyos_bgp_address_family: +    state: gathered +# Module execution result: +#  # "gathered": {  #         "address_family": [  #             { @@ -1108,40 +1109,40 @@ EXAMPLES = """  # Using rendered: -  - name: Render -    vyos.vyos.vyos_bgp_address_family: -      config: -        as_number: "100" -        address_family: -          - afi: "ipv4" -            redistribute: -              - protocol: "static" -                metric: 50 -        neighbors: -          - neighbor_address: "20.33.1.1/24" -            address_family: -              - afi: "ipv4" -                allowas_in: 4 -                as_override: True -                attribute_unchanged: -                  med: True -              - afi: "ipv6" -                default_originate: "map01" -                distribute_list: -                  - action: "export" -                    acl: 10 -          - neighbor_address: "100.11.34.12" -            address_family: -              - afi: "ipv4" -                maximum_prefix: 45 -                nexthop_self: True -                route_map: -                  - action: "export" -                    route_map: "map01" -                  - action: "import" -                    route_map: "map01" -                weight: 50 -      state: rendered +- name: Render +  vyos.vyos.vyos_bgp_address_family: +    config: +      as_number: "100" +      address_family: +        - afi: "ipv4" +          redistribute: +            - protocol: "static" +              metric: 50 +      neighbors: +        - neighbor_address: "20.33.1.1/24" +          address_family: +            - afi: "ipv4" +              allowas_in: 4 +              as_override: true +              attribute_unchanged: +                med: true +            - afi: "ipv6" +              default_originate: "map01" +              distribute_list: +                - action: "export" +                  acl: 10 +        - neighbor_address: "100.11.34.12" +          address_family: +            - afi: "ipv4" +              maximum_prefix: 45 +              nexthop_self: true +              route_map: +                - action: "export" +                  route_map: "map01" +                - action: "import" +                  route_map: "map01" +              weight: 50 +    state: rendered  # Module Execution: @@ -1158,8 +1159,6 @@ EXAMPLES = """  #         "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map import map01",  #         "set protocols bgp 100  neighbor 100.11.34.12 address-family ipv4-unicast weight 50"  #     ] - -  """  from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_bgp_global.py b/plugins/modules/vyos_bgp_global.py index 1e3578de..f9c0eeb3 100644 --- a/plugins/modules/vyos_bgp_global.py +++ b/plugins/modules/vyos_bgp_global.py @@ -28,6 +28,7 @@ The module file for vyos_bgp_global  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -432,63 +433,62 @@ EXAMPLES = """  # vyos@vyos:~$ show configuration commands |  match "set protocols bgp"  # vyos@vyos:~$ -  - name: Merge provided configuration with device configuration -    vyos.vyos.vyos_bgp_global: -      config: -        as_number: "65536" -        aggregate_address: -          - prefix: "203.0.113.0/24" -            as_set: true -          - prefix: "192.0.2.0/24" -            summary_only: true -        network: -          - address: "192.1.13.0/24" -            backdoor: true -        redistribute: -          - protocol: "kernel" -            metric: 45 -          - protocol: "connected" -            route_map: "map01" -        maximum_paths: -          - path: "ebgp" -            count: 20 -          - path: "ibgp" -            count: 55 -        timers: -          keepalive: 35 -        bgp_params: -          bestpath: -            as_path: "confed" -            compare_routerid: true -          default: -            no_ipv4_unicast: true -          router_id: "192.1.2.9" -          confederation: -            - peers: 20 -            - peers: 55 -            - identifier: 66 -        neighbor: -          - address: "192.0.2.25" -            disable_connected_check: true -            timers: -              holdtime: 30 -              keepalive: 10 -          - address: "203.0.113.5" -            attribute_unchanged: -              as_path: true -              med: true -            ebgp_multihop: 2 -            remote_as: 101 -            update_source: "192.0.2.25" -          - address: "5001::64" -            maximum_prefix: 34 -            distribute_list: -              - acl: 20 -                action: "export" -              - acl: 40 -                action: "import" - -      state: merged +- name: Merge provided configuration with device configuration +  vyos.vyos.vyos_bgp_global: +    config: +      as_number: "65536" +      aggregate_address: +        - prefix: "203.0.113.0/24" +          as_set: true +        - prefix: "192.0.2.0/24" +          summary_only: true +      network: +        - address: "192.1.13.0/24" +          backdoor: true +      redistribute: +        - protocol: "kernel" +          metric: 45 +        - protocol: "connected" +          route_map: "map01" +      maximum_paths: +        - path: "ebgp" +          count: 20 +        - path: "ibgp" +          count: 55 +      timers: +        keepalive: 35 +      bgp_params: +        bestpath: +          as_path: "confed" +          compare_routerid: true +        default: +          no_ipv4_unicast: true +        router_id: "192.1.2.9" +        confederation: +          - peers: 20 +          - peers: 55 +          - identifier: 66 +      neighbor: +        - address: "192.0.2.25" +          disable_connected_check: true +          timers: +            holdtime: 30 +            keepalive: 10 +        - address: "203.0.113.5" +          attribute_unchanged: +            as_path: true +            med: true +          ebgp_multihop: 2 +          remote_as: 101 +          update_source: "192.0.2.25" +        - address: "5001::64" +          maximum_prefix: 34 +          distribute_list: +            - acl: 20 +              action: "export" +            - acl: 40 +              action: "import" +    state: merged  # After State  # vyos@vyos:~$ show configuration commands |  match "set protocols bgp" @@ -688,26 +688,25 @@ EXAMPLES = """  # set protocols bgp 65536 timers keepalive '35'  # vyos@vyos:~$ -  - name: Replace -    vyos.vyos.vyos_bgp_global: -      config: -        as_number: "65536" -        network: -          - address: "203.0.113.0/24" -            route_map: map01 -        redistribute: -          - protocol: "static" -            route_map: "map01" -        neighbor: -          - address: "192.0.2.40" -            advertisement_interval: 72 -            capability: -              orf: "receive" -        bgp_params: -          bestpath: -            as_path: "confed" - -      state: replaced +- name: Replace +  vyos.vyos.vyos_bgp_global: +    config: +      as_number: "65536" +      network: +        - address: "203.0.113.0/24" +          route_map: map01 +      redistribute: +        - protocol: "static" +          route_map: "map01" +      neighbor: +        - address: "192.0.2.40" +          advertisement_interval: 72 +          capability: +            orf: "receive" +      bgp_params: +        bestpath: +          as_path: "confed" +    state: replaced  # After state:  # vyos@vyos:~$ show configuration commands |  match "set protocols bgp" @@ -885,11 +884,11 @@ EXAMPLES = """  # set protocols bgp 65536 redistribute static route-map 'map01'  # vyos@vyos:~$ -  - name: Delete configuration -    vyos.vyos.vyos_bgp_global: -      config: -        as_number: "65536" -      state: deleted +- name: Delete configuration +  vyos.vyos.vyos_bgp_global: +    config: +      as_number: "65536" +    state: deleted  # After state: @@ -975,11 +974,11 @@ EXAMPLES = """  # vyos@vyos:~$ -  - name: Purge configuration -    vyos.vyos.vyos_bgp_global: -      config: -        as_number: "65536" -      state: purged +- name: Purge configuration +  vyos.vyos.vyos_bgp_global: +    config: +      as_number: "65536" +    state: purged  # After state: @@ -1120,12 +1119,11 @@ EXAMPLES = """  # vyos@vyos:~$ ^C  # vyos@vyos:~$ - -  - name: Delete configuration -    vyos.vyos.vyos_bgp_global: -      config: -        as_number: "65536" -      state: deleted +- name: Delete configuration +  vyos.vyos.vyos_bgp_global: +    config: +      as_number: "65536" +    state: deleted  # Module Execution:  # @@ -1176,9 +1174,9 @@ EXAMPLES = """  # set protocols bgp 65536 redistribute static route-map 'map01'  # vyos@vyos:~$ ^C -  - name: gather configs -    vyos.vyos.vyos_bgp_global: -      state: gathered +- name: gather configs +  vyos.vyos.vyos_bgp_global: +    state: gathered  # Module Execution:  # "gathered": { @@ -1268,12 +1266,12 @@ EXAMPLES = """  # set protocols bgp 65536 parameters distance global local '10'  # set protocols bgp 65536 redistribute static route-map 'map01' -  - name: parse configs -    vyos.vyos.vyos_bgp_global: -      running_config: "{{ lookup('file', './parsed.cfg') }}" -      state: parsed -    tags: -      - parsed +- name: parse configs +  vyos.vyos.vyos_bgp_global: +    running_config: "{{ lookup('file', './parsed.cfg') }}" +    state: parsed +  tags: +    - parsed  # Module execution:  # "parsed": { @@ -1340,49 +1338,48 @@ EXAMPLES = """  # Using rendered:  # -------------- -  - name: Render -    vyos.vyos.vyos_bgp_global: -      config: -        as_number: "65536" -        network: -          - address: "203.0.113.0/24" -            route_map: map01 -        redistribute: -          - protocol: "static" -            route_map: "map01" -        bgp_params: -          always_compare_med: true -          dampening: -            start_suppress_time: 5 -            max_suppress_time: 20 -            half_life: 33 -            re_use: 60 -          distance: -            - type: "internal" -              value: 20 -            - type: "local" -              value: 10 -            - type: "external" -              value: 66 -          bestpath: -            as_path: "confed" -            compare_routerid: true -          default: -            no_ipv4_unicast: true -        neighbor: -          - address: "192.0.2.43" -            disable_connected_check: true -            advertisement_interval: 72 -            capability: -              dynamic: true -            timers: -              holdtime: 30 -              keepalive: 10 -          - address: "203.0.113.0" -            capability: -              orf: "receive" - -      state: rendered +- name: Render +  vyos.vyos.vyos_bgp_global: +    config: +      as_number: "65536" +      network: +        - address: "203.0.113.0/24" +          route_map: map01 +      redistribute: +        - protocol: "static" +          route_map: "map01" +      bgp_params: +        always_compare_med: true +        dampening: +          start_suppress_time: 5 +          max_suppress_time: 20 +          half_life: 33 +          re_use: 60 +        distance: +          - type: "internal" +            value: 20 +          - type: "local" +            value: 10 +          - type: "external" +            value: 66 +        bestpath: +          as_path: "confed" +          compare_routerid: true +        default: +          no_ipv4_unicast: true +      neighbor: +        - address: "192.0.2.43" +          disable_connected_check: true +          advertisement_interval: 72 +          capability: +            dynamic: true +          timers: +            holdtime: 30 +            keepalive: 10 +        - address: "203.0.113.0" +          capability: +            orf: "receive" +    state: rendered  # Module Execution:  # "rendered": [ @@ -1406,8 +1403,6 @@ EXAMPLES = """  #         "set protocols bgp 65536 parameters bestpath compare-routerid",  #         "set protocols bgp 65536 parameters default no-ipv4-unicast"  #     ] - -  """  from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_command.py b/plugins/modules/vyos_command.py index 2ed920cb..bacbe26a 100644 --- a/plugins/modules/vyos_command.py +++ b/plugins/modules/vyos_command.py @@ -17,6 +17,7 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -97,26 +98,26 @@ EXAMPLES = """  - name: show configuration on ethernet devices eth0 and eth1    vyos.vyos.vyos_command:      commands: -    - show interfaces ethernet {{ item }} +      - show interfaces ethernet {{ item }}    with_items: -  - eth0 -  - eth1 +    - eth0 +    - eth1  - name: run multiple commands and check if version output contains specific version      string    vyos.vyos.vyos_command:      commands: -    - show version -    - show hardware cpu +      - show version +      - show hardware cpu      wait_for: -    - result[0] contains 'VyOS 1.1.7' +      - result[0] contains 'VyOS 1.1.7'  - name: run command that requires answering a prompt    vyos.vyos.vyos_command:      commands: -    - command: rollback 1 -      prompt: Proceed with reboot? [confirm][y] -      answer: y +      - command: rollback 1 +        prompt: Proceed with reboot? [confirm][y] +        answer: y  """  RETURN = """ @@ -164,7 +165,7 @@ def parse_commands(module, warnings):              if not item["command"].startswith("show"):                  warnings.append(                      "Only show commands are supported when using check mode, not " -                    "executing %s" % item["command"] +                    "executing %s" % item["command"],                  )                  commands.remove(item) diff --git a/plugins/modules/vyos_config.py b/plugins/modules/vyos_config.py index 2a03d0c3..bf5d4217 100644 --- a/plugins/modules/vyos_config.py +++ b/plugins/modules/vyos_config.py @@ -17,6 +17,7 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -128,14 +129,14 @@ EXAMPLES = """  - name: configure the remote device    vyos.vyos.vyos_config:      lines: -    - set system host-name {{ inventory_hostname }} -    - set service lldp -    - delete service dhcp-server +      - set system host-name {{ inventory_hostname }} +      - set service lldp +      - delete service dhcp-server  - name: backup and load from file    vyos.vyos.vyos_config:      src: vyos.cfg -    backup: yes +    backup: true  - name: render a Jinja2 template onto the VyOS router    vyos.vyos.vyos_config: @@ -145,11 +146,11 @@ EXAMPLES = """    vyos.vyos.vyos_config:      lines:        # - set int eth eth2 description 'OUTSIDE' -    - set interface ethernet eth2 description 'OUTSIDE' +      - set interface ethernet eth2 description 'OUTSIDE'  - name: configurable backup path    vyos.vyos.vyos_config: -    backup: yes +    backup: true      backup_options:        filename: backup.cfg        dir_path: /home/user @@ -205,9 +206,12 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import      run_commands,  ) +  DEFAULT_COMMENT = "configured by vyos_config" -CONFIG_FILTERS = [re.compile(r"set system login user \S+ authentication encrypted-password")] +CONFIG_FILTERS = [ +    re.compile(r"set system login user \S+ authentication encrypted-password"), +]  def get_candidate(module): @@ -312,7 +316,7 @@ def run(module, result):          if result.get("filtered"):              result["warnings"].append( -                "Some configuration commands were removed, please see the filtered key" +                "Some configuration commands were removed, please see the filtered key",              )          result["changed"] = True diff --git a/plugins/modules/vyos_facts.py b/plugins/modules/vyos_facts.py index ae7543cd..a999bd31 100644 --- a/plugins/modules/vyos_facts.py +++ b/plugins/modules/vyos_facts.py @@ -5,6 +5,7 @@  # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  """  The module file for vyos_facts @@ -75,15 +76,15 @@ EXAMPLES = """  # Collect only the interfaces facts  - vyos.vyos.vyos_facts:      gather_subset: -    - '!all' -    - '!min' +      - '!all' +      - '!min'      gather_network_resources: -    - interfaces +      - interfaces  # Do not collect interfaces facts  - vyos.vyos.vyos_facts:      gather_network_resources: -    - '!interfaces' +      - '!interfaces'  # Collect interfaces and minimal default facts  - vyos.vyos.vyos_facts: diff --git a/plugins/modules/vyos_firewall_global.py b/plugins/modules/vyos_firewall_global.py index 78db9f31..205ef136 100644 --- a/plugins/modules/vyos_firewall_global.py +++ b/plugins/modules/vyos_firewall_global.py @@ -28,6 +28,7 @@ The module file for vyos_firewall_global  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -297,30 +298,30 @@ EXAMPLES = """          all: true          broadcast: true        state_policy: -      - connection_type: established -        action: accept -        log: true -      - connection_type: invalid -        action: reject +        - connection_type: established +          action: accept +          log: true +        - connection_type: invalid +          action: reject        route_redirects: -      - afi: ipv4 -        ip_src_route: true -        icmp_redirects: -          send: true -          receive: false +        - afi: ipv4 +          ip_src_route: true +          icmp_redirects: +            send: true +            receive: false        group:          address_group: -        - name: MGMT-HOSTS -          description: This group has the Management hosts address list -          members: -          - address: 192.0.1.1 -          - address: 192.0.1.3 -          - address: 192.0.1.5 +          - name: MGMT-HOSTS +            description: This group has the Management hosts address list +            members: +              - address: 192.0.1.1 +              - address: 192.0.1.3 +              - address: 192.0.1.5          network_group: -        - name: MGMT -          description: This group has the Management network addresses -          members: -          - address: 192.0.1.0/24 +          - name: MGMT +            description: This group has the Management network addresses +            members: +              - address: 192.0.1.0/24      state: merged  #  # @@ -676,6 +677,7 @@ EXAMPLES = """  #    ]  #  # "after": [] +#  # After state  # ------------  # vyos@192# run show configuration commands | grep firewall @@ -707,7 +709,7 @@ EXAMPLES = """  # set firewall state-policy invalid action 'reject'  # set firewall syn-cookies 'enable'  # set firewall twa-hazards-protection 'enable' -# +  - name: Replace firewall global attributes configuration.    vyos.vyos.vyos_firewall_global:      config: @@ -716,39 +718,39 @@ EXAMPLES = """        log_martians: true        syn_cookies: true        twa_hazards_protection: true -      ping: +      ping: null        all: true        broadcast: true        state_policy: -      - connection_type: established -        action: accept -        log: true -      - connection_type: invalid -        action: reject +        - connection_type: established +          action: accept +          log: true +        - connection_type: invalid +          action: reject        route_redirects: -      - afi: ipv4 -        ip_src_route: true -        icmp_redirects: -          send: true -          receive: false +        - afi: ipv4 +          ip_src_route: true +          icmp_redirects: +            send: true +            receive: false        group:          address_group: -        - name: SALES-HOSTS -          description: Sales office hosts address list -          members: -          - address: 192.0.2.1 -          - address: 192.0.2.2 -          - address: 192.0.2.3 -        - name: ENG-HOSTS -          description: Sales office hosts address list -          members: -          - address: 192.0.3.1 -          - address: 192.0.3.2 +          - name: SALES-HOSTS +            description: Sales office hosts address list +            members: +              - address: 192.0.2.1 +              - address: 192.0.2.2 +              - address: 192.0.2.3 +          - name: ENG-HOSTS +            description: Sales office hosts address list +            members: +              - address: 192.0.3.1 +              - address: 192.0.3.2          network_group: -        - name: MGMT -          description: This group has the Management network addresses -          members: -          - address: 192.0.1.0/24 +          - name: MGMT +            description: This group has the Management network addresses +            members: +              - address: 192.0.1.0/24      state: replaced  #  # @@ -966,7 +968,6 @@ EXAMPLES = """  #  - name: Gather firewall global config with provided configurations    vyos.vyos.vyos_firewall_global: -    config:      state: gathered  #  # @@ -1089,40 +1090,41 @@ EXAMPLES = """        log_martians: true        syn_cookies: true        twa_hazards_protection: true -      ping: +      ping: null        all: true        broadcast: true        state_policy: -      - connection_type: established -        action: accept -        log: true -      - connection_type: invalid -        action: reject +        - connection_type: established +          action: accept +          log: true +        - connection_type: invalid +          action: reject        route_redirects: -      - afi: ipv4 -        ip_src_route: true -        icmp_redirects: -        send: true -        receive: false +        - afi: ipv4 +          ip_src_route: true +          icmp_redirects: null +          send: true +          receive: false        group:          address_group: -        - name: SALES-HOSTS -          description: Sales office hosts address list -          members: -          - address: 192.0.2.1 -          - address: 192.0.2.2 -          - address: 192.0.2.3 -        - name: ENG-HOSTS -          description: Sales office hosts address list -          members: -          - address: 192.0.3.1 -          - address: 192.0.3.2 +          - name: SALES-HOSTS +            description: Sales office hosts address list +            members: +              - address: 192.0.2.1 +              - address: 192.0.2.2 +              - address: 192.0.2.3 +          - name: ENG-HOSTS +            description: Sales office hosts address list +            members: +              - address: 192.0.3.1 +              - address: 192.0.3.2          network_group: -        - name: MGMT -          description: This group has the Management network addresses -          members: -          - address: 192.0.1.0/24 +          - name: MGMT +            description: This group has the Management network addresses +            members: +              - address: 192.0.1.0/24      state: rendered +  #  #  # ------------------------- diff --git a/plugins/modules/vyos_firewall_interfaces.py b/plugins/modules/vyos_firewall_interfaces.py index f6512632..11f3e527 100644 --- a/plugins/modules/vyos_firewall_interfaces.py +++ b/plugins/modules/vyos_firewall_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_firewall_interfaces  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -123,34 +124,34 @@ EXAMPLES = """  - name: Merge the provided configuration with the existing running configuration    vyos.vyos.vyos_firewall_interfaces:      config: -    - access_rules: -      - afi: ipv4 -        rules: -        - name: INBOUND -          direction: in -        - name: OUTBOUND -          direction: out -        - name: LOCAL -          direction: local -      - afi: ipv6 -        rules: -        - name: V6-LOCAL -          direction: local -      name: eth1 -    - access_rules: -      - afi: ipv4 -        rules: -        - name: INBOUND -          direction: in -        - name: OUTBOUND -          direction: out -        - name: LOCAL -          direction: local -      - afi: ipv6 -        rules: -        - name: V6-LOCAL -          direction: local -      name: eth3 +      - access_rules: +          - afi: ipv4 +            rules: +              - name: INBOUND +                direction: in +              - name: OUTBOUND +                direction: out +              - name: LOCAL +                direction: local +          - afi: ipv6 +            rules: +              - name: V6-LOCAL +                direction: local +        name: eth1 +      - access_rules: +          - afi: ipv4 +            rules: +              - name: INBOUND +                direction: in +              - name: OUTBOUND +                direction: out +              - name: LOCAL +                direction: local +          - afi: ipv6 +            rules: +              - name: V6-LOCAL +                direction: local +        name: eth3      state: merged  #  # @@ -295,15 +296,16 @@ EXAMPLES = """  - name: Merge the provided configuration with the existing running configuration    vyos.vyos.vyos_firewall_interfaces:      config: -    - access_rules: -      - afi: ipv4 -        rules: -        - name: OUTBOUND -          direction: in -        - name: INBOUND -          direction: out -      name: eth1 +      - access_rules: +          - afi: ipv4 +            rules: +              - name: OUTBOUND +                direction: in +              - name: INBOUND +                direction: out +        name: eth1      state: merged +  #  #  # ------------------------- @@ -494,27 +496,29 @@ EXAMPLES = """  # set interfaces ethernet eth3 firewall local name 'LOCAL'  # set interfaces ethernet eth3 firewall out name 'OUTBOUND'  # -- name: Replace device configurations of listed firewall interfaces with provided +- name: >- +    Replace device configurations of listed firewall interfaces with provided      configurations    vyos.vyos.vyos_firewall_interfaces:      config: -    - name: eth1 -      access_rules: -      - afi: ipv4 -        rules: -        - name: OUTBOUND -          direction: out -      - afi: ipv6 -        rules: -        - name: V6-LOCAL -          direction: local -    - name: eth3 -      access_rules: -      - afi: ipv4 -        rules: -        - name: INBOUND -          direction: in +      - name: eth1 +        access_rules: +          - afi: ipv4 +            rules: +              - name: OUTBOUND +                direction: out +          - afi: ipv6 +            rules: +              - name: V6-LOCAL +                direction: local +      - name: eth3 +        access_rules: +          - afi: ipv4 +            rules: +              - name: INBOUND +                direction: in      state: replaced +  #  #  # ------------------------- @@ -682,12 +686,12 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_firewall_interfaces:      config: -    - name: eth3 -      access_rules: -      - afi: ipv4 -        rules: -        - name: INBOUND -          direction: out +      - name: eth3 +        access_rules: +          - afi: ipv4 +            rules: +              - name: INBOUND +                direction: out      state: overridden  #  # @@ -809,8 +813,8 @@ EXAMPLES = """  - name: Delete firewall interfaces based on interface name.    vyos.vyos.vyos_firewall_interfaces:      config: -    - name: eth1 -    - name: eth3 +      - name: eth1 +      - name: eth3      state: deleted  #  # @@ -938,10 +942,10 @@ EXAMPLES = """  - name: Delete firewall interfaces config per afi.    vyos.vyos.vyos_firewall_interfaces:      config: -    - name: eth1 -      access_rules: -      - afi: ipv4 -      - afi: ipv6 +      - name: eth1 +        access_rules: +          - afi: ipv4 +          - afi: ipv6      state: deleted  #  # @@ -964,7 +968,6 @@ EXAMPLES = """  # set firewall name 'LOCAL'  # set firewall name 'OUTBOUND' -  # Using deleted without config  #  # Before state @@ -986,7 +989,6 @@ EXAMPLES = """  #  - name: Delete firewall interfaces config when empty config provided.    vyos.vyos.vyos_firewall_interfaces: -    config:      state: deleted  #  # @@ -1010,7 +1012,6 @@ EXAMPLES = """  # Using parsed  # -#  - name: Parse the provided  configuration    vyos.vyos.vyos_firewall_interfaces:      running_config: @@ -1121,7 +1122,6 @@ EXAMPLES = """  #  - name: Gather listed firewall interfaces.    vyos.vyos.vyos_firewall_interfaces: -    config:      state: gathered  #  # @@ -1198,17 +1198,18 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_firewall_interfaces:      config: -    - name: eth2 -      access_rules: -      - afi: ipv4 -        rules: -        - direction: in -          name: INGRESS -        - direction: out -          name: OUTGRESS -        - direction: local -          name: DROP +      - name: eth2 +        access_rules: +          - afi: ipv4 +            rules: +              - direction: in +                name: INGRESS +              - direction: out +                name: OUTGRESS +              - direction: local +                name: DROP      state: rendered +  #  #  # ------------------------- @@ -1222,8 +1223,6 @@ EXAMPLES = """  #        "set interfaces ethernet eth2 firewall local name 'DROP'",  #        "set interfaces ethernet eth2 firewall local ipv6-name 'LOCAL'"  #    ] - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_firewall_rules.py b/plugins/modules/vyos_firewall_rules.py index c219f54a..06a300f5 100644 --- a/plugins/modules/vyos_firewall_rules.py +++ b/plugins/modules/vyos_firewall_rules.py @@ -28,6 +28,7 @@ The module file for vyos_firewall_rules  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -440,13 +441,13 @@ EXAMPLES = """  # set firewall name Downlink rule 502 action 'reject'  # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'  # set firewall name Downlink rule 502 ipsec 'match-ipsec' -# +  - name: Delete attributes of given firewall rules.    vyos.vyos.vyos_firewall_rules:      config: -    - afi: ipv4 -      rule_sets: -      - name: Downlink +      - afi: ipv4 +        rule_sets: +          - name: Downlink      state: deleted  #  # @@ -517,11 +518,10 @@ EXAMPLES = """  # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'  # set firewall name Downlink rule 502 ipsec 'match-ipsec' -#  - name: Delete attributes of given firewall rules.    vyos.vyos.vyos_firewall_rules:      config: -    - afi: ipv4 +      - afi: ipv4      state: deleted  #  # @@ -617,7 +617,6 @@ EXAMPLES = """  #  - name: Delete attributes of given firewall rules.    vyos.vyos.vyos_firewall_rules: -    config:      state: deleted  #  # @@ -673,48 +672,47 @@ EXAMPLES = """  - name: Merge the provided configuration with the existing running configuration    vyos.vyos.vyos_firewall_rules:      config: -    - afi: ipv6 -      rule_sets: -      - name: UPLINK -        description: This is ipv6 specific rule-set -        default_action: accept -        rules: -        - number: 1 -          action: accept -          description: Fwipv6-Rule 1 is configured by Ansible -          ipsec: match-ipsec -        - number: 2 -          action: accept -          description: Fwipv6-Rule 2 is configured by Ansible -          ipsec: match-ipsec - -    - afi: ipv4 -      rule_sets: -      - name: INBOUND -        description: IPv4 INBOUND rule set -        default_action: accept -        rules: -        - number: 101 -          action: accept -          description: Rule 101 is configured by Ansible -          ipsec: match-ipsec -        - number: 102 -          action: reject -          description: Rule 102 is configured by Ansible -          ipsec: match-ipsec -        - number: 103 -          action: accept -          description: Rule 103 is configured by Ansible -          destination: -            group: -              address_group: inbound -          source: -            address: 192.0.2.0 -          state: -            established: true -            new: false -            invalid: false -            related: true +      - afi: ipv6 +        rule_sets: +          - name: UPLINK +            description: This is ipv6 specific rule-set +            default_action: accept +            rules: +              - number: 1 +                action: accept +                description: Fwipv6-Rule 1 is configured by Ansible +                ipsec: match-ipsec +              - number: 2 +                action: accept +                description: Fwipv6-Rule 2 is configured by Ansible +                ipsec: match-ipsec +      - afi: ipv4 +        rule_sets: +          - name: INBOUND +            description: IPv4 INBOUND rule set +            default_action: accept +            rules: +              - number: 101 +                action: accept +                description: Rule 101 is configured by Ansible +                ipsec: match-ipsec +              - number: 102 +                action: reject +                description: Rule 102 is configured by Ansible +                ipsec: match-ipsec +              - number: 103 +                action: accept +                description: Rule 103 is configured by Ansible +                destination: +                  group: +                    address_group: inbound +                source: +                  address: 192.0.2.0 +                state: +                  established: true +                  new: false +                  invalid: false +                  related: true      state: merged  #  # @@ -889,28 +887,30 @@ EXAMPLES = """  # set firewall name INBOUND rule 103 state new 'disable'  # set firewall name INBOUND rule 103 state related 'enable'  # -- name: Replace device configurations of listed firewall rules with provided configurations +- name: >- +    Replace device configurations of listed firewall rules with provided +    configurations    vyos.vyos.vyos_firewall_rules:      config: -    - afi: ipv6 -      rule_sets: -      - name: UPLINK -        description: This is ipv6 specific rule-set -        default_action: accept -    - afi: ipv4 -      rule_sets: -      - name: INBOUND -        description: IPv4 INBOUND rule set -        default_action: accept -        rules: -        - number: 101 -          action: accept -          description: Rule 101 is configured by Ansible -          ipsec: match-ipsec -        - number: 104 -          action: reject -          description: Rule 104 is configured by Ansible -          ipsec: match-none +      - afi: ipv6 +        rule_sets: +          - name: UPLINK +            description: This is ipv6 specific rule-set +            default_action: accept +      - afi: ipv4 +        rule_sets: +          - name: INBOUND +            description: IPv4 INBOUND rule set +            default_action: accept +            rules: +              - number: 101 +                action: accept +                description: Rule 101 is configured by Ansible +                ipsec: match-ipsec +              - number: 104 +                action: reject +                description: Rule 104 is configured by Ansible +                ipsec: match-none      state: replaced  #  # @@ -1074,21 +1074,22 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_firewall_rules:      config: -    - afi: ipv4 -      rule_sets: -      - name: Downlink -        description: IPv4 INBOUND rule set -        default_action: accept -        rules: -        - number: 501 -          action: accept -          description: Rule 501 is configured by Ansible -          ipsec: match-ipsec -        - number: 502 -          action: reject -          description: Rule 502 is configured by Ansible -          ipsec: match-ipsec +      - afi: ipv4 +        rule_sets: +          - name: Downlink +            description: IPv4 INBOUND rule set +            default_action: accept +            rules: +              - number: 501 +                action: accept +                description: Rule 501 is configured by Ansible +                ipsec: match-ipsec +              - number: 502 +                action: reject +                description: Rule 502 is configured by Ansible +                ipsec: match-ipsec      state: overridden +  #  #  # ------------------------- @@ -1224,7 +1225,6 @@ EXAMPLES = """  #  - name: Gather listed firewall rules with provided configurations    vyos.vyos.vyos_firewall_rules: -    config:      state: gathered  #  # @@ -1340,39 +1340,40 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_firewall_rules:      config: -    - afi: ipv6 -      rule_sets: -      - name: UPLINK -        description: This is ipv6 specific rule-set -        default_action: accept -    - afi: ipv4 -      rule_sets: -      - name: INBOUND -        description: IPv4 INBOUND rule set -        default_action: accept -        rules: -        - number: 101 -          action: accept -          description: Rule 101 is configured by Ansible -          ipsec: match-ipsec -        - number: 102 -          action: reject -          description: Rule 102 is configured by Ansible -          ipsec: match-ipsec -        - number: 103 -          action: accept -          description: Rule 103 is configured by Ansible -          destination: -            group: -              address_group: inbound -          source: -            address: 192.0.2.0 -          state: -            established: true -            new: false -            invalid: false -            related: true +      - afi: ipv6 +        rule_sets: +          - name: UPLINK +            description: This is ipv6 specific rule-set +            default_action: accept +      - afi: ipv4 +        rule_sets: +          - name: INBOUND +            description: IPv4 INBOUND rule set +            default_action: accept +            rules: +              - number: 101 +                action: accept +                description: Rule 101 is configured by Ansible +                ipsec: match-ipsec +              - number: 102 +                action: reject +                description: Rule 102 is configured by Ansible +                ipsec: match-ipsec +              - number: 103 +                action: accept +                description: Rule 103 is configured by Ansible +                destination: +                  group: +                    address_group: inbound +                source: +                  address: 192.0.2.0 +                state: +                  established: true +                  new: false +                  invalid: false +                  related: true      state: rendered +  #  #  # ------------------------- @@ -1454,8 +1455,6 @@ EXAMPLES = """  #            ]  #        }  #    ] - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_hostname.py b/plugins/modules/vyos_hostname.py index 46b692a6..bc039b55 100644 --- a/plugins/modules/vyos_hostname.py +++ b/plugins/modules/vyos_hostname.py @@ -10,6 +10,7 @@ The module file for vyos_hostname  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -73,96 +74,104 @@ options:  """  EXAMPLES = """ -# Using state: merged +# Using merged +#  # Before state:  # -------------  # test#show configuration commands | grep host-name  # set system host-name 'vyostest' -# Merged play: -# ------------ +  - name: Apply the provided configuration    vyos.vyos.vyos_hostname:      config:        hostname: vyos      state: merged +  # Commands Fired:  # ---------------  # "commands": [  #         "hostname vyos",  # ], +#  # After state:  # ------------  # test#show configuration commands | grep host-name  # set system host-name 'vyos' -# Using state: deleted +# Using deleted +#  # Before state:  # -------------  # test#show configuration commands | grep host-name  # set system host-name 'vyos' -# Deleted play: -# ------------- +#  - name: Remove all existing configuration    vyos.vyos.vyos_hostname:      state: deleted +  # Commands Fired:  # ---------------  # "commands": [  #     "no hostname vyosTest",  # ], +#  # After state:  # ------------  # test#show configuration commands | grep host-name -# Using state: overridden +# Using overridden +#  # Before state:  # -------------  # test#show configuration commands | grep host-name  # set system host-name 'vyos' -# Overridden play: -# ---------------- +  - name: Override commands with provided configuration    vyos.vyos.vyos_hostname:      config:        hostname: vyosTest      state: overridden +  # Commands Fired:  # ---------------  # "commands": [  #       "hostname vyosTest",  #     ], +#  # After state:  # ------------  # test#show configuration commands | grep host-name  # set system host-name 'vyosTest' -# Using state: replaced +# Using replaced +#  # Before state:  # -------------  # test#show configuration commands | grep host-name  # set system host-name 'vyosTest' -# Replaced play: -# -------------- +  - name: Replace commands with provided configuration    vyos.vyos.vyos_hostname:      config:        hostname: vyos      state: replaced +  # After state:  # ------------  # test#show configuration commands | grep host-name  # set system host-name 'vyos' -# Using state: gathered +# Using gathered +#  # Before state:  # ------------- -#test#show configuration commands | grep host-name +# test#show configuration commands | grep host-name  # set system host-name 'vyos' -# Gathered play: -# -------------- +  - name: Gather listed hostname config    vyos.vyos.vyos_hostname:      state: gathered +  # Module Execution Result:  # ------------------------  #   "gathered": { diff --git a/plugins/modules/vyos_interfaces.py b/plugins/modules/vyos_interfaces.py index f0772ab5..c7a2168f 100644 --- a/plugins/modules/vyos_interfaces.py +++ b/plugins/modules/vyos_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_interfaces  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -167,21 +168,21 @@ EXAMPLES = """  - name: Merge provided configuration with device configuration    vyos.vyos.vyos_interfaces:      config: -    - name: eth2 -      description: Configured by Ansible -      enabled: true -      vifs: -      - vlan_id: 200 -        description: VIF 200 - ETH2 -    - name: eth3 -      description: Configured by Ansible -      mtu: 1500 -    - name: bond1 -      description: Bond - 1 -      mtu: 1200 -    - name: vti2 -      description: VTI - 2 -      enabled: false +      - name: eth2 +        description: Configured by Ansible +        enabled: true +        vifs: +          - vlan_id: 200 +            description: VIF 200 - ETH2 +      - name: eth3 +        description: Configured by Ansible +        mtu: 1500 +      - name: bond1 +        description: Bond - 1 +        mtu: 1200 +      - name: vti2 +        description: VTI - 2 +        enabled: false      state: merged  # Task Output @@ -299,12 +300,12 @@ EXAMPLES = """  - name: Replace device configurations of listed interfaces with provided configurations    vyos.vyos.vyos_interfaces:      config: -    - name: eth2 -      description: Replaced by Ansible -    - name: eth3 -      description: Replaced by Ansible -    - name: eth1 -      description: Replaced by Ansible +      - name: eth2 +        description: Replaced by Ansible +      - name: eth3 +        description: Replaced by Ansible +      - name: eth1 +        description: Replaced by Ansible      state: replaced  # Task Output @@ -437,15 +438,15 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_interfaces:      config: -    - name: eth0 -      description: Outbound Interface For The Appliance -      speed: auto -      duplex: auto -    - name: eth2 -      speed: auto -      duplex: auto -    - name: eth3 -      mtu: 1200 +      - name: eth0 +        description: Outbound Interface For The Appliance +        speed: auto +        duplex: auto +      - name: eth2 +        speed: auto +        duplex: auto +      - name: eth3 +        mtu: 1200      state: overridden  # Task Output @@ -576,10 +577,10 @@ EXAMPLES = """      themselves)    vyos.vyos.vyos_interfaces:      config: -    - name: bond1 -    - name: eth1 -    - name: eth2 -    - name: eth3 +      - name: bond1 +      - name: eth1 +      - name: eth2 +      - name: eth3      state: deleted  # Task Output @@ -693,7 +694,6 @@ EXAMPLES = """  #  - name: Gather listed interfaces with provided configurations    vyos.vyos.vyos_interfaces: -    config:      state: gathered  # Task output @@ -730,30 +730,31 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_interfaces:      config: -    - name: eth0 -      enabled: true -      duplex: auto -      speed: auto -    - name: eth1 -      description: Configured by Ansible - Interface 1 -      mtu: 1500 -      speed: auto -      duplex: auto -      enabled: true -      vifs: -      - vlan_id: 100 -        description: Eth1 - VIF 100 -        mtu: 400 +      - name: eth0          enabled: true -      - vlan_id: 101 -        description: Eth1 - VIF 101 +        duplex: auto +        speed: auto +      - name: eth1 +        description: Configured by Ansible - Interface 1 +        mtu: 1500 +        speed: auto +        duplex: auto          enabled: true -    - name: eth2 -      description: Configured by Ansible - Interface 2 (ADMIN DOWN) -      mtu: 600 -      enabled: false +        vifs: +          - vlan_id: 100 +            description: Eth1 - VIF 100 +            mtu: 400 +            enabled: true +          - vlan_id: 101 +            description: Eth1 - VIF 101 +            enabled: true +      - name: eth2 +        description: Configured by Ansible - Interface 2 (ADMIN DOWN) +        mtu: 600 +        enabled: false      state: rendered +  # Task Output  # -----------  # rendered: diff --git a/plugins/modules/vyos_l3_interfaces.py b/plugins/modules/vyos_l3_interfaces.py index cdf5842d..0849c296 100644 --- a/plugins/modules/vyos_l3_interfaces.py +++ b/plugins/modules/vyos_l3_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_l3_interfaces  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -141,28 +142,28 @@ EXAMPLES = """  - name: Merge provided configuration with device configuration    vyos.vyos.vyos_l3_interfaces:      config: -    - name: eth2 -      ipv4: -      - address: 192.0.2.10/28 -      - address: 198.51.100.40/27 -      ipv6: -      - address: 2001:db8:100::2/32 -      - address: 2001:db8:400::10/32 - -    - name: eth3 -      ipv4: -      - address: 203.0.113.65/26 -      vifs: -      - vlan_id: 101 +      - name: eth2          ipv4: -        - address: 192.0.2.71/28 -        - address: 198.51.100.131/25 -      - vlan_id: 102 +          - address: 192.0.2.10/28 +          - address: 198.51.100.40/27          ipv6: -        - address: 2001:db8:1000::5/38 -        - address: 2001:db8:1400::3/38 +          - address: '2001:db8:100::2/32' +          - address: '2001:db8:400::10/32' +      - name: eth3 +        ipv4: +          - address: 203.0.113.65/26 +        vifs: +          - vlan_id: 101 +            ipv4: +              - address: 192.0.2.71/28 +              - address: 198.51.100.131/25 +          - vlan_id: 102 +            ipv6: +              - address: '2001:db8:1000::5/38' +              - address: '2001:db8:1400::3/38'      state: merged +  # After state:  # -------------  # @@ -209,13 +210,13 @@ EXAMPLES = """  - name: Replace device configurations of listed interfaces with provided configurations    vyos.vyos.vyos_l3_interfaces:      config: -    - name: eth2 -      ipv4: -      - address: 192.0.2.10/24 +      - name: eth2 +        ipv4: +          - address: 192.0.2.10/24 -    - name: eth3 -      ipv6: -      - address: 2001:db8::11/32 +      - name: eth3 +        ipv6: +          - address: 2001:db8::11/32      state: replaced  # After state: @@ -265,13 +266,14 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_l3_interfaces:      config: -    - name: eth0 -      ipv4: -      - address: dhcp -      ipv6: -      - address: dhcpv6 +      - name: eth0 +        ipv4: +          - address: dhcp +        ipv6: +          - address: dhcpv6      state: overridden +  # After state  # ------------  # @@ -317,9 +319,9 @@ EXAMPLES = """      itself)    vyos.vyos.vyos_l3_interfaces:      config: -    - name: eth1 -    - name: eth2 -    - name: eth3 +      - name: eth1 +      - name: eth2 +      - name: eth3      state: deleted  # After state @@ -357,7 +359,6 @@ EXAMPLES = """  #  - name: Gather listed l3 interfaces with provided configurations    vyos.vyos.vyos_l3_interfaces: -    config:      state: gathered  #  # @@ -426,17 +427,18 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_l3_interfaces:      config: -    - name: eth1 -      ipv4: -      - address: 192.0.2.14/24 -    - name: eth2 -      ipv4: -      - address: 192.0.2.10/24 -      - address: 192.0.2.11/24 -      ipv6: -      - address: 2001:db8::10/32 -      - address: 2001:db8::12/32 +      - name: eth1 +        ipv4: +          - address: 192.0.2.14/24 +      - name: eth2 +        ipv4: +          - address: 192.0.2.10/24 +          - address: 192.0.2.11/24 +        ipv6: +          - address: '2001:db8::10/32' +          - address: '2001:db8::12/32'      state: rendered +  #  #  # ------------------------- @@ -510,8 +512,6 @@ EXAMPLES = """  #             "name": "eth0"  #         }  #     ] - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_lag_interfaces.py b/plugins/modules/vyos_lag_interfaces.py index fb365925..0605f068 100644 --- a/plugins/modules/vyos_lag_interfaces.py +++ b/plugins/modules/vyos_lag_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_lag_interfaces  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -136,21 +137,21 @@ EXAMPLES = """  - name: Merge provided configuration with device configuration    vyos.vyos.vyos_lag_interfaces:      config: -    - name: bond2 -      mode: active-backup -      members: -      - member: eth2 -      - member: eth1 -      hash_policy: layer2 -      primary: eth2 - -    - name: bond3 -      mode: active-backup -      hash_policy: layer2+3 -      members: -      - member: eth3 -      primary: eth3 +      - name: bond2 +        mode: active-backup +        members: +          - member: eth2 +          - member: eth1 +        hash_policy: layer2 +        primary: eth2 +      - name: bond3 +        mode: active-backup +        hash_policy: layer2+3 +        members: +          - member: eth3 +        primary: eth3      state: merged +  #  #  # ------------------------- @@ -240,11 +241,11 @@ EXAMPLES = """  - name: Replace device configurations of listed LAGs with provided configurations    vyos.vyos.vyos_lag_interfaces:      config: -    - name: bond3 -      mode: 802.3ad -      hash_policy: layer2 -      members: -      - member: eth3 +      - name: bond3 +        mode: 802.3ad +        hash_policy: layer2 +        members: +          - member: eth3      state: replaced  #  # @@ -345,14 +346,14 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_lag_interfaces:      config: -    - name: bond3 -      mode: active-backup -      members: -      - member: eth1 -      - member: eth2 -      - member: eth3 -      primary: eth3 -      hash_policy: layer2 +      - name: bond3 +        mode: active-backup +        members: +          - member: eth1 +          - member: eth2 +          - member: eth3 +        primary: eth3 +        hash_policy: layer2      state: overridden  #  # @@ -456,8 +457,8 @@ EXAMPLES = """      itself)    vyos.vyos.vyos_lag_interfaces:      config: -    - name: bond2 -    - name: bond3 +      - name: bond2 +      - name: bond3      state: deleted  #  # @@ -535,9 +536,8 @@ EXAMPLES = """  # set interfaces ethernet eth1 bond-group 'bond0'  # set interfaces ethernet eth2 bond-group 'bond1'  # -- name: Gather listed  lag interfaces with provided configurations +- name: Gather listed lag interfaces with provided configurations    vyos.vyos.vyos_lag_interfaces: -    config:      state: gathered  #  # @@ -636,19 +636,20 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_lag_interfaces:      config: -    - name: bond0 -      hash_policy: layer2 -      members: -      - member: eth1 -      mode: active-backup -      primary: eth1 -    - name: bond1 -      hash_policy: layer2+3 -      members: -      - member: eth2 -      mode: active-backup -      primary: eth2 +      - name: bond0 +        hash_policy: layer2 +        members: +          - member: eth1 +        mode: active-backup +        primary: eth1 +      - name: bond1 +        hash_policy: layer2+3 +        members: +          - member: eth2 +        mode: active-backup +        primary: eth2      state: rendered +  #  #  # ------------------------- @@ -714,8 +715,6 @@ EXAMPLES = """  #             "primary": "eth2"  #         }  #     ] - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_lldp_global.py b/plugins/modules/vyos_lldp_global.py index f59327a9..5d215f68 100644 --- a/plugins/modules/vyos_lldp_global.py +++ b/plugins/modules/vyos_lldp_global.py @@ -28,6 +28,7 @@ The module file for vyos_lldp_global  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -104,8 +105,8 @@ EXAMPLES = """    vyos.vyos.vyos_lldp_global:      config:        legacy_protocols: -      - fdp -      - cdp +        - fdp +        - cdp        snmp: enable        address: 192.0.2.11      state: merged @@ -166,9 +167,9 @@ EXAMPLES = """    vyos.vyos.vyos_lldp_global:      config:        legacy_protocols: -      - edp -      - sonmp -      - cdp +        - edp +        - sonmp +        - cdp        address: 192.0.2.14      state: replaced  # @@ -395,7 +396,7 @@ EXAMPLES = """        address: 192.0.2.17        enable: true        legacy_protocols: -      - cdp +        - cdp      state: rendered  #  # @@ -438,8 +439,6 @@ EXAMPLES = """  #         ]  #     }  # - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_lldp_interfaces.py b/plugins/modules/vyos_lldp_interfaces.py index 9260cb64..6628f65b 100644 --- a/plugins/modules/vyos_lldp_interfaces.py +++ b/plugins/modules/vyos_lldp_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_lldp_interfaces  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -110,25 +111,25 @@ options:              type: str    running_config:      description: -    - This option is used only with state I(parsed). -    - The value of this option should be the output received from the VyOS device -      by executing the command B(show configuration commands | grep lldp). -    - The state I(parsed) reads the configuration from C(running_config) option and -      transforms it into Ansible structured data as per the resource module's argspec -      and the value is then returned in the I(parsed) key within the result. +      - This option is used only with state I(parsed). +      - The value of this option should be the output received from the VyOS device +        by executing the command B(show configuration commands | grep lldp). +      - The state I(parsed) reads the configuration from C(running_config) option and +        transforms it into Ansible structured data as per the resource module's argspec +        and the value is then returned in the I(parsed) key within the result.      type: str    state:      description: -    - The state of the configuration after module completion. +      - The state of the configuration after module completion.      type: str      choices: -    - merged -    - replaced -    - overridden -    - deleted -    - rendered -    - parsed -    - gathered +      - merged +      - replaced +      - overridden +      - deleted +      - rendered +      - parsed +      - gathered      default: merged  """  EXAMPLES = """ @@ -142,22 +143,22 @@ EXAMPLES = """  - name: Merge provided configuration with device configuration    vyos.vyos.vyos_lldp_interfaces:      config: -    - name: eth1 -      location: -        civic_based: -          country_code: US -          ca_info: -          - ca_type: 0 -            ca_value: ENGLISH - -    - name: eth2 -      location: -        coordinate_based: -          altitude: 2200 -          datum: WGS84 -          longitude: 222.267255W -          latitude: 33.524449N +      - name: eth1 +        location: +          civic_based: +            country_code: US +            ca_info: +              - ca_type: 0 +                ca_value: ENGLISH +      - name: eth2 +        location: +          coordinate_based: +            altitude: 2200 +            datum: WGS84 +            longitude: 222.267255W +            latitude: 33.524449N      state: merged +  #  #  # ------------------------- @@ -233,24 +234,25 @@ EXAMPLES = """  # set service lldp interface eth2 location coordinate-based latitude '33.524449N'  # set service lldp interface eth2 location coordinate-based longitude '222.267255W'  # -- name: Replace device configurations of listed LLDP interfaces with provided configurations +- name: >- +    Replace device configurations of listed LLDP interfaces with provided +    configurations    vyos.vyos.vyos_lldp_interfaces:      config: -    - name: eth2 -      location: -        civic_based: -          country_code: US -          ca_info: -          - ca_type: 0 -            ca_value: ENGLISH - -    - name: eth1 -      location: -        coordinate_based: -          altitude: 2200 -          datum: WGS84 -          longitude: 222.267255W -          latitude: 33.524449N +      - name: eth2 +        location: +          civic_based: +            country_code: US +            ca_info: +              - ca_type: 0 +                ca_value: ENGLISH +      - name: eth1 +        location: +          coordinate_based: +            altitude: 2200 +            datum: WGS84 +            longitude: 222.267255W +            latitude: 33.524449N      state: replaced  #  # @@ -359,9 +361,9 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_lldp_interfaces:      config: -    - name: eth2 -      location: -        elin: 0000000911 +      - name: eth2 +        location: +          elin: 0000000911      state: overridden  # @@ -434,7 +436,7 @@ EXAMPLES = """  - name: Delete lldp  interface attributes of given interfaces.    vyos.vyos.vyos_lldp_interfaces:      config: -    - name: eth2 +      - name: eth2      state: deleted  #  # @@ -525,21 +527,22 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_lldp_interfaces:      config: -    - name: eth1 -      location: -        civic_based: -          country_code: US -          ca_info: -          - ca_type: 0 -            ca_value: ENGLISH -    - name: eth2 -      location: -        coordinate_based: -          altitude: 2200 -          datum: WGS84 -          longitude: 222.267255W -          latitude: 33.524449N +      - name: eth1 +        location: +          civic_based: +            country_code: US +            ca_info: +              - ca_type: 0 +                ca_value: ENGLISH +      - name: eth2 +        location: +          coordinate_based: +            altitude: 2200 +            datum: WGS84 +            longitude: 222.267255W +            latitude: 33.524449N      state: rendered +  #  #  # ------------------------- @@ -606,8 +609,6 @@ EXAMPLES = """  #             "name": "eth1"  #         }  #     ] - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_logging.py b/plugins/modules/vyos_logging.py index 7e1dea7b..204e4f91 100644 --- a/plugins/modules/vyos_logging.py +++ b/plugins/modules/vyos_logging.py @@ -2,6 +2,7 @@  # -*- coding: utf-8 -*-  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  # (c) 2017, Ansible by Red Hat, inc @@ -130,16 +131,29 @@ EXAMPLES = """  - name: Add logging aggregate    vyos.vyos.vyos_logging:      aggregate: -    - {dest: file, name: test1, facility: all, level: info} -    - {dest: file, name: test2, facility: news, level: debug} +      - dest: file +        name: test1 +        facility: all +        level: info +      - dest: file +        name: test2 +        facility: news +        level: debug      state: present  - name: Remove logging aggregate    vyos.vyos.vyos_logging:      aggregate: -    - {dest: console, facility: all, level: info} -    - {dest: console, facility: daemon, level: warning} -    - {dest: file, name: test2, facility: news, level: debug} +      - dest: console +        facility: all +        level: info +      - dest: console +        facility: daemon +        level: warning +      - dest: file +        name: test2 +        facility: news +        level: debug      state: absent  """ @@ -153,6 +167,7 @@ commands:  """  import re +  from copy import deepcopy  from ansible.module_utils._text import to_text @@ -184,23 +199,37 @@ def spec_to_commands(updates, module):              if w["name"]:                  commands.append(                      "delete system syslog {0} {1} facility {2} level {3}".format( -                        dest, name, facility, level -                    ) +                        dest, +                        name, +                        facility, +                        level, +                    ),                  )              else:                  commands.append( -                    "delete system syslog {0} facility {1} level {2}".format(dest, facility, level) +                    "delete system syslog {0} facility {1} level {2}".format( +                        dest, +                        facility, +                        level, +                    ),                  )          elif state == "present" and w not in have:              if w["name"]:                  commands.append(                      "set system syslog {0} {1} facility {2} level {3}".format( -                        dest, name, facility, level -                    ) +                        dest, +                        name, +                        facility, +                        level, +                    ),                  )              else:                  commands.append( -                    "set system syslog {0} facility {1} level {2}".format(dest, facility, level) +                    "set system syslog {0} facility {1} level {2}".format( +                        dest, +                        facility, +                        level, +                    ),                  )      return commands @@ -239,7 +268,7 @@ def config_to_dict(module):                          "name": name,                          "facility": facility,                          "level": level, -                    } +                    },                  )      return obj @@ -272,7 +301,7 @@ def map_params_to_obj(module, required_if=None):                  "facility": module.params["facility"],                  "level": module.params["level"],                  "state": module.params["state"], -            } +            },          )      return obj @@ -293,7 +322,9 @@ def main():      # remove default in aggregate spec, to handle common arguments      remove_default_spec(aggregate_spec) -    argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) +    argument_spec = dict( +        aggregate=dict(type="list", elements="dict", options=aggregate_spec), +    )      argument_spec.update(element_spec) diff --git a/plugins/modules/vyos_logging_global.py b/plugins/modules/vyos_logging_global.py index 18248d6d..06ebe48d 100644 --- a/plugins/modules/vyos_logging_global.py +++ b/plugins/modules/vyos_logging_global.py @@ -10,6 +10,7 @@ The module file for vyos_logging_global  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -220,15 +221,15 @@ EXAMPLES = """        users:          - username: vyos            facilities: -          - facility: local7 -            severity: debug +            - facility: local7 +              severity: debug        global_params:          archive:            file_num: 2            size: 111          facilities: -        - facility: cron -          severity: debug +          - facility: cron +            severity: debug          marker_interval: 111          preserve_fqdn: true      state: merged @@ -396,10 +397,11 @@ EXAMPLES = """        users:          - username: paul            facilities: -          - facility: local7 -            severity: err +            - facility: local7 +              severity: err      state: replaced +  # Commands Fired:  # --------------- diff --git a/plugins/modules/vyos_ntp_global.py b/plugins/modules/vyos_ntp_global.py index 10a21702..0fe56ad0 100644 --- a/plugins/modules/vyos_ntp_global.py +++ b/plugins/modules/vyos_ntp_global.py @@ -10,6 +10,7 @@ The module file for vyos_ntp_global  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -98,18 +99,18 @@ EXAMPLES = """  - name: Replace the existing ntp config with the new config    vyos.vyos.vyos_ntp_global:      config: -        allow_clients: -          - 10.6.6.0/24 -        listen_addresses: -          - 10.1.3.1 -        servers: -          - server: 203.0.113.0 -            options: -                - prefer - - -# # Task output: -# # ------------- +      allow_clients: +        - 10.6.6.0/24 +      listen_addresses: +        - 10.1.3.1 +      servers: +        - server: 203.0.113.0 +          options: +            - prefer + + +# Task output: +# -------------  #        "after": {  #         "allow_clients": [  #            "10.6.6.0/24" @@ -189,14 +190,14 @@ EXAMPLES = """  - name: Replace the existing ntp config with the new config    vyos.vyos.vyos_ntp_global:      config: -        allow_clients: -          - 10.6.6.0/24 -        listen_addresses: -          - 10.1.3.1 -        servers: -          - server: 203.0.113.0 -            options: -                - prefer +      allow_clients: +        - 10.6.6.0/24 +      listen_addresses: +        - 10.1.3.1 +      servers: +        - server: 203.0.113.0 +          options: +            - prefer      state: replaced @@ -302,8 +303,6 @@ EXAMPLES = """  #        set system ntp server time3.vyos.net  #        vyos@vyos:~$ - -  # # -------------------  # # 3. Using overridden  # # ------------------- @@ -319,30 +318,28 @@ EXAMPLES = """  #        set system ntp server time3.vyos.net  #        vyos@vyos:~$ -# # Task -# # ------------- +# Task +# -------------  - name: Override ntp config    vyos.vyos.vyos_ntp_global: -        config: -          allow_clients: -            - 10.3.3.0/24 -          listen_addresses: -            - 10.7.8.1 -          servers: -            - server: server1 -              options: -                - dynamic -                - prefer - -            - server: server2 -              options: -                - noselect -                - preempt - -            - server: serv -        state: overridden - - +    config: +      allow_clients: +        - 10.3.3.0/24 +      listen_addresses: +        - 10.7.8.1 +      servers: +        - server: server1 +          options: +            - dynamic +            - prefer + +        - server: server2 +          options: +            - noselect +            - preempt + +        - server: serv +    state: overridden  # # Task output:  # # ------------- @@ -436,11 +433,8 @@ EXAMPLES = """  #        set system ntp server time3.vyos.net  #        vyos@vyos:~$ - - -# # ------------------- -# # 4. Using gathered -# # ------------------- +# 4. Using gathered +# -------------------  # # Before state:  # # ------------- @@ -457,11 +451,11 @@ EXAMPLES = """  #        set system ntp server time3.vyos.net  #        vyos@vyos:~$ -# # Task -# # ------------- +# Task +# -------------  - name: Gather ntp config    vyos.vyos.vyos_ntp_global: -        state: gathered +    state: gathered  # # Task output:  # # ------------- @@ -626,32 +620,27 @@ EXAMPLES = """  #        set system ntp server time3.vyos.net  #        vyos@vyos:~$ -# # Task -# # ------------- +# Task +# -------------  - name: Render ntp config    vyos.vyos.vyos_ntp_global: -       config: -        allow_clients: -            - 10.7.7.0/24 -            - 10.8.8.0/24 -        listen_addresses: -            - 10.7.9.1 -        servers: -            - server: server7 - -            - server: server45 -              options: -                - noselect -                - prefer -                - pool -            - server: time1.vyos.net - -            - server: time2.vyos.net - -            - server: time3.vyos.net - -        state: rendered - +    config: +      allow_clients: +        - 10.7.7.0/24 +        - 10.8.8.0/24 +      listen_addresses: +        - 10.7.9.1 +      servers: +        - server: server7 +        - server: server45 +          options: +            - noselect +            - prefer +            - pool +        - server: time1.vyos.net +        - server: time2.vyos.net +        - server: time3.vyos.net +      state: rendered  # # Task output:  # # ------------- @@ -685,12 +674,12 @@ EXAMPLES = """  #           "set system ntp server time2.vyos.net",  #           "set system ntp server time3.vyos.net" -# # Task: -# # ------------- +# Task: +# -------------  - name: Parse externally provided ntp configuration    vyos.vyos.vyos_ntp_global: -     running_config: "{{ lookup('file', './sample_config.cfg') }}" -     state: parsed +    running_config: "{{ lookup('file', './sample_config.cfg') }}" +    state: parsed  # # Task output:  # # ------------- @@ -724,7 +713,6 @@ EXAMPLES = """  #  #                ]  #            } -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_ospf_interfaces.py b/plugins/modules/vyos_ospf_interfaces.py index 9a78ebd8..c2326895 100644 --- a/plugins/modules/vyos_ospf_interfaces.py +++ b/plugins/modules/vyos_ospf_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_ospf_interfaces  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -58,7 +59,7 @@ options:              - Address Family Identifier (AFI) for OSPF settings on the interfaces.              type: str              choices: ['ipv4', 'ipv6'] -            required: True +            required: true            authentication:              description:              - Authentication settings on the interface. @@ -161,29 +162,29 @@ EXAMPLES = """  # @vyos:~$ show configuration commands | match "ospf" -  - name: Merge provided configuration with device configuration -    vyos.vyos.vyos_ospf_interfaces: -      config: -        - name: "eth1" -          address_family: -            - afi: "ipv4" -              transmit_delay: 50 -              priority: 26 -              network: "point-to-point" -            - afi: "ipv6" -              dead_interval: 39 -        - name: "bond2" -          address_family: -            - afi: "ipv4" -              transmit_delay: 45 -              bandwidth: 70 -              authentication: -                md5_key: -                  key_id: 10 -                  key: "1111111111232345" -            - afi: "ipv6" -              passive: True -      state: merged +- name: Merge provided configuration with device configuration +  vyos.vyos.vyos_ospf_interfaces: +    config: +      - name: "eth1" +        address_family: +          - afi: "ipv4" +            transmit_delay: 50 +            priority: 26 +            network: "point-to-point" +          - afi: "ipv6" +            dead_interval: 39 +      - name: "bond2" +        address_family: +          - afi: "ipv4" +            transmit_delay: 45 +            bandwidth: 70 +            authentication: +              md5_key: +                key_id: 10 +                key: "1111111111232345" +          - afi: "ipv6" +            passive: true +    state: merged  # After State:  # -------------- @@ -270,9 +271,6 @@ EXAMPLES = """  #        "set interfaces bonding bond2 ipv6 ospfv3 passive"  #    ], - - -  # Using replaced:  # Before State: @@ -288,22 +286,22 @@ EXAMPLES = """  # set interfaces ethernet eth1 ip ospf transmit-delay '50'  # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' -  - name: Replace provided configuration with device configuration -    vyos.vyos.vyos_ospf_interfaces: -      config: -        - name: "eth1" -          address_family: -            - afi: "ipv4" -              cost: 100 -            - afi: "ipv6" -              ifmtu: 33 -        - name: "bond2" -          address_family: -            - afi: "ipv4" -              transmit_delay: 45 -            - afi: "ipv6" -              passive: True -      state: replaced +- name: Replace provided configuration with device configuration +  vyos.vyos.vyos_ospf_interfaces: +    config: +      - name: "eth1" +        address_family: +          - afi: "ipv4" +            cost: 100 +          - afi: "ipv6" +            ifmtu: 33 +      - name: "bond2" +        address_family: +          - afi: "ipv4" +            transmit_delay: 45 +          - afi: "ipv6" +            passive: true +    state: replaced  # After State:  # ----------- @@ -432,17 +430,18 @@ EXAMPLES = """  # set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33'  # vyos@vyos:~$ -  - name: Override device configuration with provided configuration -    vyos.vyos.vyos_ospf_interfaces: -      config: -        - name: "eth0" -          address_family: -            - afi: "ipv4" -              cost: 100 -            - afi: "ipv6" -              ifmtu: 33 -              passive: True -      state: overridden +- name: Override device configuration with provided configuration +  vyos.vyos.vyos_ospf_interfaces: +    config: +      - name: "eth0" +        address_family: +          - afi: "ipv4" +            cost: 100 +          - afi: "ipv6" +            ifmtu: 33 +            passive: true +    state: overridden +  # After State:  # ----------- @@ -561,11 +560,11 @@ EXAMPLES = """  # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'  # vyos@vyos:~$ -  - name: Delete device configuration -    vyos.vyos.vyos_ospf_interfaces: -      config: -        - name: "eth0" -      state: deleted +- name: Delete device configuration +  vyos.vyos.vyos_ospf_interfaces: +    config: +      - name: "eth0" +    state: deleted  # After State:  # ----------- @@ -708,10 +707,10 @@ EXAMPLES = """  # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'  # -  - name: parse configs -    vyos.vyos.vyos_ospf_interfaces: -      running_config: "{{ lookup('file', './parsed.cfg') }}" -      state: parsed +- name: parse configs +  vyos.vyos.vyos_ospf_interfaces: +    running_config: "{{ lookup('file', './parsed.cfg') }}" +    state: parsed  # Module Execution:  # ---------------- @@ -772,29 +771,29 @@ EXAMPLES = """  # Using rendered:  # -------------- -  - name: Render -    vyos.vyos.vyos_ospf_interfaces: -      config: -        - name: "eth1" -          address_family: -            - afi: "ipv4" -              transmit_delay: 50 -              priority: 26 -              network: "point-to-point" -            - afi: "ipv6" -              dead_interval: 39 -        - name: "bond2" -          address_family: -            - afi: "ipv4" -              transmit_delay: 45 -              bandwidth: 70 -              authentication: -                md5_key: -                  key_id: 10 -                  key: "1111111111232345" -            - afi: "ipv6" -              passive: True -      state: rendered +- name: Render +  vyos.vyos.vyos_ospf_interfaces: +    config: +      - name: "eth1" +        address_family: +          - afi: "ipv4" +            transmit_delay: 50 +            priority: 26 +            network: "point-to-point" +          - afi: "ipv6" +            dead_interval: 39 +      - name: "bond2" +        address_family: +          - afi: "ipv4" +            transmit_delay: 45 +            bandwidth: 70 +            authentication: +              md5_key: +                key_id: 10 +                key: "1111111111232345" +          - afi: "ipv6" +            passive: true +    state: rendered  # Module Execution:  # ---------------- @@ -827,9 +826,9 @@ EXAMPLES = """  # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'  # vyos@vyos:~$ -  - name: gather configs -    vyos.vyos.vyos_ospf_interfaces: -      state: gathered +- name: gather configs +  vyos.vyos.vyos_ospf_interfaces: +    state: gathered  # Module Execution:  # ----------------- @@ -880,11 +879,6 @@ EXAMPLES = """  #            "name": "eth3"  #        }  #    ], - - - - -  """  from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_ospfv2.py b/plugins/modules/vyos_ospfv2.py index 863bc6fc..10e49740 100644 --- a/plugins/modules/vyos_ospfv2.py +++ b/plugins/modules/vyos_ospfv2.py @@ -28,6 +28,7 @@ The module file for vyos_ospfv2  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -389,42 +390,42 @@ EXAMPLES = """          auto_cost:            reference_bandwidth: 2          neighbor: -        - neighbor_id: 192.0.11.12 -          poll_interval: 10 -          priority: 2 +          - neighbor_id: 192.0.11.12 +            poll_interval: 10 +            priority: 2          redistribute: -        - route_type: bgp -          metric: 10 -          metric_type: 2 +          - route_type: bgp +            metric: 10 +            metric_type: 2          passive_interface: -        - eth1 -        - eth2 +          - eth1 +          - eth2          parameters:            router_id: 192.0.1.1            opaque_lsa: true            rfc1583_compatibility: true            abr_type: cisco          areas: -        - area_id: '2' -          area_type: -            normal: true -            authentication: plaintext-password -            shortcut: enable -        - area_id: '3' -          area_type: -            nssa: -              set: true -        - area_id: '4' -          area_type: -            stub: -              default_cost: 20 -          network: -          - address: 192.0.2.0/24 -          range: -          - address: 192.0.3.0/24 -            cost: 10 -          - address: 192.0.4.0/24 -          cost: 12 +          - area_id: '2' +            area_type: +              normal: true +              authentication: plaintext-password +              shortcut: enable +          - area_id: '3' +            area_type: +              nssa: +                set: true +          - area_id: '4' +            area_type: +              stub: +                default_cost: 20 +            network: +              - address: 192.0.2.0/24 +            range: +              - address: 192.0.3.0/24 +                cost: 10 +              - address: 192.0.4.0/24 +            cost: 12      state: merged  #  # @@ -612,23 +613,23 @@ EXAMPLES = """    vyos.vyos.vyos_ospfv2:      config:        areas: -      - area_id: '2' -        area_type: -          normal: true -        authentication: plaintext-password -        shortcut: enable -      - area_id: '3' -        area_type: -          nssa: -            set: false -      - area_id: '4' -        area_type: -          stub: -            default_cost: 20 -        network: -        - address: 192.0.2.0/24 -        - address: 192.0.22.0/24 -        - address: 192.0.32.0/24 +        - area_id: '2' +          area_type: +            normal: true +          authentication: plaintext-password +          shortcut: enable +        - area_id: '3' +          area_type: +            nssa: +              set: false +        - area_id: '4' +          area_type: +            stub: +              default_cost: 20 +          network: +            - address: 192.0.2.0/24 +            - address: 192.0.22.0/24 +            - address: 192.0.32.0/24      state: merged  #  # @@ -920,39 +921,40 @@ EXAMPLES = """          auto_cost:            reference_bandwidth: 2          neighbor: -        - neighbor_id: 192.0.11.12 -          poll_interval: 10 -          priority: 2 +          - neighbor_id: 192.0.11.12 +            poll_interval: 10 +            priority: 2          redistribute: -        - route_type: bgp -          metric: 10 -          metric_type: 2 +          - route_type: bgp +            metric: 10 +            metric_type: 2          passive_interface: -        - eth1 +          - eth1          parameters:            router_id: 192.0.1.1            opaque_lsa: true            rfc1583_compatibility: true            abr_type: cisco          areas: -        - area_id: '2' -          area_type: -            normal: true -          authentication: plaintext-password -          shortcut: enable -        - area_id: '4' -          area_type: -            stub: -              default_cost: 20 -          network: -          - address: 192.0.2.0/24 -          - address: 192.0.12.0/24 -          - address: 192.0.22.0/24 -          - address: 192.0.32.0/24 -          range: -          - address: 192.0.42.0/24 -            cost: 10 +          - area_id: '2' +            area_type: +              normal: true +            authentication: plaintext-password +            shortcut: enable +          - area_id: '4' +            area_type: +              stub: +                default_cost: 20 +            network: +              - address: 192.0.2.0/24 +              - address: 192.0.12.0/24 +              - address: 192.0.22.0/24 +              - address: 192.0.32.0/24 +            range: +              - address: 192.0.42.0/24 +                cost: 10      state: replaced +  #  #  # ------------------------- @@ -1213,42 +1215,42 @@ EXAMPLES = """          auto_cost:            reference_bandwidth: 2          neighbor: -        - neighbor_id: 192.0.11.12 -          poll_interval: 10 -          priority: 2 +          - neighbor_id: 192.0.11.12 +            poll_interval: 10 +            priority: 2          redistribute: -        - route_type: bgp -          metric: 10 -          metric_type: 2 +          - route_type: bgp +            metric: 10 +            metric_type: 2          passive_interface: -        - eth1 -        - eth2 +          - eth1 +          - eth2          parameters:            router_id: 192.0.1.1            opaque_lsa: true            rfc1583_compatibility: true            abr_type: cisco          areas: -        - area_id: '2' -          area_type: -            normal: true -          authentication: plaintext-password -          shortcut: enable -        - area_id: '3' -          area_type: -            nssa: -              set: true -        - area_id: '4' -          area_type: -            stub: -              default_cost: 20 -          network: -          - address: 192.0.2.0/24 -          range: -          - address: 192.0.3.0/24 -            cost: 10 -          - address: 192.0.4.0/24 -            cost: 12 +          - area_id: '2' +            area_type: +              normal: true +            authentication: plaintext-password +            shortcut: enable +          - area_id: '3' +            area_type: +              nssa: +                set: true +          - area_id: '4' +            area_type: +              stub: +                default_cost: 20 +            network: +              - address: 192.0.2.0/24 +            range: +              - address: 192.0.3.0/24 +                cost: 10 +              - address: 192.0.4.0/24 +                cost: 12      state: rendered  #  # @@ -1754,7 +1756,6 @@ EXAMPLES = """  # ------------  # vyos@192# run show configuration commands | grep ospf  # -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_ospfv3.py b/plugins/modules/vyos_ospfv3.py index 4ff6106f..8dbaaeee 100644 --- a/plugins/modules/vyos_ospfv3.py +++ b/plugins/modules/vyos_ospfv3.py @@ -28,6 +28,7 @@ The module file for vyos_ospfv3  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -130,21 +131,22 @@ EXAMPLES = """    vyos.vyos.vyos_ospfv3:      config:        redistribute: -      - route_type: bgp +        - route_type: bgp        parameters:          router_id: 192.0.2.10        areas: -      - area_id: '2' -        export_list: export1 -        import_list: import1 -        range: -        - address: 2001:db10::/32 -        - address: 2001:db20::/32 -        - address: 2001:db30::/32 -      - area_id: '3' -        range: -        - address: 2001:db40::/32 +        - area_id: '2' +          export_list: export1 +          import_list: import1 +          range: +            - address: '2001:db10::/32' +            - address: '2001:db20::/32' +            - address: '2001:db30::/32' +        - area_id: '3' +          range: +            - address: '2001:db40::/32'      state: merged +  #  #  # ------------------------- @@ -236,21 +238,22 @@ EXAMPLES = """    vyos.vyos.vyos_ospfv3:      config:        redistribute: -      - route_type: bgp +        - route_type: bgp        parameters:          router_id: 192.0.2.10        areas: -      - area_id: '2' -        export_list: export1 -        import_list: import1 -        range: -        - address: 2001:db10::/32 -        - address: 2001:db30::/32 -        - address: 2001:db50::/32 -      - area_id: '4' -        range: -        - address: 2001:db60::/32 +        - area_id: '2' +          export_list: export1 +          import_list: import1 +          range: +            - address: '2001:db10::/32' +            - address: '2001:db30::/32' +            - address: '2001:db50::/32' +        - area_id: '4' +          range: +            - address: '2001:db60::/32'      state: replaced +  #  #  # ------------------------- @@ -360,21 +363,22 @@ EXAMPLES = """    vyos.vyos.vyos_ospfv3:      config:        redistribute: -      - route_type: bgp +        - route_type: bgp        parameters:          router_id: 192.0.2.10        areas: -      - area_id: '2' -        export_list: export1 -        import_list: import1 -        range: -        - address: 2001:db10::/32 -        - address: 2001:db20::/32 -        - address: 2001:db30::/32 -      - area_id: '3' -        range: -        - address: 2001:db40::/32 +        - area_id: '2' +          export_list: export1 +          import_list: import1 +          range: +            - address: '2001:db10::/32' +            - address: '2001:db20::/32' +            - address: '2001:db30::/32' +        - area_id: '3' +          range: +            - address: '2001:db40::/32'      state: rendered +  #  #  # ------------------------- @@ -602,8 +606,6 @@ EXAMPLES = """  # After state  # ------------  # vyos@192# run show configuration commands | grep ospfv3 - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_ping.py b/plugins/modules/vyos_ping.py index 8c0330df..98619399 100644 --- a/plugins/modules/vyos_ping.py +++ b/plugins/modules/vyos_ping.py @@ -21,6 +21,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -217,10 +218,10 @@ def build_ping(dest, count, size=None, interval=None, source=None, ttl=None):  def parse_rate(rate_info):      rate_re = re.compile( -        r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)" +        r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)",      )      rate_err_re = re.compile( -        r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)" +        r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)",      )      if rate_re.match(rate_info): @@ -233,7 +234,7 @@ def parse_rate(rate_info):  def parse_rtt(rtt_info):      rtt_re = re.compile( -        r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)" +        r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)",      )      rtt = rtt_re.match(rtt_info) diff --git a/plugins/modules/vyos_prefix_lists.py b/plugins/modules/vyos_prefix_lists.py index ed190d49..c0d50d31 100644 --- a/plugins/modules/vyos_prefix_lists.py +++ b/plugins/modules/vyos_prefix_lists.py @@ -10,6 +10,7 @@ The module file for vyos_prefix_lists  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -1240,7 +1241,6 @@ EXAMPLES = """  #             ]  #         }  #     ] -  """  RETURN = """ diff --git a/plugins/modules/vyos_route_maps.py b/plugins/modules/vyos_route_maps.py index d49261cf..bff6859d 100644 --- a/plugins/modules/vyos_route_maps.py +++ b/plugins/modules/vyos_route_maps.py @@ -10,6 +10,7 @@ The module file for vyos_route_maps  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -264,35 +265,35 @@ EXAMPLES = """  # vyos@vyos:~$ show configuration commands |  match "set policy route-map"  # vyos@vyos:~$ -    - name: Merge the provided configuration with the existing running configuration -      register: result -      vyos.vyos.vyos_route_maps: &id001 -        config: -          - route_map: test1 -            entries: -              - sequence: 1 -                description: "test" -                action: permit -                continue: 2 -                on_match: -                  next: True -          - route_map: test3 -            entries: -              - sequence: 1 -                action: permit -                match: -                  rpki: invalid -                  metric: 1 -                  peer: 192.0.2.32 -                set: -                  local_preference: 4 -                  metric: 5 -                  metric_type: "type-1" -                  origin: egp -                  originator_id: 192.0.2.34 -                  tag: 5 -                  weight: 4 -        state: merged +- name: Merge the provided configuration with the existing running configuration +  register: result +  vyos.vyos.vyos_route_maps: &id001 +    config: +      - route_map: test1 +        entries: +          - sequence: 1 +            description: "test" +            action: permit +            continue: 2 +            on_match: +              next: true +      - route_map: test3 +        entries: +          - sequence: 1 +            action: permit +            match: +              rpki: invalid +              metric: 1 +              peer: 192.0.2.32 +            set: +              local_preference: 4 +              metric: 5 +              metric_type: "type-1" +              origin: egp +              originator_id: 192.0.2.34 +              tag: 5 +              weight: 4 +    state: merged  # After State  # vyos@vyos:~$ show configuration commands |  match "set policy route-maps"  #   set policy route-map test1 rule 1 description test @@ -913,8 +914,6 @@ EXAMPLES = """  #         "set policy route-map test3 rule 1 match metric 3",  #         "set policy route-map test3 rule 1 match peer 192.0.2.35"  #     ], -# -  """  from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_snmp_server.py b/plugins/modules/vyos_snmp_server.py index 74bae3fc..5eb69b88 100644 --- a/plugins/modules/vyos_snmp_server.py +++ b/plugins/modules/vyos_snmp_server.py @@ -10,6 +10,7 @@ The module file for vyos_snmp_server  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  DOCUMENTATION = """ @@ -268,30 +269,29 @@ EXAMPLES = """  # vyos@vyos:~$ show configuration commands | grep snmp  # vyos@vyos:~$ -  - name: Merge provided configuration with device configuration -    vyos.vyos.vyos_snmp_server: -      config: -        communities: -          - name: "switches" -            authorization_type: "rw" -          - name: "bridges" -            clients: ["1.1.1.1", "12.1.1.10"] -        contact: "admin2@ex.com" -        listen_addresses: -          - address: "20.1.1.1" -          - address: "100.1.2.1" -            port: 33 -        snmp_v3: -          users: -            - user: admin_user -              authentication: -                plaintext_key: "abc1234567" -                type: "sha" -              privacy: -                plaintext_key: "abc1234567" -                type: "aes" - -      state: merged +- name: Merge provided configuration with device configuration +  vyos.vyos.vyos_snmp_server: +    config: +      communities: +        - name: "switches" +          authorization_type: "rw" +        - name: "bridges" +          clients: ["1.1.1.1", "12.1.1.10"] +      contact: "admin2@ex.com" +      listen_addresses: +        - address: "20.1.1.1" +        - address: "100.1.2.1" +          port: 33 +      snmp_v3: +        users: +          - user: admin_user +            authentication: +              plaintext_key: "abc1234567" +              type: "sha" +            privacy: +              plaintext_key: "abc1234567" +              type: "aes" +    state: merged  # After State: @@ -366,9 +366,10 @@ EXAMPLES = """  #     ],  # -# using Replaced: +# Using replaced  # Before State +# -------------  # vyos@vyos:~$ show configuration commands | grep snmp  # set service snmp community bridges client '1.1.1.1'  # set service snmp community bridges client '12.1.1.10' @@ -380,43 +381,42 @@ EXAMPLES = """  # set service snmp v3 user admin_user auth type 'sha'  # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'  # set service snmp v3 user admin_user privacy type 'aes' -# vyos@vyos:~$ -  - name: Replace -    vyos.vyos.vyos_snmp_server: -      config: -        communities: -          - name: "bridges" -            networks: ["1.1.1.0/24", "12.1.1.0/24"] -        location: "RDU, NC" -        listen_addresses: -          - address: "100.1.2.1" -            port: 33 -        snmp_v3: -          groups: -            - group: "default" -              view: "default" -          users: -            - user: admin_user -              authentication: -                plaintext_key: "abc1234567" -                type: "sha" -              privacy: -                plaintext_key: "abc1234567" -                type: "aes" -              group: "default" -            - user: guest_user2 -              authentication: -                plaintext_key: "opq1234567" -                type: "sha" -              privacy: -                plaintext_key: "opq1234567" -                type: "aes" -          views: -            - view: "default" -              oid: 1 +- name: Replace SNMP Server configuration +  vyos.vyos.vyos_snmp_server: +    config: +      communities: +        - name: "bridges" +          networks: ["1.1.1.0/24", "12.1.1.0/24"] +      location: "RDU, NC" +      listen_addresses: +        - address: "100.1.2.1" +          port: 33 +      snmp_v3: +        groups: +          - group: "default" +            view: "default" +        users: +          - user: admin_user +            authentication: +              plaintext_key: "abc1234567" +              type: "sha" +            privacy: +              plaintext_key: "abc1234567" +              type: "aes" +            group: "default" +          - user: guest_user2 +            authentication: +              plaintext_key: "opq1234567" +              type: "sha" +            privacy: +              plaintext_key: "opq1234567" +              type: "aes" +        views: +          - view: "default" +            oid: 1 -      state: replaced +    state: replaced  # After State:  # vyos@vyos:~$ show configuration commands | grep snmp @@ -572,43 +572,41 @@ EXAMPLES = """  # set service snmp v3 user admin_user auth type 'sha'  # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'  # set service snmp v3 user admin_user privacy type 'aes' -# vyos@vyos:~$ -  - name: Override config -    vyos.vyos.vyos_snmp_server: -      config: -        communities: -          - name: "bridges" -            networks: ["1.1.1.0/24", "12.1.1.0/24"] -        location: "RDU, NC" -        listen_addresses: -          - address: "100.1.2.1" -            port: 33 -        snmp_v3: -          groups: -            - group: "default" -              view: "default" -          users: -            - user: admin_user -              authentication: -                plaintext_key: "abc1234567" -                type: "sha" -              privacy: -                plaintext_key: "abc1234567" -                type: "aes" -              group: "default" -            - user: guest_user2 -              authentication: -                plaintext_key: "opq1234567" -                type: "sha" -              privacy: -                plaintext_key: "opq1234567" -                type: "aes" -          views: -            - view: "default" -              oid: 1 - -      state: overridden +- name: Override SNMP server config +  vyos.vyos.vyos_snmp_server: +    config: +      communities: +        - name: "bridges" +          networks: ["1.1.1.0/24", "12.1.1.0/24"] +      location: "RDU, NC" +      listen_addresses: +        - address: "100.1.2.1" +          port: 33 +      snmp_v3: +        groups: +          - group: "default" +            view: "default" +        users: +          - user: admin_user +            authentication: +              plaintext_key: "abc1234567" +              type: "sha" +            privacy: +              plaintext_key: "abc1234567" +              type: "aes" +            group: "default" +          - user: guest_user2 +            authentication: +              plaintext_key: "opq1234567" +              type: "sha" +            privacy: +              plaintext_key: "opq1234567" +              type: "aes" +        views: +          - view: "default" +            oid: 1 +    state: overridden  # After State:  # vyos@vyos:~$ show configuration commands | grep snmp @@ -771,11 +769,10 @@ EXAMPLES = """  # set service snmp v3 user guest_user2 privacy plaintext-key 'opq1234567'  # set service snmp v3 user guest_user2 privacy type 'aes'  # set service snmp v3 view default oid 1 -# vyos@vyos:~$ -  - name: Delete Config -    vyos.vyos.vyos_snmp_server: -      state: deleted +- name: Delete Config +  vyos.vyos.vyos_snmp_server: +    state: deleted  # After State:  # vyos@vyos:~$ show configuration commands | grep snmp @@ -849,30 +846,29 @@ EXAMPLES = """  #     ],  # Using rendered: -  - name: Render provided configuration -    vyos.vyos.vyos_snmp_server: -      config: -        communities: -          - name: "switches" -            authorization_type: "rw" -          - name: "bridges" -            clients: ["1.1.1.1", "12.1.1.10"] -        contact: "admin2@ex.com" -        listen_addresses: -          - address: "20.1.1.1" -          - address: "100.1.2.1" -            port: 33 -        snmp_v3: -          users: -            - user: admin_user -              authentication: -                plaintext_key: "abc1234567" -                type: "sha" -              privacy: -                plaintext_key: "abc1234567" -                type: "aes" - -      state: rendered +- name: Render provided configuration +  vyos.vyos.vyos_snmp_server: +    config: +      communities: +        - name: "switches" +          authorization_type: "rw" +        - name: "bridges" +          clients: ["1.1.1.1", "12.1.1.10"] +      contact: "admin2@ex.com" +      listen_addresses: +        - address: "20.1.1.1" +        - address: "100.1.2.1" +          port: 33 +      snmp_v3: +        users: +          - user: admin_user +            authentication: +              plaintext_key: "abc1234567" +              type: "sha" +            privacy: +              plaintext_key: "abc1234567" +              type: "aes" +    state: rendered  # Module Execution:  #  "rendered": [ @@ -903,11 +899,10 @@ EXAMPLES = """  # set service snmp v3 user admin_user auth type 'sha'  # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'  # set service snmp v3 user admin_user privacy type 'aes' -# vyos@vyos:~$ -  - name: gather configs -    vyos.vyos.vyos_snmp_server: -      state: gathered +- name: Gather SNMP server config +  vyos.vyos.vyos_snmp_server: +    state: gathered  # Module Execution:  #   "gathered": { @@ -974,10 +969,10 @@ EXAMPLES = """  # set service snmp v3 user vyos privacy type 'aes'  # set service snmp v3 view default oid 1 -  - name: parse configs -    vyos.vyos.vyos_snmp_server: -      running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}" -      state: parsed +- name: Parse SNMP server config +  vyos.vyos.vyos_snmp_server: +    running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}" +    state: parsed  # Module Execution:  # "parsed": { diff --git a/plugins/modules/vyos_static_routes.py b/plugins/modules/vyos_static_routes.py index 07615998..df9c501e 100644 --- a/plugins/modules/vyos_static_routes.py +++ b/plugins/modules/vyos_static_routes.py @@ -28,6 +28,7 @@ The module file for vyos_static_routes  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -143,25 +144,26 @@ EXAMPLES = """  - name: Merge the provided configuration with the existing running configuration    vyos.vyos.vyos_static_routes:      config: -    - address_families: -      - afi: ipv4 -        routes: -        - dest: 192.0.2.32/28 -          blackhole_config: -            type: blackhole -          next_hops: -          - forward_router_address: 192.0.2.6 -          - forward_router_address: 192.0.2.7 -    - address_families: -      - afi: ipv6 -        routes: -        - dest: 2001:db8:1000::/36 -          blackhole_config: -            distance: 2 -          next_hops: -          - forward_router_address: 2001:db8:2000:2::1 -          - forward_router_address: 2001:db8:2000:2::2 +      - address_families: +          - afi: ipv4 +            routes: +              - dest: 192.0.2.32/28 +                blackhole_config: +                  type: blackhole +                next_hops: +                  - forward_router_address: 192.0.2.6 +                  - forward_router_address: 192.0.2.7 +      - address_families: +          - afi: ipv6 +            routes: +              - dest: '2001:db8:1000::/36' +                blackhole_config: +                  distance: 2 +                next_hops: +                  - forward_router_address: '2001:db8:2000:2::1' +                  - forward_router_address: '2001:db8:2000:2::2'      state: merged +  #  #  # ------------------------- @@ -257,16 +259,16 @@ EXAMPLES = """  - name: Replace device configurations of listed static routes with provided configurations    vyos.vyos.vyos_static_routes:      config: -    - address_families: -      - afi: ipv4 -        routes: -        - dest: 192.0.2.32/28 -          blackhole_config: -            distance: 2 -          next_hops: -          - forward_router_address: 192.0.2.7 -            enabled: false -          - forward_router_address: 192.0.2.9 +      - address_families: +          - afi: ipv4 +            routes: +              - dest: 192.0.2.32/28 +                blackhole_config: +                  distance: 2 +                next_hops: +                  - forward_router_address: 192.0.2.7 +                    enabled: false +                  - forward_router_address: 192.0.2.9      state: replaced  #  # @@ -433,12 +435,12 @@ EXAMPLES = """  - name: Overrides all device configuration with provided configuration    vyos.vyos.vyos_static_routes:      config: -    - address_families: -      - afi: ipv4 -        routes: -        - dest: 198.0.2.48/28 -          next_hops: -          - forward_router_address: 192.0.2.18 +      - address_families: +          - afi: ipv4 +            routes: +              - dest: 198.0.2.48/28 +                next_hops: +                  - forward_router_address: 192.0.2.18      state: overridden  #  # @@ -543,9 +545,9 @@ EXAMPLES = """  - name: Delete static route based on afi.    vyos.vyos.vyos_static_routes:      config: -    - address_families: -      - afi: ipv4 -      - afi: ipv6 +      - address_families: +          - afi: ipv4 +          - afi: ipv6      state: deleted  #  # @@ -694,24 +696,24 @@ EXAMPLES = """  - name: Render the commands for provided  configuration    vyos.vyos.vyos_static_routes:      config: -    - address_families: -      - afi: ipv4 -        routes: -        - dest: 192.0.2.32/28 -          blackhole_config: -            type: blackhole -          next_hops: -          - forward_router_address: 192.0.2.6 -          - forward_router_address: 192.0.2.7 -    - address_families: -      - afi: ipv6 -        routes: -        - dest: 2001:db8:1000::/36 -          blackhole_config: -            distance: 2 -          next_hops: -          - forward_router_address: 2001:db8:2000:2::1 -          - forward_router_address: 2001:db8:2000:2::2 +      - address_families: +          - afi: ipv4 +            routes: +              - dest: 192.0.2.32/28 +                blackhole_config: +                  type: blackhole +                next_hops: +                  - forward_router_address: 192.0.2.6 +                  - forward_router_address: 192.0.2.7 +      - address_families: +          - afi: ipv6 +            routes: +              - dest: 2001:db8:1000::/36 +                blackhole_config: +                  distance: 2 +                next_hops: +                  - forward_router_address: 2001:db8:2000:2::1 +                  - forward_router_address: 2001:db8:2000:2::2      state: rendered  #  # @@ -871,8 +873,6 @@ EXAMPLES = """  # set protocols static route6 2001:db8:1000::/36 blackhole distance '2'  # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'  # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' - -  """  RETURN = """  before: diff --git a/plugins/modules/vyos_system.py b/plugins/modules/vyos_system.py index 66a3fd4e..96a0e9bc 100644 --- a/plugins/modules/vyos_system.py +++ b/plugins/modules/vyos_system.py @@ -18,6 +18,7 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -90,8 +91,8 @@ EXAMPLES = """  - name: configure domain search suffixes    vyos.vyos.vyos_system:      domain_search: -    - sub1.example.com -    - sub2.example.com +      - sub1.example.com +      - sub2.example.com  """  from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_user.py b/plugins/modules/vyos_user.py index 5494df3f..53c45c20 100644 --- a/plugins/modules/vyos_user.py +++ b/plugins/modules/vyos_user.py @@ -2,6 +2,7 @@  # -*- coding: utf-8 -*-  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  # (c) 2017, Ansible by Red Hat, inc @@ -154,12 +155,12 @@ EXAMPLES = """      state: present  - name: remove all users except admin    vyos.vyos.vyos_user: -    purge: yes +    purge: true  - name: set multiple users to level operator    vyos.vyos.vyos_user:      aggregate: -    - name: netop -    - name: netend +      - name: netop +      - name: netend      level: operator      state: present  - name: Change Password for User netop @@ -181,6 +182,7 @@ commands:  """  import re +  from copy import deepcopy  from functools import partial diff --git a/plugins/modules/vyos_vlan.py b/plugins/modules/vyos_vlan.py index f3e3dc88..49cc1258 100644 --- a/plugins/modules/vyos_vlan.py +++ b/plugins/modules/vyos_vlan.py @@ -6,6 +6,7 @@  from __future__ import absolute_import, division, print_function +  __metaclass__ = type @@ -122,8 +123,8 @@ EXAMPLES = """    vyos.vyos.vyos_vlan:      vlan_id: 100      interfaces: -    - eth1 -    - eth2 +      - eth1 +      - eth2  - name: Configure virtual interface address    vyos.vyos.vyos_vlan: @@ -136,14 +137,14 @@ EXAMPLES = """      vlan_id: 100      interfaces: eth0      associated_interfaces: -    - eth0 +      - eth0  - name: vlan intent check    vyos.vyos.vyos_vlan:      vlan_id: 100      associated_interfaces: -    - eth3 -    - eth4 +      - eth3 +      - eth4  - name: Delete vlan    vyos.vyos.vyos_vlan: @@ -164,6 +165,7 @@ commands:  """  import re  import time +  from copy import deepcopy  from ansible.module_utils._text import to_text @@ -224,7 +226,7 @@ def map_obj_to_commands(updates, module):              if not obj_in_want:                  for i in h["interfaces"]:                      commands.append( -                        "delete interfaces ethernet {0} vif {1}".format(i, h["vlan_id"]) +                        "delete interfaces ethernet {0} vif {1}".format(i, h["vlan_id"]),                      )      return commands @@ -260,7 +262,7 @@ def map_params_to_obj(module):                  "state": module.params["state"],                  "interfaces": module.params["interfaces"],                  "associated_interfaces": module.params["associated_interfaces"], -            } +            },          )      return obj @@ -325,7 +327,7 @@ def check_declarative_intent_params(want, module, result):          for i in w["associated_interfaces"]:              if (set(obj_interface) - set(w["associated_interfaces"])) != set([]):                  module.fail_json( -                    msg="Interface {0} not configured on vlan {1}".format(i, w["vlan_id"]) +                    msg="Interface {0} not configured on vlan {1}".format(i, w["vlan_id"]),                  ) diff --git a/plugins/terminal/vyos.py b/plugins/terminal/vyos.py index d5d57e7f..cbe98939 100644 --- a/plugins/terminal/vyos.py +++ b/plugins/terminal/vyos.py @@ -18,6 +18,7 @@  #  from __future__ import absolute_import, division, print_function +  __metaclass__ = type  import os @@ -61,7 +62,7 @@ class TerminalModule(TerminalBase):      except ValueError:          raise AnsibleConnectionFailure(              "Invalid value set for vyos terminal length '%s', value should be a valid integer string" -            % terminal_length +            % terminal_length,          )      def on_open_shell(self): | 
