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

Commit

Permalink
Merge 3478d58 into a5d792c
Browse files Browse the repository at this point in the history
  • Loading branch information
bewing committed Jun 17, 2017
2 parents a5d792c + 3478d58 commit ac6f505
Show file tree
Hide file tree
Showing 14 changed files with 615 additions and 0 deletions.
1 change: 1 addition & 0 deletions napalm_yang/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def resolve_rule(rule, attribute, keys, extra_vars=None, translation_model=None,
def template(string, **kwargs):
env = jinja2.Environment(
undefined=jinja2.StrictUndefined,
extensions=['jinja2.ext.do'],
keep_trailing_newline=True,
)
env.filters.update(jinja_filters.load_filters())
Expand Down
2 changes: 2 additions & 0 deletions napalm_yang/jinja_filters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ip_filters
import json_filters

JINJA_FILTERS = [
ip_filters,
json_filters,
]


Expand Down
6 changes: 6 additions & 0 deletions napalm_yang/jinja_filters/json_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import json

def filters():
return {
"json": lambda obj: json.dumps(obj),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
metadata:
processor: JSONParser
execute:
- method: "device.run_commands"
args:
commands: ["show interfaces", "show snmp mib ifmib ifindex"]

interfaces:
_process: unnecessary
interface:
_process:
- mode: dict
from: "{{ bookmarks.interfaces.0.interfaces|json }}"
config:
_process: unnecessary
hold-time:
_process: not_implemented
state:
_process: not_implemented
down:
_process: not_implemented
up:
_process: not_implemented
state:
_process: unnecessary
admin-status:
_process:
- mode: map
value: "{{ bookmarks.parent.get('interfaceStatus', 'disabled') }}"
map:
"disabled": DOWN
"errdisabled": DOWN
"connected": UP
"notconnect": UP
counters:
_process: unnecessary
in-broadcast-pkts:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.inBroadcastPkts }}"
in-discards:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.inDiscards }}"
in-errors:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.totalInErrors }}"
in-multicast-pkts:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.inMulticastPkts }}"
_process: not_implemented
in-octets:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.inOctets }}"
_process: not_implemented
in-unicast-pkts:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.inUcastPkts }}"
_process: not_implemented
in-unknown-protos:
_process: not_implemented
last-clear:
_process: not_implemented
out-broadcast-pkts:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.outBroadcastPkts }}"
_process: not_implemented
out-discards:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.outDiscards }}"
_process: not_implemented
out-errors:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.totalOutErrors }}"
_process: not_implemented
out-multicast-pkts:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.outMulticastPkts }}"
_process: not_implemented
out-octets:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.outOctets }}"
_process: not_implemented
out-unicast-pkts:
_process:
- mode: value
value: "{{ bookmarks.parent.interfaceCounters.outUcastPkts }}"
description:
_process:
- mode: value
value: "{{ bookmarks.parent.description }}"
enabled:
_process:
- mode: map
value: "{{ bookmarks.parent.get('interfaceStatus', 'disabled') }}"
map:
"disabled": false
"errdisabled": true
"connected": true
"notconnect": true
ifindex:
_process: not_implemented
last-change:
_process: not_implemented
mtu:
_process:
- mode: value
value: "{{ bookmarks.parent.mtu }}"
name:
_process: not_implemented
oper-status:
_process:
- mode: map
value: "{{ bookmarks.parent.get('interfaceStatus', 'disabled') }}"
map:
"disabled": DOWN
"errdisabled": DOWN
"connected": UP
"notconnect": DOWN
type:
_process:
- mode: map
value: "{{ bookmarks.parent.get('hardware', 'Unspecified') }}"
map:
"ethernet": ethernetCsmacd
"Unspecified": null
subinterfaces:
_process: not_implemented
subinterface:
_process: not_implemented
state:
_process: not_implemented
admin-status:
_process: not_implemented
counters:
_process: not_implemented
in-broadcast-pkts:
_process: not_implemented
in-discards:
_process: not_implemented
in-errors:
_process: not_implemented
in-multicast-pkts:
_process: not_implemented
in-octets:
_process: not_implemented
in-unicast-pkts:
_process: not_implemented
in-unknown-protos:
_process: not_implemented
last-clear:
_process: not_implemented
out-broadcast-pkts:
_process: not_implemented
out-discards:
_process: not_implemented
out-errors:
_process: not_implemented
out-multicast-pkts:
_process: not_implemented
out-octets:
_process: not_implemented
out-unicast-pkts:
_process: not_implemented
description:
_process: not_implemented
enabled:
_process: not_implemented
ifindex:
_process: not_implemented
index:
_process: not_implemented
last-change:
_process: not_implemented
name:
_process: not_implemented
oper-status:
_process: not_implemented
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
metadata:
processor: JSONParser

transceiver:
_process: unnecessary
config:
_process: not_implemented
enabled:
_process: not_implemented
ethernet-pmd-preconf:
_process: not_implemented
form-factor-preconf:
_process: not_implemented
physical-channels:
_process: unnecessary
channel:
_process:
- mode: dict
from: "{{ bookmarks.parent.get('transceiver', {}).get('physical-channels', {}).get('channel', {})|json }}"
config:
_process: not_implemented
description:
_process: not_implemented
index:
_process: not_implemented
target-output-power:
_process: not_implemented
tx-laser:
_process: not_implemented
index:
_process: not_implemented
state:
_process: unnecessary
description:
_process: not_implemented
index:
_process:
- mode: value
value: "{{ parent_key }}"
input-power:
_process: unnecessary
avg:
_process: not_implemented
instant:
_process:
- mode: value
value: "{{ bookmarks.parent.state.get('input-power', {}).get('instant', None) }}"
when: "{{ bookmarks.parent.state.get('input-power', {}).get('instant', 'None') is not equalto 'None' }}"
max:
_process: not_implemented
min:
_process: not_implemented
laser-bias-current:
_process: unnecessary
avg:
_process: not_implemented
instant:
_process:
- mode: value
value: "{{ bookmarks.parent.state.get('laser-bias-current', {}).get('instant', None) }}"
when: "{{ bookmarks.parent.state.get('laser-bias-current', {}).get('instant', 'None') is not equalto 'None' }}"
max:
_process: not_implemented
min:
_process: not_implemented
output-frequency:
_process: not_implemented
output-power:
_process: unnecessary
avg:
_process: not_implemented
instant:
_process:
- mode: value
value: "{{ bookmarks.parent.state.get('output-power', {}).get('instant', None) }}"
when: "{{ bookmarks.parent.state.get('output-power', {}).get('instant', 'None') is not equalto 'None' }}"
max:
_process: not_implemented
min:
_process: not_implemented
target-output-power:
_process: not_implemented
tx-laser:
_process: not_implemented
state:
_process: unnecessary
connector-type:
_process: not_implemented
date-code:
_process: not_implemented
enabled:
_process:
- mode: value
value: "{{ bookmarks.parent.get('transceiver', {}).get('state', {}).get('enabled', None) }}"
when: "{{ bookmarks.parent.get('transceiver', {}).get('state', {}).get('enabled', 'None') is not equalto 'None' }}"
ethernet-pmd:
_process:
- mode: value
value: "{{ bookmarks.parent.get('transceiver', {}).get('state', {}).get('ethernet-pmd', None) }}"
when: "{{ bookmarks.parent.get('transceiver', {}).get('state', {}).get('ethernet-pmd', 'None') is not equalto 'None' }}"
ethernet-pmd-preconf:
_process: not_implemented
fault-condition:
_process: not_implemented
form-factor:
_process: not_implemented
form-factor-preconf:
_process: not_implemented
internal-temp:
_process: not_implemented
otn-compliance-code:
_process: not_implemented
present:
_process: not_implemented
serial-no:
_process: not_implemented
sonet-sdh-compliance-code:
_process: not_implemented
vendor:
_process: not_implemented
vendor-part:
_process: not_implemented
vendor-rev:
_process: not_implemented
Loading

0 comments on commit ac6f505

Please sign in to comment.