Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Dbarrosop/simplifications #68

Merged
merged 9 commits into from
Jul 1, 2017
2 changes: 1 addition & 1 deletion napalm_yang/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def resolve_rule(rule, attribute, keys, extra_vars=None, translation_model=None,
elif isinstance(rule, str):
if rule in ["unnecessary"]:
return [{"mode": "skip", "reason": rule}]
elif rule in ["not_implemented"]:
elif rule in ["not_implemented", "not_supported"]:
return [{"mode": "gate", "reason": rule}]
else:
raise Exception("Not sure what to do with rule {} on attribute {}".format(rule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ ipv4:
_process:
- mode: is_absent
regexp: "(?P<value>^\\W*switchport$)"
from: "{{ bookmarks['parent'] }}"
mtu:
_process: not_implemented
addresses:
_process: unnecessary
address:
_process:
- mode: block
regexp: "(?P<block>ip address (?P<key>(?P<ip>.*))\\/(?P<prefix>\\d+))(?P<secondary> secondary)*"
from: "{{ bookmarks['parent'] }}"
- regexp: "(?P<block>ip address (?P<key>(?P<ip>.*))\\/(?P<prefix>\\d+))(?P<secondary> secondary)*"
ip:
_process: unnecessary
config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ interfaces:
_process: unnecessary
interface:
_process:
- mode: block
regexp: "(?P<block>interface (?P<key>(\\w|-)*\\d+)\n(?:.|\n)*?^!$)"
from: "{{ bookmarks.interfaces.0 }}"
- regexp: "(?P<block>interface (?P<key>(\\w|-)*\\d+)\n(?:.|\n)*?^!$)"
from: interfaces.0
name:
_process: unnecessary
hold-time:
Expand All @@ -29,8 +28,7 @@ interfaces:
type:
_process:
- mode: map
regexp: "(?P<value>(\\w|-)*)\\d+"
from: "{{ interface_key }}"
regexp: "interface (?P<value>(\\w|-)*)\\d+"
map:
Ethernet: ethernetCsmacd
Management: ethernetCsmacd
Expand All @@ -41,24 +39,18 @@ interfaces:
_process:
- mode: is_present
regexp: "(?P<value>no shutdown)"
from: "{{ bookmarks.interface[interface_key] }}"
description:
_process:
- mode: search
regexp: "description (?P<value>.*)"
from: "{{ bookmarks.interface[interface_key] }}"
- regexp: "description (?P<value>.*)"
mtu:
_process:
- mode: search
regexp: "mtu (?P<value>[0-9]+)"
from: "{{ bookmarks.interface[interface_key] }}"
- regexp: "mtu (?P<value>[0-9]+)"
subinterfaces:
_process: unnecessary
subinterface:
_process:
- mode: block
regexp: "(?P<block>interface {{interface_key}}\\.(?P<key>\\d+)\\n(?:.|\\n)*?^!$)"
from: "{{ bookmarks.interfaces.0 }}"
- regexp: "(?P<block>interface {{interface_key}}\\.(?P<key>\\d+)\\n(?:.|\\n)*?^!$)"
from: interfaces.0
index:
_process: unnecessary
config:
Expand All @@ -73,9 +65,6 @@ interfaces:
_process:
- mode: is_present
regexp: "(?P<value>no shutdown)"
from: "{{ bookmarks.subinterface[subinterface_key] }}"
description:
_process:
- mode: search
regexp: "description (?P<value>.*)"
from: "{{ bookmarks.subinterface[subinterface_key] }}"
- regexp: "description (?P<value>.*)"
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,11 @@ global:
_process: unnecessary
as:
_process:
- mode: search
regexp: "local-as (?P<value>.*)"
from: "{{ bookmarks['protocol'][protocol_key] }}"
- regexp: "local-as (?P<value>.*)"
default: "{{ extra_vars.process_id|default(1) }}"
router-id:
_process:
- mode: search
regexp: "router-id (?P<value>.*)"
from: "{{ bookmarks['protocol'][protocol_key] }}"
- regexp: "router-id (?P<value>.*)"
default-route-distance:
_process: not_implemented
config:
Expand Down Expand Up @@ -355,9 +351,7 @@ neighbors:
_process: unnecessary
neighbor:
_process:
- mode: block
regexp: "(?P<block>neighbor (?P<key>\\d+.\\d+.\\d+.\\d+).*)"
from: "{{ bookmarks['protocol'][protocol_key] }}"
- regexp: "(?P<block>neighbor (?P<key>\\d+.\\d+.\\d+.\\d+).*)"
flat: true
add-paths:
_process: not_implemented
Expand Down Expand Up @@ -625,29 +619,21 @@ neighbors:
_process: not_implemented
description:
_process:
- mode: search
regexp: "neighbor {{ neighbor_key }} description (?P<value>.*)"
from: "{{ bookmarks['neighbor'][neighbor_key] }}"
- regexp: "neighbor {{ neighbor_key }} description (?P<value>.*)"
enabled:
_process:
- mode: is_absent
regexp: "neighbor {{ neighbor_key }} (?P<value>shutdown)"
from: "{{ bookmarks['neighbor'][neighbor_key] }}"
local-as:
_process:
- mode: search
regexp: "neighbor {{ neighbor_key }} local-as (?P<value>\\d+)"
from: "{{ bookmarks['neighbor'][neighbor_key] }}"
- regexp: "neighbor {{ neighbor_key }} local-as (?P<value>\\d+)"
neighbor-address:
_process:
- mode: value
value: "{{ neighbor_key }}"
from: "{{ bookmarks['neighbor'][neighbor_key] }}"
peer-as:
_process:
- mode: search
regexp: "neighbor {{ neighbor_key }} remote-as (?P<value>.*)"
from: "{{ bookmarks['neighbor'][neighbor_key] }}"
- regexp: "neighbor {{ neighbor_key }} remote-as (?P<value>.*)"
peer-group:
_process: not_implemented
peer-type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ _process:
when: "{{ protocol_key != 'static static' }}"
static:
_process:
- mode: block
regexp: "(?P<block>ip route (?P<key>\\d+.*\\/\\d+).*)"
from: "{{ bookmarks['network-instances'][0] }}"
- regexp: "(?P<block>ip route (?P<key>\\d+.*\\/\\d+).*)"
when: "{{ network_instance_key == 'global' }}"
flat: true
- mode: block
regexp: "(?P<block>ip route vrf {{ network_instance_key }} (?P<key>\\d+.*\\/\\d+).*)"
from: "{{ bookmarks['network-instances'][0] }}"
- regexp: "(?P<block>ip route vrf {{ network_instance_key }} (?P<key>\\d+.*\\/\\d+).*)"
when: "{{ network_instance_key != 'global' }}"
flat: true
config:
Expand All @@ -26,9 +22,7 @@ static:
_process: unnecessary
next-hop:
_process:
- mode: block
regexp: "(?P<block>ip route (vrf {{ network_instance_key }} )*{{ static_key }} (?P<key>\\d+.\\d+.\\d+.\\d+) (?P<metric>\\d+) tag (?P<tag>\\d+))"
from: "{{ bookmarks['static'][static_key] }}"
- regexp: "(?P<block>ip route (vrf {{ network_instance_key }} )*{{ static_key }} (?P<key>\\d+.\\d+.\\d+.\\d+) (?P<metric>\\d+) tag (?P<tag>\\d+))"
config:
_process: unnecessary
index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ network-instances:
_process: unnecessary
network-instance:
_process:
- mode: block
regexp: "(?P<block>vrf definition (?P<key>(.*))\n(?:.|\n)*?^!$)"
from: "{{ bookmarks['network-instances'][0] }}"
- regexp: "(?P<block>vrf definition (?P<key>(.*))\n(?:.|\n)*?^!$)"
from: network-instances.0
mandatory:
- key: "global"
block: ""
block: null
extra_vars: {}
afts: !include includes/afts.yaml
config:
_process: unnecessary
description:
_process:
- mode: search
regexp: "description (?P<value>.*)"
from: "{{ bookmarks.parent }}"
- regexp: "description (?P<value>.*)"
enabled:
_process:
- mode: value
Expand All @@ -37,9 +34,7 @@ network-instances:
_process: unnecessary
route-distinguisher:
_process:
- mode: search
regexp: "rd (?P<value>.*)"
from: "{{ bookmarks.parent }}"
- regexp: "rd (?P<value>.*)"
router-id:
_process: not_implemented
type:
Expand Down Expand Up @@ -321,19 +316,16 @@ network-instances:
_process: unnecessary
protocol:
_process:
- mode: block
regexp: "(?P<block>router (?P<protocol_name>(bgp))\\s*(?P<process_id>\\d+)*\n(?:.|\n)*?)^(!| vrf \\w+)$"
from: "{{ bookmarks['network-instances'][0] }}"
- regexp: "(?P<block>router (?P<protocol_name>(bgp))\\s*(?P<process_id>\\d+)*\n(?:.|\n)*?)^(!| vrf \\w+)$"
from: network-instances.0
composite_key: [protocol_name, protocol_name]
when: "{{ network_instance_key == 'global' }}"
- mode: block
regexp: "router (?P<protocol_name>(bgp))\\s*(?P<process_id>\\d+)*\n(?:.|\n)*?^ (?P<block>vrf {{ network_instance_key }}\n(?:.|\n)*?)^(!| vrf.*)$"
from: "{{ bookmarks['network-instances'][0] }}"
- regexp: "router (?P<protocol_name>(bgp))\\s*(?P<process_id>\\d+)*\n(?:.|\n)*?^ (?P<block>vrf {{ network_instance_key }}\n(?:.|\n)*?)^(!| vrf.*)$"
from: network-instances.0
composite_key: [protocol_name, protocol_name]
when: "{{ network_instance_key != 'global' }}"
- mode: block
regexp: "(?P<block>ip route .*\n(?:.|\n)*?^!$)"
from: "{{ bookmarks['network-instances'][0] }}"
- regexp: "(?P<block>ip route .*\n(?:.|\n)*?^!$)"
from: network-instances.0
key: "static static"
bgp: !include includes/bgp.yaml
config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ vlan:
_process: unnecessary
vlan-id:
_process:
- mode: search
regexp: "^\\W*encapsulation dot1q vlan (?P<value>[0-9]+)"
from: "{{ bookmarks['parent'] }}"
- regexp: "^\\W*encapsulation dot1q vlan (?P<value>[0-9]+)"
Loading