diff --git a/changelogs/fragments/no_log_mask.yaml b/changelogs/fragments/no_log_mask.yaml new file mode 100644 index 0000000..65e3edf --- /dev/null +++ b/changelogs/fragments/no_log_mask.yaml @@ -0,0 +1,3 @@ +--- +security_fixes: + - Mask values of sensitive keys in module result. diff --git a/docs/vyos.vyos.vyos_bgp_address_family_module.rst b/docs/vyos.vyos.vyos_bgp_address_family_module.rst new file mode 100644 index 0000000..6ba0dc2 --- /dev/null +++ b/docs/vyos.vyos.vyos_bgp_address_family_module.rst @@ -0,0 +1,2085 @@ +.. _vyos.vyos.vyos_bgp_address_family_module: + + +********************************* +vyos.vyos.vyos_bgp_address_family +********************************* + +**BGP Address Family Resource Module.** + + +Version added: 2.1.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages BGP address family configuration of interfaces on devices running VYOS. + + + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ config + +
+ dictionary +
+
+ +
A dict of BGP global configuration for interfaces.
+
+
+ address_family + +
+ list + / elements=dictionary +
+
+ +
BGP address-family parameters.
+
+
+ afi + +
+ string +
+
+
    Choices: +
  • ipv4
  • +
  • ipv6
  • +
+
+
BGP address family settings.
+
+
+ aggregate_address + +
+ list + / elements=dictionary +
+
+ +
BGP aggregate network.
+
+
+ as_set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Generate AS-set path information for this aggregate address.
+
+
+ prefix + +
+ string +
+
+ +
BGP aggregate network.
+
+
+ summary_only + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Announce the aggregate summary network only.
+
+
+ networks + +
+ list + / elements=dictionary +
+
+ +
BGP network
+
+
+ backdoor + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Network as a backdoor route.
+
+
+ path_limit + +
+ integer +
+
+ +
AS path hop count limit
+
+
+ prefix + +
+ string +
+
+ +
BGP network address
+
+
+ route_map + +
+ string +
+
+ +
Route-map to modify route attributes
+
+
+ redistribute + +
+ list + / elements=dictionary +
+
+ +
Redistribute routes from other protocols into BGP
+
+
+ metric + +
+ integer +
+
+ +
Metric for redistributed routes.
+
+
+ protocol + +
+ string +
+
+
    Choices: +
  • connected
  • +
  • kernel
  • +
  • ospf
  • +
  • ospfv3
  • +
  • rip
  • +
  • ripng
  • +
  • static
  • +
+
+
types of routes to be redistributed.
+
+
+ route_map + +
+ string +
+
+ +
Route map to filter redistributed routes
+
+
+ table + +
+ string +
+
+ +
Redistribute non-main Kernel Routing Table.
+
+
+ as_number + +
+ integer +
+
+ +
AS number.
+
+
+ neighbors + +
+ list + / elements=dictionary +
+
+ +
BGP neighbor
+
+
+ address_family + +
+ list + / elements=dictionary +
+
+ +
address family.
+
+
+ afi + +
+ string +
+
+
    Choices: +
  • ipv4
  • +
  • ipv6
  • +
+
+
BGP neighbor parameters.
+
+
+ allowas_in + +
+ integer +
+
+ +
Number of occurrences of AS number.
+
+
+ as_override + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
AS for routes sent to this neighbor to be the local AS.
+
+
+ attribute_unchanged + +
+ dictionary +
+
+ +
BGP attributes are sent unchanged.
+
+
+ as_path + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
as_path attribute
+
+
+ med + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
med attribute
+
+
+ next_hop + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
next_hop attribute
+
+
+ capability + +
+ dictionary +
+
+ +
Advertise capabilities to this neighbor.
+
+
+ dynamic + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Advertise dynamic capability to this neighbor.
+
+
+ orf + +
+ string +
+
+
    Choices: +
  • send
  • +
  • receive
  • +
+
+
Advertise ORF capability to this neighbor.
+
+
+ default_originate + +
+ string +
+
+ +
Send default route to this neighbor
+
+
+ distribute_list + +
+ list + / elements=dictionary +
+
+ +
Access-list to filter route updates to/from this neighbor.
+
+
+ acl + +
+ integer +
+
+ +
Acess-list number.
+
+
+ action + +
+ string +
+
+
    Choices: +
  • export
  • +
  • import
  • +
+
+
Access-list to filter outgoing/incoming route updates to this neighbor
+
+
+ filter_list + +
+ list + / elements=dictionary +
+
+ +
As-path-list to filter route updates to/from this neighbor.
+
+
+ action + +
+ string +
+
+
    Choices: +
  • export
  • +
  • import
  • +
+
+
filter outgoing/incoming route updates
+
+
+ path_list + +
+ string +
+
+ +
As-path-list to filter
+
+
+ maximum_prefix + +
+ integer +
+
+ +
Maximum number of prefixes to accept from this neighbor nexthop-self Nexthop for routes sent to this neighbor to be the local router.
+
+
+ nexthop_local + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Nexthop attributes.
+
+
+ nexthop_self + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Nexthop for routes sent to this neighbor to be the local router.
+
+
+ peer_group + +
+ string +
+
+ +
IPv4 peer group for this peer
+
+
+ prefix_list + +
+ list + / elements=dictionary +
+
+ +
Prefix-list to filter route updates to/from this neighbor.
+
+
+ action + +
+ string +
+
+
    Choices: +
  • export
  • +
  • import
  • +
+
+
filter outgoing/incoming route updates
+
+
+ prefix_list + +
+ string +
+
+ +
Prefix-list to filter
+
+
+ remove_private_as + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Remove private AS numbers from AS path in outbound route updates
+
+
+ route_map + +
+ list + / elements=dictionary +
+
+ +
Route-map to filter route updates to/from this neighbor.
+
+
+ action + +
+ string +
+
+
    Choices: +
  • export
  • +
  • import
  • +
+
+
filter outgoing/incoming route updates
+
+
+ route_map + +
+ string +
+
+ +
route-map to filter
+
+
+ route_reflector_client + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Neighbor as a route reflector client
+
+
+ route_server_client + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Neighbor is route server client
+
+
+ soft_reconfiguration + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Soft reconfiguration for neighbor
+
+
+ unsupress_map + +
+ string +
+
+ +
Route-map to selectively unsuppress suppressed routes
+
+
+ weight + +
+ integer +
+
+ +
Default weight for routes from this neighbor
+
+
+ neighbor_address + +
+ string +
+
+ +
BGP neighbor address (v4/v6).
+
+
+ running_config + +
+ string +
+
+ +
This option is used only with state parsed.
+
The value of this option should be the output received from the IOS device by executing the command show configuration command | match bgp.
+
The state parsed reads the configuration from 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 parsed key within the result.
+
+
+ state + +
+ string +
+
+
    Choices: +
  • merged ←
  • +
  • replaced
  • +
  • deleted
  • +
  • gathered
  • +
  • parsed
  • +
  • rendered
  • +
  • purged
  • +
  • overridden
  • +
+
+
The state the configuration should be left in.
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml + + # Using merged + # Before state + # 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 + + # 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 allowas-in number '4' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast default-originate route-map 'map01' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast distribute-list export '10' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast nexthop-self + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map export 'map01' + # 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' + # vyos@vyos:~$ + # + # Module Execution: + # + # "after": { + # "address_family": [ + # { + # "afi": "ipv4", + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "maximum_prefix": 45, + # "nexthop_self": true, + # "route_map": [ + # { + # "action": "export", + # "route_map": "map01" + # }, + # { + # "action": "import", + # "route_map": "map01" + # } + # ], + # "weight": 50 + # } + # ], + # "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": [ + # { + # "acl": 10, + # "action": "export" + # } + # ] + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + # }, + # "before": {}, + # "changed": true, + # "commands": [ + # "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 allowas-in number 4", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast default-originate route-map map01", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast distribute-list export 10", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast maximum-prefix 45", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast nexthop-self", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map export map01", + # "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" + # ], + # + + # Using replaced: + + # Before 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 allowas-in number '4' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast default-originate route-map 'map01' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast distribute-list export '10' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast nexthop-self + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map export 'map01' + # 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' + # 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 + + # 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 + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast nexthop-self + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast allowas-in number '4' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast as-override + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast attribute-unchanged med + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast default-originate route-map 'map01' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list export '10' + # vyos@vyos:~$ + # + # + # # Module Execution: + # "after": { + # "address_family": [ + # { + # "afi": "ipv4", + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "allowas_in": 4, + # "as_override": true, + # "attribute_unchanged": { + # "med": true + # } + # }, + # { + # "afi": "ipv6", + # "default_originate": "map01", + # "distribute_list": [ + # { + # "acl": 10, + # "action": "export" + # } + # ] + # } + # ], + # "neighbor_address": "100.11.34.12" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4" + # }, + # { + # "afi": "ipv6", + # "maximum_prefix": 45, + # "nexthop_self": true + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + # }, + # "before": { + # "address_family": [ + # { + # "afi": "ipv4", + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "maximum_prefix": 45, + # "nexthop_self": true, + # "route_map": [ + # { + # "action": "export", + # "route_map": "map01" + # }, + # { + # "action": "import", + # "route_map": "map01" + # } + # ], + # "weight": 50 + # } + # ], + # "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": [ + # { + # "acl": 10, + # "action": "export" + # } + # ] + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + # }, + # "changed": true, + # "commands": [ + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast distribute-list", + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast default-originate", + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged", + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override", + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast allowas-in", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast nexthop-self", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast maximum-prefix", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast allowas-in number 4", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast as-override", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast attribute-unchanged med", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast default-originate route-map map01", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list export 10", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast maximum-prefix 45", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast nexthop-self" + # ], + + + # Using overridden + # vyos@vyos:~$ show configuration commands | match "set protocols bgp" + # set protocols bgp 100 address-family ipv4-unicast network 35.1.1.0/24 backdoor + # set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50' + # set protocols bgp 100 address-family ipv6-unicast aggregate-address 6601:1:1:1::/64 summary-only + # set protocols bgp 100 address-family ipv6-unicast network 5001:1:1:1::/64 route-map 'map01' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast nexthop-self + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast allowas-in number '4' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast as-override + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast attribute-unchanged med + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast default-originate route-map 'map01' + # 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 + + # Aft=validate-moduleser 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 + # set protocols bgp 100 address-family ipv6-unicast redistribute static metric '50' + # set protocols bgp 100 neighbor 20.33.1.1/24 + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast nexthop-self + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast route-map import 'map01' + # vyos@vyos:~$ + + + # Module Execution: + + # "after": { + # "address_family": [ + # { + # "afi": "ipv4", + # "aggregate_address": [ + # { + # "prefix": "60.9.2.0/24", + # "summary_only": true + # } + # ] + # }, + # { + # "afi": "ipv6", + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4" + # }, + # { + # "afi": "ipv6", + # "maximum_prefix": 45, + # "nexthop_self": true, + # "route_map": [ + # { + # "action": "import", + # "route_map": "map01" + # } + # ] + # } + # ], + # "neighbor_address": "100.11.34.12" + # } + # ] + # }, + # "before": { + # "address_family": [ + # { + # "afi": "ipv4", + # "networks": [ + # { + # "backdoor": true, + # "prefix": "35.1.1.0/24" + # } + # ], + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "aggregate_address": [ + # { + # "prefix": "6601:1:1:1::/64", + # "summary_only": true + # } + # ], + # "networks": [ + # { + # "prefix": "5001:1:1:1::/64", + # "route_map": "map01" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "allowas_in": 4, + # "as_override": true, + # "attribute_unchanged": { + # "med": true + # } + # }, + # { + # "afi": "ipv6", + # "default_originate": "map01", + # "distribute_list": [ + # { + # "acl": 10, + # "action": "export" + # } + # ] + # } + # ], + # "neighbor_address": "100.11.34.12" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4" + # }, + # { + # "afi": "ipv6", + # "maximum_prefix": 45, + # "nexthop_self": true + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + # }, + # "changed": true, + # "commands": [ + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast default-originate", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast attribute-unchanged", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast as-override", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast allowas-in", + # "delete protocols bgp 100 address-family ipv6 aggregate-address", + # "delete protocols bgp 100 address-family ipv6 network", + # "delete protocols bgp 100 address-family ipv4 network", + # "delete protocols bgp 100 address-family ipv4 redistribute", + # "set protocols bgp 100 address-family ipv4-unicast aggregate-address 60.9.2.0/24 summary-only", + # "set protocols bgp 100 address-family ipv6-unicast redistribute static metric 50", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast maximum-prefix 45", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast nexthop-self", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast route-map import map01" + # ], + # + + # Using deleted: + + # Before 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 + # set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50' + # set protocols bgp 100 address-family ipv6-unicast redistribute static metric '50' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast allowas-in number '4' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast default-originate route-map 'map01' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast distribute-list export '10' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast nexthop-self + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map export 'map01' + # 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' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast maximum-prefix '45' + # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast nexthop-self + # 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 + + + # After State: + + # vyos@vyos:~$ show configuration commands | match "set protocols bgp" + # set protocols bgp 100 address-family ipv6-unicast redistribute static metric '50' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast allowas-in number '4' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override + # 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 + # vyos@vyos:~$ + # + # + # Module Execution: + # + # "after": { + # "address_family": [ + # { + # "afi": "ipv6", + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "allowas_in": 4, + # "as_override": true, + # "attribute_unchanged": { + # "med": true + # } + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + # }, + # "before": { + # "address_family": [ + # { + # "afi": "ipv4", + # "aggregate_address": [ + # { + # "prefix": "60.9.2.0/24", + # "summary_only": true + # } + # ], + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "maximum_prefix": 45, + # "nexthop_self": true, + # "route_map": [ + # { + # "action": "export", + # "route_map": "map01" + # }, + # { + # "action": "import", + # "route_map": "map01" + # } + # ], + # "weight": 50 + # }, + # { + # "afi": "ipv6", + # "maximum_prefix": 45, + # "nexthop_self": true, + # "route_map": [ + # { + # "action": "import", + # "route_map": "map01" + # } + # ] + # } + # ], + # "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": [ + # { + # "acl": 10, + # "action": "export" + # } + # ] + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + # }, + # "changed": true, + # "commands": [ + # "delete protocols bgp 100 address-family ipv4-unicast", + # "delete protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast", + # "delete protocols bgp 100 neighbor 100.11.34.12 address-family" + # ], + # + + # using parsed: + + # parsed.cfg + # set protocols bgp 65536 address-family ipv4-unicast aggregate-address 192.0.2.0/24 as-set + # set protocols bgp 65536 address-family ipv4-unicast network 192.1.13.0/24 route-map 'map01' + # set protocols bgp 65536 address-family ipv4-unicast network 192.2.13.0/24 backdoor + # set protocols bgp 65536 address-family ipv6-unicast redistribute ripng metric '20' + # set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv4-unicast route-map export 'map01' + # set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv4-unicast soft-reconfiguration inbound + # 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 + + # Module Execution: + # "parsed": { + # "address_family": [ + # { + # "afi": "ipv4", + # "aggregate_address": [ + # { + # "as_set": true, + # "prefix": "192.0.2.0/24" + # } + # ], + # "networks": [ + # { + # "prefix": "192.1.13.0/24", + # "route_map": "map01" + # }, + # { + # "backdoor": true, + # "prefix": "192.2.13.0/24" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "redistribute": [ + # { + # "metric": 20, + # "protocol": "ripng" + # } + # ] + # } + # ], + # "as_number": 65536, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "route_map": [ + # { + # "action": "export", + # "route_map": "map01" + # } + # ], + # "soft_reconfiguration": true + # } + # ], + # "neighbor_address": "192.0.2.25" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv6", + # "attribute_unchanged": { + # "next_hop": true + # } + # } + # ], + # "neighbor_address": "203.0.113.5" + # } + # ] + # + + # Using gathered: + + # Native config: + + # vyos@vyos:~$ show configuration commands | match "set protocols bgp" + # set protocols bgp 100 address-family ipv4-unicast network 35.1.1.0/24 backdoor + # set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50' + # set protocols bgp 100 address-family ipv6-unicast aggregate-address 6601:1:1:1::/64 summary-only + # set protocols bgp 100 address-family ipv6-unicast network 5001:1:1:1::/64 route-map 'map01' + # set protocols bgp 100 address-family ipv6-unicast redistribute static metric '50' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast allowas-in number '4' + # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override + # 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: + + # "gathered": { + # "address_family": [ + # { + # "afi": "ipv4", + # "networks": [ + # { + # "backdoor": true, + # "prefix": "35.1.1.0/24" + # } + # ], + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "aggregate_address": [ + # { + # "prefix": "6601:1:1:1::/64", + # "summary_only": true + # } + # ], + # "networks": [ + # { + # "prefix": "5001:1:1:1::/64", + # "route_map": "map01" + # } + # ], + # "redistribute": [ + # { + # "metric": 50, + # "protocol": "static" + # } + # ] + # } + # ], + # "as_number": 100, + # "neighbors": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "allowas_in": 4, + # "as_override": true, + # "attribute_unchanged": { + # "med": true + # } + # } + # ], + # "neighbor_address": "20.33.1.1/24" + # } + # ] + + # 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 + + # Module Execution: + + # "rendered": [ + # "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 allowas-in number 4", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast as-override", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast default-originate route-map map01", + # "set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv6-unicast distribute-list export 10", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast maximum-prefix 45", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast nexthop-self", + # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map export map01", + # "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" + # ] + + + + +Status +------ + + +Authors +~~~~~~~ + +- Gomathi Selvi Srinivasan (@GomathiselviS) diff --git a/galaxy.yml b/galaxy.yml index 00426bf..3eb12ba 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,15 +1,15 @@ --- authors: - Ansible Network Community (ansible-network) dependencies: - "ansible.netcommon": ">=2.0.0" + "ansible.netcommon": ">=2.0.1" license_file: LICENSE name: vyos description: Ansible Network Collection for VYOS devices. namespace: vyos readme: README.md repository: https://github.com/ansible-collections/vyos.vyos tags: [vyos, networking] # NOTE(pabelanger): We create an empty version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. version: null 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 4192a84..da56aa9 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 @@ -1,290 +1,290 @@ # -*- coding: utf-8 -*- # Copyright 2021 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ############################################# # WARNING # ############################################# # # This file is auto generated by the resource # module builder playbook. # # Do not edit this file manually. # # Changes to this file will be over written # by the resource module builder. # # Changes should be made in the model used to # generate this file or in the resource module # builder template. # ############################################# """ The arg spec for the vyos_bgp_global module """ class Bgp_globalArgs(object): # pylint: disable=R0903 """The arg spec for the vyos_bgp_global module""" def __init__(self, **kwargs): pass argument_spec = { "running_config": {"type": "str"}, "state": { "default": "merged", "type": "str", "choices": [ "merged", "replaced", "deleted", "gathered", "parsed", "rendered", "purged", ], }, "config": { "type": "dict", "options": { "redistribute": { "elements": "dict", "type": "list", "options": { "route_map": {"type": "str"}, "metric": {"type": "int"}, "protocol": { "type": "str", "choices": [ "connected", "kernel", "ospf", "rip", "static", ], }, }, }, "network": { "elements": "dict", "type": "list", "options": { "backdoor": {"type": "bool"}, "route_map": {"type": "str"}, "address": {"type": "str"}, }, }, "maximum_paths": { "type": "list", "elements": "dict", "options": { "path": {"type": "str"}, "count": {"type": "int"}, }, }, "aggregate_address": { "elements": "dict", "type": "list", "options": { "summary_only": {"type": "bool"}, "as_set": {"type": "bool"}, "prefix": {"type": "str"}, }, }, "timers": { "type": "dict", "options": { "holdtime": {"type": "int"}, "keepalive": {"type": "int"}, }, }, "neighbor": { "type": "list", "elements": "dict", "options": { "shutdown": {"type": "bool"}, "weight": {"type": "int"}, "default_originate": {"type": "str"}, "peer_group_name": {"type": "str"}, "route_reflector_client": {"type": "bool"}, "strict_capability_match": {"type": "bool"}, "remove_private_as": {"type": "bool"}, "as_override": {"type": "bool"}, "port": {"type": "int"}, "soft_reconfiguration": {"type": "bool"}, "nexthop_self": {"type": "bool"}, "remote_as": {"type": "int"}, "ebgp_multihop": {"type": "int"}, "route_map": { "elements": "dict", "type": "list", "options": { "action": { "type": "str", "choices": ["export", "import"], }, "route_map": {"type": "str"}, }, }, "distribute_list": { "elements": "dict", "type": "list", "options": { "action": { "type": "str", "choices": ["export", "import"], }, "acl": {"type": "int"}, }, }, "allowas_in": {"type": "int"}, "passive": {"type": "bool"}, "ttl_security": {"type": "int"}, "peer_group": {"type": "bool"}, "maximum_prefix": {"type": "int"}, "prefix_list": { "elements": "dict", "type": "list", "options": { "action": { "type": "str", "choices": ["export", "import"], }, "prefix_list": {"type": "str"}, }, }, "update_source": {"type": "str"}, "description": {"type": "str"}, "local_as": {"type": "int"}, "route_server_client": {"type": "bool"}, "attribute_unchanged": { "type": "dict", "options": { "as_path": {"type": "bool"}, "med": {"type": "bool"}, "next_hop": {"type": "bool"}, }, }, "disable_connected_check": {"type": "bool"}, "address": {"type": "str"}, - "password": {"type": "str"}, + "password": {"type": "str", "no_log": True}, "disable_send_community": { "type": "str", "choices": ["extended", "standard"], }, "unsuppress_map": {"type": "str"}, "override_capability": {"type": "bool"}, "filter_list": { "elements": "dict", "type": "list", "options": { "action": { "type": "str", "choices": ["export", "import"], }, "path_list": {"type": "str"}, }, }, "capability": { "type": "dict", "options": { "orf": { "type": "str", "choices": ["send", "receive"], }, "dynamic": {"type": "bool"}, }, }, "timers": { "type": "dict", "options": { "holdtime": {"type": "int"}, "connect": {"type": "int"}, "keepalive": {"type": "int"}, }, }, "disable_capability_negotiation": {"type": "bool"}, "advertisement_interval": {"type": "int"}, }, }, "bgp_params": { "type": "dict", "options": { "router_id": {"type": "str"}, "distance": { "elements": "dict", "type": "list", "options": { "prefix": {"type": "int"}, "type": { "type": "str", "choices": [ "external", "internal", "local", ], }, "value": {"type": "int"}, }, }, "dampening": { "type": "dict", "options": { "half_life": {"type": "int"}, "start_suppress_time": {"type": "int"}, "max_suppress_time": {"type": "int"}, "re_use": {"type": "int"}, }, }, "graceful_restart": {"type": "int"}, "scan_time": {"type": "int"}, "always_compare_med": {"type": "bool"}, "no_fast_external_failover": {"type": "bool"}, "bestpath": { "type": "dict", "options": { "med": { "type": "str", "choices": ["confed", "missing-as-worst"], }, "as_path": { "type": "str", "choices": ["confed", "ignore"], }, "compare_routerid": {"type": "bool"}, }, }, "enforce_first_as": {"type": "bool"}, "default": { "type": "dict", "options": { "local_pref": {"type": "int"}, "no_ipv4_unicast": {"type": "bool"}, }, }, "cluster_id": {"type": "str"}, "no_client_to_client_reflection": {"type": "bool"}, "deterministic_med": {"type": "bool"}, "log_neighbor_changes": {"type": "bool"}, "disable_network_import_check": {"type": "bool"}, "confederation": { "type": "list", "elements": "dict", "options": { "peers": {"type": "int"}, "identifier": {"type": "int"}, }, }, }, }, "as_number": {"type": "int"}, }, }, } # pylint: disable=C0301 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 e7dd10c..71ba63b 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 @@ -1,97 +1,103 @@ # -*- coding: utf-8 -*- # Copyright 2020 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ############################################# # WARNING # ############################################# # # This file is auto generated by the resource # module builder playbook. # # Do not edit this file manually. # # Changes to this file will be over written # by the resource module builder. # # Changes should be made in the model used to # generate this file or in the resource module # builder template. # ############################################# """ The arg spec for the vyos_ospf_interfaces module """ class Ospf_interfacesArgs(object): # pylint: disable=R0903 """The arg spec for the vyos_ospf_interfaces module""" def __init__(self, **kwargs): pass argument_spec = { "running_config": {}, "state": { "default": "merged", "type": "str", "choices": [ "merged", "replaced", "overridden", "deleted", "gathered", "parsed", "rendered", ], }, "config": { "elements": "dict", "type": "list", "options": { "name": {"type": "str"}, "address_family": { "elements": "dict", "type": "list", "options": { "passive": {"type": "bool"}, "retransmit_interval": {"type": "int"}, "cost": {"type": "int"}, "afi": { "required": True, "type": "str", "choices": ["ipv4", "ipv6"], }, "authentication": { "type": "dict", "options": { - "plaintext_password": {"type": "str"}, + "plaintext_password": { + "type": "str", + "no_log": True, + }, "md5_key": { "type": "dict", + "no_log": False, "options": { - "key_id": {"type": "int"}, - "key": {"type": "str"}, + "key_id": { + "type": "int", + }, + "key": {"type": "str", "no_log": True}, }, }, }, }, "mtu_ignore": {"type": "bool"}, "priority": {"type": "int"}, "instance": {"type": "str"}, "bandwidth": {"type": "int"}, "dead_interval": {"type": "int"}, "ifmtu": {"type": "int"}, "hello_interval": {"type": "int"}, "transmit_delay": {"type": "int"}, "network": {"type": "str"}, }, }, }, }, } # pylint: disable=C0301 diff --git a/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py index b8e915c..0061e79 100644 --- a/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py @@ -1,275 +1,281 @@ # # -*- coding: utf-8 -*- # Copyright 2019 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ############################################# # WARNING # ############################################# # # This file is auto generated by the resource # module builder playbook. # # Do not edit this file manually. # # Changes to this file will be over written # by the resource module builder. # # Changes should be made in the model used to # generate this file or in the resource module # builder template. # ############################################# """ The arg spec for the vyos_ospfv2 module """ class Ospfv2Args(object): # pylint: disable=R0903 """The arg spec for the vyos_ospfv2 module""" def __init__(self, **kwargs): pass argument_spec = { "config": { "options": { "auto_cost": { "options": {"reference_bandwidth": {"type": "int"}}, "type": "dict", }, "default_information": { "options": { "originate": { "options": { "always": {"type": "bool"}, "metric": {"type": "int"}, "metric_type": {"type": "int"}, "route_map": {"type": "str"}, }, "type": "dict", } }, "type": "dict", }, "default_metric": {"type": "int"}, "distance": { "options": { "global": {"type": "int"}, "ospf": { "options": { "external": {"type": "int"}, "inter_area": {"type": "int"}, "intra_area": {"type": "int"}, }, "type": "dict", }, }, "type": "dict", }, "log_adjacency_changes": { "choices": ["detail"], "type": "str", }, "max_metric": { "options": { "router_lsa": { "options": { "administrative": {"type": "bool"}, "on_shutdown": {"type": "int"}, "on_startup": {"type": "int"}, }, "type": "dict", } }, "type": "dict", }, "mpls_te": { "options": { "enabled": {"type": "bool"}, "router_address": {"type": "str"}, }, "type": "dict", }, "neighbor": { "elements": "dict", "options": { "neighbor_id": {"type": "str"}, "poll_interval": {"type": "int"}, "priority": {"type": "int"}, }, "type": "list", }, "areas": { "elements": "dict", "options": { "area_id": {"type": "str"}, "area_type": { "options": { "normal": {"type": "bool"}, "nssa": { "options": { "default_cost": {"type": "int"}, "no_summary": {"type": "bool"}, "set": {"type": "bool"}, "translate": { "choices": [ "always", "candidate", "never", ], "type": "str", }, }, "type": "dict", }, "stub": { "options": { "default_cost": {"type": "int"}, "no_summary": {"type": "bool"}, "set": {"type": "bool"}, }, "type": "dict", }, }, "type": "dict", }, "authentication": { "choices": ["plaintext-password", "md5"], "type": "str", }, "network": { "elements": "dict", "options": { "address": {"required": True, "type": "str"} }, "type": "list", }, "range": { "elements": "dict", "options": { "address": {"type": "str"}, "cost": {"type": "int"}, "not_advertise": {"type": "bool"}, "substitute": {"type": "str"}, }, "type": "list", }, "shortcut": { "choices": ["default", "disable", "enable"], "type": "str", }, "virtual_link": { "elements": "dict", "options": { "address": {"type": "str"}, "authentication": { "options": { "md5": { "elements": "dict", "options": { "key_id": {"type": "int"}, - "md5_key": {"type": "str"}, + "md5_key": { + "type": "str", + "no_log": True, + }, }, "type": "list", }, - "plaintext_password": {"type": "str"}, + "plaintext_password": { + "type": "str", + "no_log": True, + }, }, "type": "dict", }, "dead_interval": {"type": "int"}, "hello_interval": {"type": "int"}, "retransmit_interval": {"type": "int"}, "transmit_delay": {"type": "int"}, }, "type": "list", }, }, "type": "list", }, "parameters": { "options": { "abr_type": { "choices": [ "cisco", "ibm", "shortcut", "standard", ], "type": "str", }, "opaque_lsa": {"type": "bool"}, "rfc1583_compatibility": {"type": "bool"}, "router_id": {"type": "str"}, }, "type": "dict", }, "passive_interface": {"type": "list", "elements": "str"}, "passive_interface_exclude": { "type": "list", "elements": "str", }, "redistribute": { "elements": "dict", "options": { "metric": {"type": "int"}, "metric_type": {"type": "int"}, "route_map": {"type": "str"}, "route_type": { "choices": [ "bgp", "connected", "kernel", "rip", "static", ], "type": "str", }, }, "type": "list", }, "route_map": {"type": "list", "elements": "str"}, "timers": { "options": { "refresh": { "options": {"timers": {"type": "int"}}, "type": "dict", }, "throttle": { "options": { "spf": { "options": { "delay": {"type": "int"}, "initial_holdtime": {"type": "int"}, "max_holdtime": {"type": "int"}, }, "type": "dict", } }, "type": "dict", }, }, "type": "dict", }, }, "type": "dict", }, "running_config": {"type": "str"}, "state": { "choices": [ "merged", "replaced", "deleted", "parsed", "gathered", "rendered", ], "default": "merged", "type": "str", }, } # pylint: disable=C0301 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 3cfa83c..1efd877 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 @@ -1,88 +1,92 @@ # -*- coding: utf-8 -*- # Copyright 2021 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type """ The vyos bgp_global fact class It is in this file the configuration is collected from the device for a given resource, parsed, and the facts tree is populated based on the configuration. """ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( utils, ) from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.rm_templates.bgp_global import ( Bgp_globalTemplate, ) from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.bgp_global.bgp_global import ( Bgp_globalArgs, ) import re class Bgp_globalFacts(object): """The vyos bgp_global facts class""" def __init__(self, module, subspec="config", options="options"): self._module = module self.argument_spec = Bgp_globalArgs.argument_spec def get_device_data(self, connection): return connection.get( 'show configuration commands | match "set protocols bgp"' ) def populate_facts(self, connection, ansible_facts, data=None): """Populate the facts for Bgp_global network resource :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ facts = {} objs = {} config_lines = [] if not data: data = self.get_device_data(connection) for resource in data.splitlines(): if "address-family" not in resource: config_lines.append(re.sub("'", "", resource)) - bgp_global_parser = Bgp_globalTemplate(lines=config_lines) + bgp_global_parser = Bgp_globalTemplate( + lines=config_lines, module=self._module + ) objs = bgp_global_parser.parse() if "neighbor" in objs: objs["neighbor"] = list(objs["neighbor"].values()) objs["neighbor"] = sorted( objs["neighbor"], key=lambda k: k["address"] ) if "network" in objs: objs["network"] = sorted( objs["network"], key=lambda k: k["address"] ) if "aggregate_address" in objs: objs["aggregate_address"] = sorted( objs["aggregate_address"], key=lambda k: k["prefix"] ) ansible_facts["ansible_network_resources"].pop("bgp_global", None) params = utils.remove_empties( - utils.validate_config(self.argument_spec, {"config": objs}) + bgp_global_parser.validate_config( + self.argument_spec, {"config": objs}, redact=True + ) ) facts["bgp_global"] = params.get("config", []) ansible_facts["ansible_network_resources"].update(facts) return ansible_facts 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 15ac92a..7ef05cb 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 @@ -1,101 +1,106 @@ # -*- coding: utf-8 -*- # Copyright 2020 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type """ The vyos ospf_interfaces fact class It is in this file the configuration is collected from the device for a given resource, parsed, and the facts tree is populated based on the configuration. """ import re from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( utils, ) from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.rm_templates.ospf_interfaces import ( Ospf_interfacesTemplate, ) from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospf_interfaces.ospf_interfaces import ( Ospf_interfacesArgs, ) class Ospf_interfacesFacts(object): """The vyos ospf_interfaces facts class""" def __init__(self, module, subspec="config", options="options"): self._module = module self.argument_spec = Ospf_interfacesArgs.argument_spec def get_device_data(self, connection): return connection.get( 'show configuration commands | match "set interfaces"' ) def get_config_set(self, data): """ To classify the configurations beased on interface """ interface_list = [] config_set = [] int_string = "" for config_line in data.splitlines(): ospf_int = re.search(r"set interfaces \S+ (\S+) .*", config_line) if ospf_int: if ospf_int.group(1) not in interface_list: if int_string: config_set.append(int_string) interface_list.append(ospf_int.group(1)) int_string = "" int_string = int_string + config_line + "\n" if int_string: config_set.append(int_string) return config_set def populate_facts(self, connection, ansible_facts, data=None): """Populate the facts for Ospf_interfaces network resource :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ facts = {} objs = [] + ospf_interfaces_parser = Ospf_interfacesTemplate( + lines=[], module=self._module + ) if not data: data = self.get_device_data(connection) # parse native config using the Ospf_interfaces template ospf_interfaces_facts = [] resources = self.get_config_set(data) for resource in resources: ospf_interfaces_parser = Ospf_interfacesTemplate( - lines=resource.split("\n") + lines=resource.split("\n"), module=self._module ) objs = ospf_interfaces_parser.parse() for key, sortv in [("address_family", "afi")]: if key in objs and objs[key]: objs[key] = list(objs[key].values()) ospf_interfaces_facts.append(objs) ansible_facts["ansible_network_resources"].pop("ospf_interfaces", None) facts = {"ospf_interfaces": []} params = utils.remove_empties( - utils.validate_config( - self.argument_spec, {"config": ospf_interfaces_facts} + ospf_interfaces_parser.validate_config( + self.argument_spec, + {"config": ospf_interfaces_facts}, + redact=True, ) ) if params.get("config"): for cfg in params["config"]: facts["ospf_interfaces"].append(utils.remove_empties(cfg)) ansible_facts["ansible_network_resources"].update(facts) return ansible_facts 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 55e2200..ae953e4 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 @@ -1,1421 +1,1421 @@ # -*- coding: utf-8 -*- # Copyright 2021 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type """ The Bgp_address_family parser templates file. This contains a list of parser definitions and associated functions that facilitates both facts gathering and native command generation for the given network resource. """ import re from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) def _tmplt_bgp_af_aggregate_address(config_data): afi = config_data["address_family"]["afi"] + "-unicast" command = "protocols bgp {as_number} address-family ".format(**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"] ) if config_data["aggregate_address"].get("summary_only"): command += afi + " aggregate-address {prefix} summary-only".format( **config_data["aggregate_address"] ) return command def _tmplt_bgp_af_redistribute_metric(config_data): if config_data["address_family"]["redistribute"].get("metric"): afi = config_data["address_family"]["afi"] + "-unicast" 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"] ) return command def _tmplt_bgp_af_redistribute_route_map(config_data): if config_data["address_family"]["redistribute"].get("route_map"): afi = config_data["address_family"]["afi"] + "-unicast" 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"] ) ) return command def _tmplt_bgp_af_redistribute_table(config_data): if config_data["address_family"]["redistribute"].get("table"): afi = config_data["address_family"]["afi"] + "-unicast" 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"] ) return command def _tmplt_bgp_af_delete_redistribute(config_data): afi = config_data["address_family"]["afi"] + "-unicast" command = "protocols bgp {as_number} address-family ".format(**config_data) config_data = config_data["address_family"] command += afi + " redistribute {protocol}".format( **config_data["redistribute"] ) return command def _tmplt_bgp_af_neighbor_distribute_list(config_data): command = [] afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" cmd = "protocols bgp {as_number} neighbor ".format(**config_data) cmd += "{neighbor_address} address-family ".format( **config_data["neighbors"] ) 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"]) ) return command def _tmplt_bgp_af_neighbor_route_map(config_data): command = [] afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" cmd = "protocols bgp {as_number} neighbor ".format(**config_data) cmd += "{neighbor_address} address-family ".format( **config_data["neighbors"] ) 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"]) ) return command def _tmplt_bgp_af_neighbor_prefix_list(config_data): command = [] afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" cmd = "protocols bgp {as_number} neighbor ".format(**config_data) cmd += "{neighbor_address} address-family ".format( **config_data["neighbors"] ) 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"]) ) return command def _tmplt_bgp_af_neighbor_filter_list(config_data): command = [] afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" cmd = "protocols bgp {as_number} neighbor ".format(**config_data) cmd += "{neighbor_address} address-family ".format( **config_data["neighbors"] ) 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"]) ) return command def _tmplt_bgp_af_neighbor_attribute(config_data): command = [] afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" cmd = "protocols bgp {as_number} neighbor ".format(**config_data) cmd += "{neighbor_address} address-family ".format( **config_data["neighbors"] ) config_data = config_data["neighbors"]["address_family"] for k in config_data["attribute_unchanged"].keys(): if config_data["attribute_unchanged"][k]: k = re.sub("_", "-", k) c = cmd + afi + " attribute-unchanged " + k command.append(c) return command def _tmplt_bgp_af_neighbor_delete(config_data): afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" command = "protocols bgp {as_number} ".format(**config_data) command += ( "neighbor {neighbor_address} address-family ".format( **config_data["neighbors"] ) + afi ) config_data = config_data["neighbors"]["address_family"] if config_data.get("allowas_in"): command += " allowas-in" elif config_data.get("as_override"): command += " as-override" elif config_data.get("attribute_unchanged"): command += " attribute-unchanged" elif config_data.get("capability"): command += " capability" elif config_data.get("default_originate"): command += " default-originate" elif config_data.get("maximum_prefix"): command += " maximum-prefix" elif config_data.get("nexthop_local"): command += " nexthop-local" elif config_data.get("nexthop_self"): command += " nexthop-self" elif config_data.get("peer_group"): command += " peer-group" elif config_data.get("remote_private_as"): command += " remote-private-as" elif config_data.get("route_reflector_client"): command += " route-reflector-client" elif config_data.get("route_server_client"): command += " route-server-client" elif config_data.get("soft_reconfiguration"): command += " soft-reconfiguration" elif config_data.get("unsuppress_map"): command += " unsuppress-map" elif config_data.get("weight"): command += " weight" elif config_data.get("filter_list"): command += " filter-list" elif config_data.get("prefix_list"): command += " prefix-list" elif config_data.get("distribute_list"): command += " distribute-list" elif config_data.get("route_map"): command += " route-map" return command def _tmplt_bgp_af_neighbor(config_data): afi = config_data["neighbors"]["address_family"]["afi"] + "-unicast" command = "protocols bgp {as_number} ".format(**config_data) command += ( "neighbor {neighbor_address} address-family ".format( **config_data["neighbors"] ) + afi ) config_data = config_data["neighbors"]["address_family"] if config_data.get("allowas_in"): command += " allowas-in number {allowas_in}".format(**config_data) elif config_data.get("as_override"): command += " as-override" elif config_data.get("capability"): command += " capability " if config_data["capability"].get("dynamic"): command += "dynamic" elif config_data["capability"].get("orf"): command += " prefix-list {orf}".format(**config_data["capability"]) elif config_data.get("default_originate"): command += " default-originate route-map {default_originate}".format( **config_data ) elif config_data.get("maximum_prefix"): command += " maximum-prefix {maximum_prefix}".format(**config_data) elif config_data.get("nexthop_local"): command += " nexthop-local" elif config_data.get("nexthop_self"): command += " nexthop-self" elif config_data.get("peer_group"): command += " peer-group {peer_group}".format(**config_data) elif config_data.get("remote_private_as"): command += " remote-private-as" elif config_data.get("route_reflector_client"): command += " route-reflector-client" elif config_data.get("route_server_client"): command += " route-server-client" elif config_data.get("soft_reconfiguration"): command += " soft-reconfiguration inbound" elif config_data.get("unsuppress_map"): command += " unsuppress-map {unsuppress_map}".format(**config_data) elif config_data.get("weight"): command += " weight {weight}".format(**config_data) return command class Bgp_address_familyTemplate(NetworkTemplate): - def __init__(self, lines=None): + def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Bgp_address_familyTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix + lines=lines, tmplt=self, prefix=prefix, module=module ) # fmt: off PARSERS = [ { "name": "address_family", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast", "compval": "as_number", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", } } } }, { "name": "aggregate_address", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+aggregate-address \s+(?P
\S+) \s*(?Pas-set)* \s*(?Psummary-only)* $""", re.VERBOSE, ), "setval": _tmplt_bgp_af_aggregate_address, "remval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast aggregate-address" + " {{ address_family.aggregate_address.prefix }}", "compval": "address_family.aggregate_address", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "aggregate_address": [ { "prefix": "{{ address }}", "as_set": "{{ True if as_set is defined }}", "summary_only": "{{ True if summary_only is defined }}" } ] } } } }, { "name": "network.backdoor", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+network \s+(?P
\S+) \s+backdoor *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast network {{ address_family.networks.prefix }} backdoor", "remval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast network {{ address_family.networks.prefix }}", "compval": "address_family.networks.backdoor", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "networks": [ { "prefix": "{{ address }}", "backdoor": "{{ True }}" } ] } } } }, { "name": "network.path_limit", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+network \s+(?P
\S+) \s+path-limit \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast network" + "{{ address_family.networks.prefix }} path-limit {{ address_family.networks.path_limit }}", "remval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast network {{ address_family.networks.address }}", "compval": "address_family.networks.path_limit", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "networks": [ { "prefix": "{{ address }}", "path_limit": "{{ limit|int }}" } ] } } } }, { "name": "network.route_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+network \s+(?P
\S+) \s+route-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast network" + " {{ address_family.networks.prefix }} route-map {{ address_family.networks.route_map }}", "remval": "protocols bgp {{ as_number }} address-family {{ address_family.afi }}-unicast network {{ address_family.networks.prefix }}", "compval": "address_family.networks.route_map", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "networks": [ { "prefix": "{{ address }}", "route_map": "{{ map }}" } ] } } } }, { "name": "redistribute.metric", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+redistribute \s+(?P\S+) \s+metric \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_redistribute_metric, "remval": _tmplt_bgp_af_delete_redistribute, "compval": "address_family.redistribute.metric", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "redistribute": [ { "protocol": "{{ proto }}", "metric": "{{ val|int }}" } ] } } } }, { "name": "redistribute.route_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+redistribute \s+(?P\S+) \s+route-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_redistribute_route_map, "remval": _tmplt_bgp_af_delete_redistribute, "compval": "address_family.redistribute.route_map", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "redistribute": [ { "protocol": "{{ proto }}", "route_map": "{{ map }}" } ] } } } }, { "name": "redistribute.table", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+address-family \s+(?P\S+)-unicast \s+redistribute \s+table \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_redistribute_table, "remval": _tmplt_bgp_af_delete_redistribute, "compval": "address_family.redistribute.table", "result": { "as_number": "{{ as_num }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "redistribute": [ { "table": "{{ tab }}" } ] } } } }, { "name": "neighbors", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbors.neighbor_address }} address-family", "compval": "neighbors", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", } } } }, { "name": "neighbors.address_family", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbors.neighbor_address }} address-family {{ neighbors.address_family.afi }}-unicast", "compval": "neighbors", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", } } } } } }, { "name": "neighbors.allowas_in", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+allowas-in \s+number \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.allowas_in", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "allowas_in": "{{ num }}" } } } } } }, { "name": "neighbors.as_override", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+as-override *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.as_override", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "as_override": "{{ True }}" } } } } } }, { "name": "neighbors.attribute_unchanged.as_path", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+attribute-unchanged \s+(?Pas-path) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_attribute, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.attribute_unchanged.as_path", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "attribute_unchanged": { "as_path": "{{ True }}" } } } } } } }, { "name": "neighbors.attribute_unchanged.med", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+attribute-unchanged \s+(?Pmed) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_attribute, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.attribute_unchanged.med", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "attribute_unchanged": { "med": "{{ True }}" } } } } } } }, { "name": "neighbors.attribute_unchanged.next_hop", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+attribute-unchanged \s+(?Pnext-hop) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_attribute, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.attribute_unchanged.next_hop", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "attribute_unchanged": { "next_hop": "{{ True }}" } } } } } } }, { "name": "neighbors.capability_dynamic", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+capability \s+dynamic *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.capability.dynamic", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "capability": { "dynamic": "{{ true }}" } } } } } } }, { "name": "neighbors.capability_orf", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+capability \s+prefix-list \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.capability.orf", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "capability": { "orf": "{{ orf }}" } } } } } } }, { "name": "neighbors.default_originate", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+default-originate \s+route-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.default_originate", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "default_originate": "{{ map }}" } } } } } }, { "name": "neighbors.distribute_list", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+distribute-list \s+(?Pexport|import) \s+(?P\d+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_distribute_list, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.distribute_list", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "distribute_list": [ { "action": "{{ action }}", "acl": "{{ list }}" } ] } } } } } }, { "name": "neighbors.prefix_list", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+prefix-list \s+(?Pexport|import) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_prefix_list, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.prefix_list", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "prefix_list": [ { "action": "{{ action }}", "prefix_list": "{{ list }}" } ] } } } } } }, { "name": "neighbors.filter_list", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+filter-list \s+(?Pexport|import) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_filter_list, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.filter_list", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "filter_list": [ { "action": "{{ action }}", "path_list": "{{ list }}" } ] } } } } } }, { "name": "neighbors.maximum_prefix", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+maximum-prefix \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.maximum_prefix", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "maximum_prefix": "{{ num }}" } } } } } }, { "name": "neighbors.nexthop_local", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+nexthop-local *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.nexthop_local", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "nexthop_local": "{{ True }}" } } } } } }, { "name": "neighbors.nexthop_self", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+nexthop-self *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.nexthop_self", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "nexthop_self": "{{ True }}" } } } } } }, { "name": "neighbors.peer_group", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+peer-group \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.peer_group", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "peer_group": "{{ name }}" } } } } } }, { "name": "neighbors.remove_private_as", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+remove-private-as *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.remove_private_as", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "remove_private_as": "{{ True }}" } } } } } }, { "name": "neighbors.route_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+route-map \s+(?Pexport|import) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor_route_map, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.route_map", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "route_map": [ { "action": "{{ action }}", "route_map": "{{ map }}" } ] } } } } } }, { "name": "neighbors.route_reflector_client", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+route-reflector-client *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.route_reflector_client", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "route_reflector_client": "{{ True }}" } } } } } }, { "name": "neighbors.route_server_client", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+route-server-client *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.route_server_client", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "route_server_client": "{{ True }}" } } } } } }, { "name": "neighbors.soft_reconfiguration", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+soft-reconfiguration \s+inbound *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.soft_reconfiguration", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "soft_reconfiguration": "{{ True }}" } } } } } }, { "name": "neighbors.unsuppress_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+unsuppress-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.unsuppress_map", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "unsuppress_map": "{{ map }}" } } } } } }, { "name": "neighbors.weight", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+address-family \s+(?P\S+)-unicast \s+weight \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_af_neighbor, "remval": _tmplt_bgp_af_neighbor_delete, "compval": "neighbors.address_family.weight", "result": { "as_number": "{{ as_num }}", "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", "address_family": { "{{ afi }}": { "afi": "{{ afi }}", "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 aff6258..cb9907b 100644 --- a/plugins/module_utils/network/vyos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/bgp_global.py @@ -1,2043 +1,2043 @@ # -*- coding: utf-8 -*- # Copyright 2021 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type """ The Bgp_global parser templates file. This contains a list of parser definitions and associated functions that facilitates both facts gathering and native command generation for the given network resource. """ import re from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) def _tmplt_bgp_params_confederation(config_data): command = [] for list_el in config_data["bgp_params"]["confederation"]: for k, v in iteritems(list_el): command.append( "protocols bgp {as_number} parameters confederation ".format( **config_data ) + k + " " + str(v) ) return command def _tmplt_bgp_maximum_paths(config_data): command = [] for list_el in config_data["maximum_paths"]: command.append( "protocols bgp {as_number} maximum-paths ".format(**config_data) + list_el["path"] + " " + str(list_el["count"]) ) return command def _tmplt_bgp_aggregate_address(config_data): command = "protocols bgp {as_number} aggregate-address".format( **config_data ) if config_data["aggregate_address"].get("as_set"): command += " {prefix} as-set".format( **config_data["aggregate_address"] ) if config_data["aggregate_address"].get("summary_only"): command += " {prefix} summary-only".format( **config_data["aggregate_address"] ) return command def _tmplt_delete_bgp_maximum_paths(config_data): command = "protocols bgp {as_number} maximum-paths".format(**config_data) return command def _tmplt_bgp_params_default(config_data): command = "protocols bgp {as_number} parameters default".format( **config_data ) if config_data["bgp_params"]["default"].get("no_ipv4_unicast"): command += " no-ipv4-unicast" if config_data["bgp_params"]["default"].get("local_pref"): command += " local-pref {local_pref}".format( **config_data["bgp_params"]["default"] ) return command def _tmplt_bgp_delete_redistribute(config_data): command = ( "protocols bgp {as_number} redistribute ".format(**config_data) + config_data["redistribute"]["protocol"] ) return command def _tmplt_bgp_neighbor_timers(config_data): command = [] for k, v in iteritems(config_data["neighbor"]["timers"]): command.append( "protocols bgp {as_number} neighbor ".format(**config_data) + config_data["neighbor"]["address"] + " timers " + k + " " + str(v) ) return command 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) ) return command def _tmplt_bgp_neighbor_attribute_unchanged_as_path(config_data): command = "protocols bgp {as_number} ".format( **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 ) + "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 ) + "neighbor {address} attribute-unchanged next-hop".format( **config_data["neighbor"] ) return command def _tmplt_bgp_neighbor_distribute_list(config_data): command = [] for list_el in config_data["neighbor"]["distribute_list"]: command.append( "protocols bgp {as_number} ".format(**config_data) + "neighbor {address} distribute-list ".format( **config_data["neighbor"] ) + list_el["action"] + " " + str(list_el["acl"]) ) return command def _tmplt_bgp_neighbor_route_map(config_data): command = [] for list_el in config_data["neighbor"]["route_map"]: command.append( "protocols bgp {as_number} ".format(**config_data) + "neighbor {address} route-map ".format(**config_data["neighbor"]) + list_el["action"] + " " + str(list_el["route_map"]) ) return command def _tmplt_bgp_neighbor_prefix_list(config_data): command = [] for list_el in config_data["neighbor"]["prefix_list"]: command.append( "protocols bgp {as_number} ".format(**config_data) + "neighbor {address} prefix-list ".format( **config_data["neighbor"] ) + list_el["action"] + " " + str(list_el["prefix_list"]) ) return command def _tmplt_bgp_neighbor_filter_list(config_data): command = [] for list_el in config_data["neighbor"]["filter_list"]: command.append( "protocols bgp {as_number} ".format(**config_data) + "neighbor {address} filter-list ".format( **config_data["neighbor"] ) + list_el["action"] + " " + str(list_el["path_list"]) ) return command def _tmplt_bgp_params_distance(config_data): command = ( "protocols bgp {as_number} parameters distance global ".format( **config_data ) + config_data["bgp_params"]["distance"]["type"] + " " + str(config_data["bgp_params"]["distance"]["value"]) ) return command class Bgp_globalTemplate(NetworkTemplate): - def __init__(self, lines=None): + def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Bgp_globalTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix + lines=lines, tmplt=self, prefix=prefix, module=module ) # fmt: off PARSERS = [ { "name": "router", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }}", "compval": "as_number", "result": { "as_number": "{{ as_num }}", } }, { "name": "aggregate_address", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+aggregate-address \s+(?P
\S+) \s*(?Pas-set)* \s*(?Psummary-only)* $""", re.VERBOSE, ), "setval": _tmplt_bgp_aggregate_address, "remval": "protocols bgp {{ as_number }} aggregate-address {{ aggregate_address.prefix }}", "compval": "aggregate_address", "result": { "as_number": "{{ as_num }}", "aggregate_address": [ { "prefix": "{{ address }}", "as_set": "{{ True if as_set is defined }}", "summary_only": "{{ True if summary_only is defined }}" } ] } }, { "name": "maximum_paths", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+maximum-paths \s+(?Pebgp|ibgp) \s+(?P\d+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_maximum_paths, "remval": _tmplt_delete_bgp_maximum_paths, "compval": "maximum_paths", "result": { "as_number": "{{ as_num }}", "maximum_paths": [ { "path": "{{ path }}", "count": "{{ count }}", } ] } }, { "name": "neighbor.advertisement_interval", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+advertisement-interval \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} advertisement-interval {{ neighbor.advertisement_interval }}", "remval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} advertisement-interval", "compval": "neighbor.advertisement_interval", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "advertisement_interval": "{{ interval }}" } } } }, { "name": "neighbor.allowas_in", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+allowas-in \s+number \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} allowas-in number {{ neighbor.allowas_in }}", "compval": "neighbor.allowas_in", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "allowas_in": "{{ count }}" } } } }, { "name": "neighbor.as_override", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+as-override *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} as-override", "compval": "neighbor.as_override", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "as_override": "{{ True }}" } } } }, { "name": "neighbor.attribute_unchanged.as_path", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+attribute-unchanged \s+(?Pas-path) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_attribute_unchanged_as_path, "compval": "neighbor.attribute_unchanged", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "attribute_unchanged": { "{{ 'as_path' }}": "{{ True }}" } } } } }, { "name": "neighbor.attribute_unchanged.med", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+attribute-unchanged \s+(?Pmed) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_attribute_unchanged_med, "compval": "neighbor.attribute_unchanged", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "attribute_unchanged": { "{{ 'med' }}": "{{ True }}" } } } } }, { "name": "neighbor.attribute_unchanged.next_hop", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+attribute-unchanged \s+(?Pnext-hop) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_attribute_unchanged_next_hop, "compval": "neighbor.attribute_unchanged", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "attribute_unchanged": { "{{ 'next_hop' }}": "{{ True }}" } } } } }, { "name": "neighbor.capability_dynamic", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+capability \s+(?Pdynamic) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} capability dynamic", "compval": "neighbor.capability.dynamic", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "capability": { "dynamic": "{{ True if dynamic is defined}}" } } } } }, { "name": "neighbor.capability_orf", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+capability \s+orf \s+prefix-list \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} capability orf prefix-list {{ neighbor.capability.orf }}", "compval": "neighbor.capability.orf", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "capability": { "orf": "{{ orf }}" } } } } }, { "name": "neighbor.default_originate", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+default-originate \s+route-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} default-originate route-map {{ neighbor.default_originate }}", "compval": "neighbor.advertisement_interval", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "default_originate": "{{ map }}" } } } }, { "name": "neighbor.description", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+description \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} description {{ neighbor.description }}", "compval": "neighbor.description", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "description": "{{ desc }}" } } } }, { "name": "neighbor.disable_capability_negotiation", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+disable-capability-negotiation *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} disable-capability-negotiation", "compval": "neighbor.disable_capability_negotiation", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "disable_capability_negotiation": "{{ True }}" } } } }, { "name": "neighbor.disable_connected_check", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+disable-connected-check *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} disable-connected-check", "compval": "neighbor.disable_connected_check", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "disable_connected_check": "{{ True }}" } } } }, { "name": "neighbor.disable_send_community", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+disable-send-community \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} disable-send-community {{ neighbor.disable_send_community }}", "compval": "neighbor.disable_send_community", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "disable_send_community": "{{ comm }}" } } } }, { "name": "neighbor.distribute_list", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+distribute-list \s+(?Pexport|import) \s+(?P\d+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_distribute_list, "compval": "neighbor.distribute_list", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "distribute_list": [ { "action": "{{ action }}", "acl": "{{ list }}" } ] } } } }, { "name": "neighbor.ebgp_multihop", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+ebgp-multihop \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} ebgp-multihop {{ neighbor.ebgp_multihop }}", "compval": "neighbor.ebgp_multihop", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "ebgp_multihop": "{{ hop|int }}" } } } }, { "name": "neighbor.filter_list", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+filter-list \s+(?Pexport|import) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_filter_list, "compval": "neighbor.filter_list", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "filter_list": [ { "action": "{{ action }}", "path_list": "{{ list }}" } ] } } } }, { "name": "neighbor.local_as", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+local-as \s+(?P\S+) \s+no-prepend *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} local-as {{ neighbor.local_as }} no-prepend", "compval": "neighbor.local_as", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "local_as": "{{ as }}" } } } }, { "name": "neighbor.maximum_prefix", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+maximum-prefix \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} maximum-prefix {{ neighbor.maximum_prefix }}", "compval": "neighbor.maximum_prefix", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "maximum_prefix": "{{ num }}" } } } }, { "name": "neighbor.nexthop_self", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+nexthop-self *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} nexthop-self", "compval": "neighbor.nexthop_self", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "nexthop_self": "{{ True }}" } } } }, { "name": "neighbor.override_capability", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+override-capability *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} override-capability", "compval": "neighbor.override_capability", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "override_capability": "{{ True }}" } } } }, { "name": "neighbor.passive", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+passive *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} nexthop-self", "compval": "neighbor.passive", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "passive": "{{ True }}" } } } }, { "name": "neighbor.password", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+password \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} password {{ neighbor.address }}", "compval": "neighbor.password", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "password": "{{ pwd }}" } } } }, { "name": "neighbor.peer_group_name", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+peer-group \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} peer-group {{ neighbor.peer_group_name }}", "compval": "neighbor.peer_group_name", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "peer_group_name": "{{ name }}" } } } }, { "name": "neighbor.port", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+port \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} port {{ neighbor.port }}", "compval": "neighbor.port", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "port": "{{ num|int }}" } } } }, { "name": "neighbor.prefix_list", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+prefix-list \s+(?Pexport|import) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_prefix_list, "compval": "neighbor.prefix_list", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "prefix_list": [ { "action": "{{ action }}", "prefix_list": "{{ list }}" } ] } } } }, { "name": "neighbor.remote_as", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+remote-as \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} remote-as {{ neighbor.remote_as }}", "compval": "neighbor.remote_as", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "remote_as": "{{ num|int }}" } } } }, { "name": "neighbor.remove_private_as", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+remote-private-as *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} remote-private-as", "compval": "neighbor.remove_private_as", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "remove_private_as": "{{ True }}" } } } }, { "name": "neighbor.route_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+route-map \s+(?Pexport|import) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_route_map, "compval": "neighbor.route_map", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "route_map": [ { "action": "{{ action }}", "route_map": "{{ map }}" } ] } } } }, { "name": "neighbor.route_reflector_client", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+route-reflector-client *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} router-reflector-client", "compval": "neighbor.route_reflector_client", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "route_reflector_client": "{{ True }}" } } } }, { "name": "neighbor.route_server_client", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+route-server-client *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} route-server-client", "compval": "neighbor.route_server_client", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "route_server_client": "{{ True }}" } } } }, { "name": "neighbor.shutdown", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+shutdown *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} shutdown", "compval": "neighbor.shutdown", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "shutdown": "{{ True }}" } } } }, { "name": "neighbor.soft_reconfiguration", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+soft-reconfiguration \s+inbound *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} soft-reconfiguration", "compval": "neighbor.soft_reconfiguration", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "soft_reconfiguration": "{{ True }}" } } } }, { "name": "neighbor.strict_capability_match", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+strict-capability-match *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} strict-capability-match", "compval": "neighbor.strict_capability_match", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "strict_capability_match": "{{ True }}" } } } }, { "name": "neighbor.unsuppress_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+unsuppress-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} unsuppress-map {{ neighbor.unsuppress_map }}", "compval": "neighbor.unsuppress_map", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "unsuppress_map": "{{ map }}" } } } }, { "name": "neighbor.update_source", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+update-source \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} update-source {{ neighbor.update_source }}", "compval": "neighbor.update_source", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "update_source": "{{ src }}" } } } }, { "name": "neighbor.weight", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+weight \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} weight {{ neighbor.weight }}", "compval": "neighbor.weight", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "weight": "{{ num }}" } } } }, { "name": "neighbor.ttl_security", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+ttl-security \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} ttl-security {{ neighbor.ttl_security }}", "compval": "neighbor.ttl_security", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "ttl_security": "{{ ttl|int }}" } } } }, { "name": "neighbor.timers", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+neighbor \s+(?P
\S+) \s+timers \s+(?Pconnect|holdtime|keepalive) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_neighbor_timers, "remval": "protocols bgp {{ as_number }} neighbor {{ neighbor.address }} timers", "compval": "neighbor.timers", "result": { "as_number": "{{ as_num }}", "neighbor": { "{{ address }}": { "address": "{{ address }}", "timers": { "{{ type }}": "{{ sec }}" } } } } }, { "name": "network.backdoor", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+network \s+(?P
\S+) \s+backdoor *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} network {{ network.address }} backdoor", "remval": "protocols bgp {{ as_number }} network {{ network.address }}", "compval": "network.backdoor", "result": { "as_number": "{{ as_num }}", "network": [ { "address": "{{ address }}", "backdoor": "{{ True }}" } ] } }, { "name": "network.route_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+network \s+(?P
\S+) \s+route-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} network {{ network.address }} route-map {{ network.route_map }}", "remval": "protocols bgp {{ as_number }} network {{ network.address }}", "compval": "network.route_map", "result": { "as_number": "{{ as_num }}", "network": [ { "address": "{{ address }}", "route_map": "{{ map }}" } ] } }, { "name": "redistribute.metric", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+redistribute \s+(?P\S+) \s+metric \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} redistribute {{ redistribute.protocol }} metric {{ redistribute.metric }}", "remval": _tmplt_bgp_delete_redistribute, "compval": "redistribute", "result": { "as_number": "{{ as_num }}", "redistribute": [ { "protocol": "{{ proto }}", "metric": "{{ val|int }}" } ] } }, { "name": "redistribute.route_map", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+redistribute \s+(?P\S+) \s+route-map \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} redistribute {{ redistribute.protocol }} route-map {{ redistribute.route_map }}", "remval": _tmplt_bgp_delete_redistribute, "compval": "redistribute", "result": { "as_number": "{{ as_num }}", "redistribute": [ { "protocol": "{{ proto }}", "route_map": "{{ val }}" } ] } }, { "name": "timers", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+timers \s+(?P\S+) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_timers, "remval": "protocols bgp {{ as_number }} timers", "compval": "timers", "result": { "as_number": "{{ as_num }}", "timers": { "{{ type }}": "{{ val }}", } } }, { "name": "bgp_params.always_compare_med", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+always-compare-med *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters always-compare-med", "compval": "bgp_params.always_compare_med", "result": { "as_number": "{{ as_num }}", "bgp_params": { "always_compare_med": "{{ True }}", } } }, { "name": "bgp_params.bestpath.as_path", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+bestpath \s+as-path \s+(?Pconfed|ignore) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters bestpath as-path {{ bgp_params.bestpath.as_path }}", "compval": "bgp_params.bestpath.as_path", "result": { "as_number": "{{ as_num }}", "bgp_params": { "bestpath": { "as_path": "{{ path }}", } } } }, { "name": "bgp_params.bestpath.compare_routerid", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+bestpath \s+compare-routerid *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters bestpath compare-routerid", "compval": "bgp_params.bestpath.compare_routerid", "result": { "as_number": "{{ as_num }}", "bgp_params": { "bestpath": { "compare_routerid": "{{ True }}", } } } }, { "name": "bgp_params.bestpath.med", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+bestpath \s+med \s+(?Pconfed|missing-as-worst) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters bestpath med {{ bestpath.med }}", "compval": "bgp_params.bestpath.med", "result": { "as_number": "{{ as_num }}", "bgp_params": { "bestpath": { "med": "{{ path }}", } } } }, { "name": "bgp_params.cluster_id", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+cluster-id \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters cluster-id {{ bgp_params.cluster_id }}", "compval": "bgp_params.cluster_id", "result": { "as_number": "{{ as_num }}", "bgp_params": { "cluster_id": "{{ id }}", } } }, { "name": "bgp_params.confederation", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+confederation \s+(?Pidentifier|peers) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_params_confederation, "compval": "bgp_params.always_compare_med", "result": { "as_number": "{{ as_num }}", "bgp_params": { "confederation": [ { "peers": "{{ val if type == 'peers' }}", "identifier": "{{ val if type == 'identifier' }}" } ] } } }, { "name": "bgp_params.dampening_half_life", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+dampening \s+half-life \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters dampening half-life {{ bgp_params.dampening.half_life}}", "compval": "bgp_params.dampening.half_life", "result": { "as_number": "{{ as_num }}", "bgp_params": { "dampening": { "half_life": "{{ val }}" } } } }, { "name": "bgp_params.dampening_max_suppress_time", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+dampening \s+max-suppress-time \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters dampening max-suppress-time {{ bgp_params.dampening.max_suppress_time}}", "compval": "bgp_params.dampening.max_suppress_time", "result": { "as_number": "{{ as_num }}", "bgp_params": { "dampening": { "max_suppress_time": "{{ val }}" } } } }, { "name": "bgp_params.dampening_re_use", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+dampening \s+re-use \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters dampening re-use {{ bgp_params.dampening.re_use}}", "compval": "bgp_params.dampening.re_use", "result": { "as_number": "{{ as_num }}", "bgp_params": { "dampening": { "re_use": "{{ val }}" } } } }, { "name": "bgp_params.dampening_start_suppress_time", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+dampening \s+start-suppress-time \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters dampening start-suppress-time {{ bgp_params.dampening.start_suppress_time}}", "compval": "bgp_params.dampening.start_suppress_time", "result": { "as_number": "{{ as_num }}", "bgp_params": { "dampening": { "start_suppress_time": "{{ val }}" } } } }, { "name": "bgp_params.default", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+default \s*(?Pno-ipv4-unicast)* \s*(?Plocal-pref\s\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_params_default, "remval": "protocols bgp {{ as_number }} parameters default", "compval": "bgp_params.default", "result": { "as_number": "{{ as_num }}", "bgp_params": { "default": { "no_ipv4_unicast": "{{ True if no_ipv4_unicast is defined }}", "local_pref": "{{ local_pref.split(" " )[1] if local_pref is defined }}" } } } }, { "name": "bgp_params.deterministic_med", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+deterministic-med *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters deterministic-med", "compval": "bgp_params.deterministic_med", "result": { "as_number": "{{ as_num }}", "bgp_params": { "deterministic_med": "{{ True }}", } } }, { "name": "bgp_params.disbale_network_import_check", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+disable-network-import-check *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters disable-network-import-check", "compval": "bgp_params.disable_network_import_check", "result": { "as_number": "{{ as_num }}", "bgp_params": { "disable_network_import_check": "{{ True }}", } } }, { "name": "bgp_params.distance.prefix", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+distance\sprefix \s+(?P\S+) \s+distance \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters distance prefix {{ bgp_params.distance.prefix }} distance {{ bgp_params.distance.value }}", "compval": "bgp_params.distance.prefix", "remval": "protocols bgp {{ as_number }} parameters distance prefix", "result": { "as_number": "{{ as_num }}", "bgp_params": { "distance": [ { "prefix": "{{ prefix }}", "value": "{{ val }}" } ] } } }, { "name": "bgp_params.distance.global", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+distance\sglobal \s+(?P\S+) \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_bgp_params_distance, "remval": "protocols bgp {{ as_number }} parameters distance global", "compval": "bgp_params.distance", "result": { "as_number": "{{ as_num }}", "bgp_params": { "distance": [ { "type": "{{ type }}", "value": "{{ val }}" } ] } } }, { "name": "bgp_params.enforce_first_as", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+enforce-first-as *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters enforce-first-as", "compval": "bgp_params.enforce_first_as", "result": { "as_number": "{{ as_num }}", "bgp_params": { "enforce_first_as": "{{ True }}", } } }, { "name": "bgp_params.graceful_restart", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+graceful-restart\s+stalepath-time \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters graceful-restart stalepath-time {{ bgp_params.graceful_restart }}", "compval": "bgp_params.graceful_restart", "result": { "as_number": "{{ as_num }}", "bgp_params": { "graceful_restart": "{{ val }}", } } }, { "name": "bgp_params.log_neighbor_changes", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+log-neighbor-changes *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters log-neighbor-changes", "compval": "bgp_params.log_neighbor_changes", "result": { "as_number": "{{ as_num }}", "bgp_params": { "log_neighbor_changes": "{{ True }}", } } }, { "name": "bgp_params.no_client_to_client_reflection", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+no-client-to-client-reflection *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters no-client-to-client-reflection", "compval": "bgp_params.log_neighbor_changes", "result": { "as_number": "{{ as_num }}", "bgp_params": { "no_client_to_client_reflection": "{{ True }}", } } }, { "name": "bgp_params.no_fast_external_failover", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+no-fast-external-failover *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters no-fast-external-failover", "compval": "bgp_params.no_fast_external_failover", "result": { "as_number": "{{ as_num }}", "bgp_params": { "no_fast_external_failover": "{{ True }}", } } }, { "name": "bgp_params.routerid", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+router-id \s+(?P\S+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters router-id {{ bgp_params.router_id }}", "compval": "bgp_params.router_id", "result": { "as_number": "{{ as_num }}", "bgp_params": { "router_id": "{{ id }}", } } }, { "name": "bgp_params.scan_time", "getval": re.compile( r""" ^set \s+protocols \s+bgp \s+(?P\d+) \s+parameters \s+scan-time \s+(?P\d+) *$""", re.VERBOSE, ), "setval": "protocols bgp {{ as_number }} parameters scan-time {{ bgp_params.scan_time }}", "compval": "bgp_params.scan_time", "result": { "as_number": "{{ as_num }}", "bgp_params": { "scan_time": "{{ val }}", } } }, ] # 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 460e6b0..1e3afbe 100644 --- a/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py @@ -1,743 +1,743 @@ # -*- coding: utf-8 -*- # Copyright 2020 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type """ The Ospf_interfaces parser templates file. This contains a list of parser definitions and associated functions that facilitates both facts gathering and native command generation for the given network resource. """ import re from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( get_interface_type, ) def _get_parameters(data): if data["afi"] == "ipv6": val = ["ospfv3", "ipv6"] else: val = ["ospf", "ip"] return val def _tmplt_ospf_int_delete(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] ) return command def _tmplt_ospf_int_cost(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " cost {cost}".format(**config_data["address_family"]) ) return command def _tmplt_ospf_int_auth_password(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " authentication plaintext-password {plaintext_password}".format( **config_data["address_family"]["authentication"] ) ) return command def _tmplt_ospf_int_auth_md5(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " authentication md5 key-id {key_id} ".format( **config_data["address_family"]["authentication"]["md5_key"] ) + "md5-key {key}".format( **config_data["address_family"]["authentication"]["md5_key"] ) ) return command def _tmplt_ospf_int_auth_md5_delete(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " authentication" ) return command def _tmplt_ospf_int_bw(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " bandwidth {bandwidth}".format(**config_data["address_family"]) ) return command def _tmplt_ospf_int_hello_interval(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " hello-interval {hello_interval}".format( **config_data["address_family"] ) ) return command def _tmplt_ospf_int_dead_interval(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " dead-interval {dead_interval}".format( **config_data["address_family"] ) ) return command def _tmplt_ospf_int_mtu_ignore(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " mtu-ignore" ) return command def _tmplt_ospf_int_network(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " network {network}".format(**config_data["address_family"]) ) return command def _tmplt_ospf_int_priority(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " priority {priority}".format(**config_data["address_family"]) ) return command def _tmplt_ospf_int_retransmit_interval(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " retransmit-interval {retransmit_interval}".format( **config_data["address_family"] ) ) return command def _tmplt_ospf_int_transmit_delay(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " transmit-delay {transmit_delay}".format( **config_data["address_family"] ) ) return command def _tmplt_ospf_int_ifmtu(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " ifmtu {ifmtu}".format(**config_data["address_family"]) ) return command def _tmplt_ospf_int_instance(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " instance-id {instance}".format(**config_data["address_family"]) ) return command def _tmplt_ospf_int_passive(config_data): int_type = get_interface_type(config_data["name"]) params = _get_parameters(config_data["address_family"]) command = ( "interfaces " + int_type + " {name} ".format(**config_data) + params[1] + " " + params[0] + " passive" ) return command class Ospf_interfacesTemplate(NetworkTemplate): - def __init__(self, lines=None): + def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Ospf_interfacesTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix + lines=lines, tmplt=self, prefix=prefix, module=module ) # fmt: off PARSERS = [ { "name": "ip_ospf", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) *$""", re.VERBOSE, ), "remval": _tmplt_ospf_int_delete, "compval": "address_family", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', } } } }, { "name": "authentication_password", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+authentication \s+plaintext-password \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_auth_password, "compval": "address_family.authentication", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "authentication": { "plaintext_password": "{{ text }}" } } } } }, { "name": "authentication_md5", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+authentication \s+md5 \s+key-id \s+(?P\d+) \s+md5-key \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_auth_md5, "remval": _tmplt_ospf_int_auth_md5_delete, "compval": "address_family.authentication", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "authentication": { "md5_key": { "key_id": "{{ id }}", "key": "{{ text }}" } } } } } }, { "name": "bandwidth", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+bandwidth \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_bw, "compval": "address_family.bandwidth", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "bandwidth": "{{ bw }}" } } } }, { "name": "cost", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+cost \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_cost, "compval": "address_family.cost", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "cost": "{{ val }}" } } } }, { "name": "hello_interval", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+hello-interval \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_hello_interval, "compval": "address_family.hello_interval", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "hello_interval": "{{ val }}" } } } }, { "name": "dead_interval", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+dead-interval \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_dead_interval, "compval": "address_family.dead_interval", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "dead_interval": "{{ val }}" } } } }, { "name": "mtu_ignore", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+(?P\'mtu-ignore\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_mtu_ignore, "compval": "address_family.mtu_ignore", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "mtu_ignore": "{{ True if mtu is defined }}" } } } }, { "name": "network", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+network \s+(?P\S+) *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_network, "compval": "address_family.network", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "network": "{{ val }}" } } } }, { "name": "priority", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+priority \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_priority, "compval": "address_family.priority", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "priority": "{{ val }}" } } } }, { "name": "retransmit_interval", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+retransmit-interval \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_retransmit_interval, "compval": "address_family.retransmit_interval", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "retransmit_interval": "{{ val }}" } } } }, { "name": "transmit_delay", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+transmit-delay \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_transmit_delay, "compval": "address_family.transmit_delay", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "transmit_delay": "{{ val }}" } } } }, { "name": "ifmtu", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+ifmtu \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_ifmtu, "compval": "address_family.ifmtu", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "ifmtu": "{{ val }}" } } } }, { "name": "instance", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+instance-id \s+(?P\'\d+\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_instance, "compval": "address_family.instance", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "instance": "{{ val }}" } } } }, { "name": "passive", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) \s+(?Pip|ipv6) \s+(?Pospf|ospfv3) \s+(?P\'passive\') *$""", re.VERBOSE, ), "setval": _tmplt_ospf_int_passive, "compval": "address_family.passive", "result": { "name": "{{ name }}", "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "passive": "{{ True if pass is defined }}" } } } }, { "name": "interface_name", "getval": re.compile( r""" ^set \s+interfaces \s+(?P\S+) \s+(?P\S+) .*$""", re.VERBOSE, ), "setval": "set interface {{ type }} {{ name }}", "result": { "name": "{{ name }}", } }, ] # fmt: on diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml index a98d351..f585cbc 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml @@ -1,133 +1,133 @@ --- merged: commands: - set interfaces ethernet eth0 ip ospf cost 50 - set interfaces ethernet eth0 ip ospf priority 26 - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 - set interfaces bonding bond2 ip ospf transmit-delay 45 - set interfaces bonding bond2 ipv6 ospfv3 passive after: - address_family: - afi: "ipv4" transmit_delay: 45 - afi: "ipv6" passive: true name: "bond2" - address_family: - afi: "ipv4" cost: 50 priority: 26 - afi: "ipv6" instance: "33" mtu_ignore: true name: "eth0" replaced: commands: - set interfaces ethernet eth0 ip ospf transmit-delay 50 - set interfaces ethernet eth0 ip ospf network point-to-point - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39 - delete interfaces ethernet eth0 ip ospf cost 50 - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore - set interfaces bonding bond2 ip ospf bandwidth 70 - - set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345 + - set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key ******** after: - address_family: - afi: "ipv4" authentication: md5_key: key: "1111111111232345" key_id: 10 bandwidth: 70 transmit_delay: 45 - afi: "ipv6" passive: true name: "bond2" - address_family: - afi: "ipv4" network: "point-to-point" priority: 26 transmit_delay: 50 - afi: "ipv6" dead_interval: 39 name: "eth0" overridden: commands: - delete interfaces bonding bond2 ip ospf - delete interfaces bonding bond2 ipv6 ospfv3 - set interfaces ethernet eth0 ip ospf transmit-delay 50 - set interfaces ethernet eth0 ip ospf network point-to-point - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39 - delete interfaces ethernet eth0 ip ospf cost 50 - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore after: - address_family: - afi: "ipv4" network: "point-to-point" priority: 26 transmit_delay: 50 - afi: "ipv6" dead_interval: 39 name: "eth0" deleted: commands: - delete interfaces bonding bond2 ip ospf - delete interfaces bonding bond2 ipv6 ospfv3 after: - address_family: - afi: "ipv4" cost: 50 priority: 26 - afi: "ipv6" instance: "33" mtu_ignore: true name: "eth0" rendered: commands: - set interfaces ethernet eth1 firewall in name 'INBOUND' - set interfaces ethernet eth1 firewall out name 'OUTBOUND' - set interfaces ethernet eth1 firewall local name 'LOCAL' - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' - set interfaces ethernet eth2 firewall in name 'INBOUND' - set interfaces ethernet eth2 firewall out name 'OUTBOUND' - set interfaces ethernet eth2 firewall local name 'LOCAL' - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' round_trip: after: - name: eth0 - access_rules: - afi: ipv4 rules: - direction: in name: INBOUND - direction: local name: LOCAL - direction: out name: OUTBOUND - afi: ipv6 rules: - direction: local name: V6-LOCAL name: eth1 - name: eth2 access_rules: - afi: ipv4 rules: - direction: in name: INBOUND - direction: local name: LOCAL - direction: out name: OUTBOUND - afi: ipv6 rules: - direction: local name: V6-LOCAL diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index d9ecb5c..a44822b 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -1,6 +1,3 @@ plugins/action/vyos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py compile-2.6!skip plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py import-2.6!skip -plugins/modules/vyos_bgp_global.py validate-modules:no-log-needed # temporary workaround for no-log -plugins/modules/vyos_ospf_interfaces.py validate-modules:no-log-needed # temporary workaround for no-log -plugins/modules/vyos_ospfv2.py validate-modules:no-log-needed # temporary workaround for no-log diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index d9ecb5c..a44822b 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -1,6 +1,3 @@ plugins/action/vyos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py compile-2.6!skip plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py import-2.6!skip -plugins/modules/vyos_bgp_global.py validate-modules:no-log-needed # temporary workaround for no-log -plugins/modules/vyos_ospf_interfaces.py validate-modules:no-log-needed # temporary workaround for no-log -plugins/modules/vyos_ospfv2.py validate-modules:no-log-needed # temporary workaround for no-log