From 226ac24084078ada32f9e2717c50a1326b748042 Mon Sep 17 00:00:00 2001 From: "josh.jenkins" Date: Tue, 21 Nov 2017 19:06:14 -0800 Subject: [PATCH 1/3] 'or' logic doesn't allow 'None' which evaluates as False. This means that "allow_agent" cannot be set to True based on the logic provided. Instead, check if the value exists in the dict, then set the value absolutely (even if it's "None") if set. --- lib/jnpr/junos/device.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/jnpr/junos/device.py b/lib/jnpr/junos/device.py index 09ac26e12..814925ada 100644 --- a/lib/jnpr/junos/device.py +++ b/lib/jnpr/junos/device.py @@ -1146,10 +1146,14 @@ def __init__(self, *vargs, **kvargs): self._ssh_config = kvargs.get('ssh_config') self._sshconf_lkup() # but if user or private key is explicit from call, then use it. - self._auth_user = kvargs.get('user') or self._conf_auth_user or \ - self._auth_user - self._ssh_private_key_file = kvargs.get('ssh_private_key_file') \ - or self._conf_ssh_private_key_file + if 'user' in kvargs: + self._auth_user = kvargs.get('user') + else: + self._auth_user = self._conf_auth_user or self._auth_user + if 'ssh_private_key_file' in kvargs: + self._ssh_private_key_file = kvargs.get('ssh_private_key_file') + else: + self._ssh_private_key_file = self._conf_ssh_private_key_file self._auth_password = kvargs.get( 'password') or kvargs.get('passwd') From ff0575929c934e2543015d97dd5fa16884f49c3e Mon Sep 17 00:00:00 2001 From: "josh.jenkins" Date: Tue, 28 Nov 2017 19:11:35 -0800 Subject: [PATCH 2/3] Use paramiko less than 2.0 for python2.6 --- .travis.yml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4ea3f175d..6fdef81e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ addons: - libxslt1-dev install: - - if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install importlib; fi + - if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install importlib 'paramiko>=1.15.2,<2.0'; fi - "pip install -r development.txt" - "pip install -r requirements.txt" diff --git a/setup.py b/setup.py index e9466e517..3f61d7bcb 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ install_reqs = list(filter(None, req_lines)) if sys.version_info[:2] == (2, 6): install_reqs.append('importlib>=1.0.3') + install_reqs = [req.replace('paramiko>=1.15.2','paramiko>=1.15.2,<2.0') for req in install_reqs] setup( name="junos-eznc", From 8ff7f5ff16caeb5e62651b98a6667814126c7b35 Mon Sep 17 00:00:00 2001 From: jjico Date: Mon, 1 Apr 2019 15:30:41 -0700 Subject: [PATCH 3/3] replace yaml with json; update factory appropriately --- lib/jnpr/junos/factory/__init__.py | 38 ++++- lib/jnpr/junos/op/arp.json | 18 ++ lib/jnpr/junos/op/arp.py | 8 +- lib/jnpr/junos/op/arp.yml | 14 -- lib/jnpr/junos/op/bfd.json | 57 +++++++ lib/jnpr/junos/op/bfd.py | 8 +- lib/jnpr/junos/op/bfd.yml | 47 ------ lib/jnpr/junos/op/bgp.json | 18 ++ lib/jnpr/junos/op/bgp.py | 8 +- lib/jnpr/junos/op/bgp.yml | 15 -- lib/jnpr/junos/op/ccc.json | 31 ++++ lib/jnpr/junos/op/ccc.py | 8 +- lib/jnpr/junos/op/ccc.yml | 25 --- lib/jnpr/junos/op/ethernetswitchingtable.json | 47 ++++++ lib/jnpr/junos/op/ethernetswitchingtable.py | 10 +- lib/jnpr/junos/op/ethernetswitchingtable.yml | 41 ----- lib/jnpr/junos/op/ethport.json | 42 +++++ lib/jnpr/junos/op/ethport.py | 8 +- lib/jnpr/junos/op/ethport.yml | 29 ---- lib/jnpr/junos/op/fpc.json | 47 ++++++ lib/jnpr/junos/op/fpc.py | 8 +- lib/jnpr/junos/op/fpc.yml | 66 -------- lib/jnpr/junos/op/idpattacks.json | 14 ++ lib/jnpr/junos/op/idpattacks.py | 8 +- lib/jnpr/junos/op/idpattacks.yml | 11 -- lib/jnpr/junos/op/intopticdiag.json | 22 +++ lib/jnpr/junos/op/intopticdiag.py | 8 +- lib/jnpr/junos/op/intopticdiag.yml | 21 --- lib/jnpr/junos/op/inventory.json | 19 +++ lib/jnpr/junos/op/inventory.py | 8 +- lib/jnpr/junos/op/inventory.yml | 17 -- lib/jnpr/junos/op/isis.json | 46 ++++++ lib/jnpr/junos/op/isis.py | 8 +- lib/jnpr/junos/op/isis.yml | 38 ----- lib/jnpr/junos/op/l2circuit.json | 27 +++ lib/jnpr/junos/op/l2circuit.py | 8 +- lib/jnpr/junos/op/l2circuit.yml | 28 ---- lib/jnpr/junos/op/lacp.json | 58 +++++++ lib/jnpr/junos/op/lacp.py | 8 +- lib/jnpr/junos/op/lacp.yml | 56 ------- lib/jnpr/junos/op/ldp.json | 52 ++++++ lib/jnpr/junos/op/ldp.py | 8 +- lib/jnpr/junos/op/ldp.yml | 45 ----- lib/jnpr/junos/op/lldp.json | 19 +++ lib/jnpr/junos/op/lldp.py | 8 +- lib/jnpr/junos/op/lldp.yml | 16 -- lib/jnpr/junos/op/nd.json | 16 ++ lib/jnpr/junos/op/nd.py | 8 +- lib/jnpr/junos/op/nd.yml | 13 -- lib/jnpr/junos/op/ospf.json | 66 ++++++++ lib/jnpr/junos/op/ospf.py | 8 +- lib/jnpr/junos/op/ospf.yml | 58 ------- lib/jnpr/junos/op/phyport.json | 155 ++++++++++++++++++ lib/jnpr/junos/op/phyport.py | 8 +- lib/jnpr/junos/op/phyport.yml | 97 ----------- lib/jnpr/junos/op/routes.json | 63 +++++++ lib/jnpr/junos/op/routes.py | 8 +- lib/jnpr/junos/op/routes.yml | 51 ------ lib/jnpr/junos/op/teddb.json | 64 ++++++++ lib/jnpr/junos/op/teddb.py | 8 +- lib/jnpr/junos/op/teddb.yml | 46 ------ lib/jnpr/junos/op/vlan.json | 19 +++ lib/jnpr/junos/op/vlan.py | 8 +- lib/jnpr/junos/op/vlan.yml | 17 -- lib/jnpr/junos/op/xcvr.json | 20 +++ lib/jnpr/junos/op/xcvr.py | 8 +- lib/jnpr/junos/op/xcvr.yml | 16 -- lib/jnpr/junos/resources/autosys.json | 14 ++ lib/jnpr/junos/resources/autosys.yml | 12 -- lib/jnpr/junos/resources/bgp.json | 42 +++++ lib/jnpr/junos/resources/bgp.yml | 19 --- lib/jnpr/junos/resources/interface.json | 34 ++++ lib/jnpr/junos/resources/interface.yml | 22 --- lib/jnpr/junos/resources/staticroutes.json | 15 ++ lib/jnpr/junos/resources/staticroutes.yml | 14 -- lib/jnpr/junos/resources/syslog.json | 27 +++ lib/jnpr/junos/resources/syslog.yml | 19 --- lib/jnpr/junos/resources/user.json | 36 ++++ lib/jnpr/junos/resources/user.yml | 18 -- 79 files changed, 1208 insertions(+), 967 deletions(-) create mode 100644 lib/jnpr/junos/op/arp.json delete mode 100644 lib/jnpr/junos/op/arp.yml create mode 100644 lib/jnpr/junos/op/bfd.json delete mode 100644 lib/jnpr/junos/op/bfd.yml create mode 100644 lib/jnpr/junos/op/bgp.json delete mode 100644 lib/jnpr/junos/op/bgp.yml create mode 100644 lib/jnpr/junos/op/ccc.json delete mode 100644 lib/jnpr/junos/op/ccc.yml create mode 100644 lib/jnpr/junos/op/ethernetswitchingtable.json delete mode 100644 lib/jnpr/junos/op/ethernetswitchingtable.yml create mode 100644 lib/jnpr/junos/op/ethport.json delete mode 100644 lib/jnpr/junos/op/ethport.yml create mode 100644 lib/jnpr/junos/op/fpc.json delete mode 100644 lib/jnpr/junos/op/fpc.yml create mode 100644 lib/jnpr/junos/op/idpattacks.json delete mode 100644 lib/jnpr/junos/op/idpattacks.yml create mode 100644 lib/jnpr/junos/op/intopticdiag.json delete mode 100644 lib/jnpr/junos/op/intopticdiag.yml create mode 100644 lib/jnpr/junos/op/inventory.json delete mode 100644 lib/jnpr/junos/op/inventory.yml create mode 100644 lib/jnpr/junos/op/isis.json delete mode 100644 lib/jnpr/junos/op/isis.yml create mode 100644 lib/jnpr/junos/op/l2circuit.json delete mode 100644 lib/jnpr/junos/op/l2circuit.yml create mode 100644 lib/jnpr/junos/op/lacp.json delete mode 100644 lib/jnpr/junos/op/lacp.yml create mode 100644 lib/jnpr/junos/op/ldp.json delete mode 100644 lib/jnpr/junos/op/ldp.yml create mode 100644 lib/jnpr/junos/op/lldp.json delete mode 100644 lib/jnpr/junos/op/lldp.yml create mode 100644 lib/jnpr/junos/op/nd.json delete mode 100644 lib/jnpr/junos/op/nd.yml create mode 100644 lib/jnpr/junos/op/ospf.json delete mode 100644 lib/jnpr/junos/op/ospf.yml create mode 100644 lib/jnpr/junos/op/phyport.json delete mode 100644 lib/jnpr/junos/op/phyport.yml create mode 100644 lib/jnpr/junos/op/routes.json delete mode 100644 lib/jnpr/junos/op/routes.yml create mode 100644 lib/jnpr/junos/op/teddb.json delete mode 100644 lib/jnpr/junos/op/teddb.yml create mode 100644 lib/jnpr/junos/op/vlan.json delete mode 100644 lib/jnpr/junos/op/vlan.yml create mode 100644 lib/jnpr/junos/op/xcvr.json delete mode 100644 lib/jnpr/junos/op/xcvr.yml create mode 100644 lib/jnpr/junos/resources/autosys.json delete mode 100644 lib/jnpr/junos/resources/autosys.yml create mode 100644 lib/jnpr/junos/resources/bgp.json delete mode 100644 lib/jnpr/junos/resources/bgp.yml create mode 100644 lib/jnpr/junos/resources/interface.json delete mode 100644 lib/jnpr/junos/resources/interface.yml create mode 100644 lib/jnpr/junos/resources/staticroutes.json delete mode 100644 lib/jnpr/junos/resources/staticroutes.yml create mode 100644 lib/jnpr/junos/resources/syslog.json delete mode 100644 lib/jnpr/junos/resources/syslog.yml create mode 100644 lib/jnpr/junos/resources/user.json delete mode 100644 lib/jnpr/junos/resources/user.yml diff --git a/lib/jnpr/junos/factory/__init__.py b/lib/jnpr/junos/factory/__init__.py index 60a4b1d6a..62ed1cc67 100644 --- a/lib/jnpr/junos/factory/__init__.py +++ b/lib/jnpr/junos/factory/__init__.py @@ -1,33 +1,59 @@ +import glob +import json import yaml import os.path from jnpr.junos.factory.factory_loader import FactoryLoader -__all__ = ['loadyaml', 'FactoryLoader'] +__all__ = ['load', 'loadjson', 'loadyaml', 'FactoryLoader'] -def loadyaml(path): +def load(path): """ - Load a YAML file at :path: that contains Table and View definitions. + Load a file at :path: that contains Table and View definitions. Returns a of item-name anditem-class definition. + Supports both json and yaml natively; prefers JSON. + In this way additional support can be added (csv, xml, etc) If you want to import these definitions directly into your namespace, (like a module) you would do the following: - globals().update( loadyaml( )) + globals().update( load( )) If you did not want to do this, you can access the items as the . - For example, if your YAML file contained a Table called MyTable, then + For example, if your file contained a Table called MyTable, then you could do something like: - catalog = loadyaml( ) + catalog = load( ) MyTable = catalog['MyTable'] table = MyTable(dev) table.get() ... """ + ext = os.path.splitext(path)[1] + if ext == '': + # We don't have an ext, find it + candidates = glob.glob(path + '*') + for candy in candidates: + candy_ext = os.path.splitext(candy)[1] + if candy_ext == '.yml' or candy_ext = '.yaml': + return loadyaml(candy) + else: + return loadjson(candy) + elif ext == '.yml' or ext == '.yaml': + return loadyaml(path) + else: + return loadjson(path) + +def loadyaml(path): # if no extension is given, default to '.yml' if os.path.splitext(path)[1] == '': path += '.yml' return FactoryLoader().load(yaml.load(open(path, 'r'))) + +def loadjson(path): + # if no extension is given, default to '.json' + if os.path.splitext(path)[1] == '': + path += '.json' + return FactoryLoader().load(json.load(open(path, 'r'))) diff --git a/lib/jnpr/junos/op/arp.json b/lib/jnpr/junos/op/arp.json new file mode 100644 index 000000000..3ec1da4ad --- /dev/null +++ b/lib/jnpr/junos/op/arp.json @@ -0,0 +1,18 @@ +{ + "ArpView" : { + "fields" : { + "ip_address" : "ip-address", + "mac_address" : "mac-address", + "interface_name" : "interface-name" + } + }, + "ArpTable" : { + "rpc" : "get-arp-table-information", + "item" : "arp-table-entry", + "key" : "mac-address", + "view" : "ArpView", + "args" : { + "no-resolve" : "True" + } + } +} diff --git a/lib/jnpr/junos/op/arp.py b/lib/jnpr/junos/op/arp.py index 117789533..2124f5ff4 100644 --- a/lib/jnpr/junos/op/arp.py +++ b/lib/jnpr/junos/op/arp.py @@ -1,7 +1,7 @@ """ Pythonifier for ARP Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/arp.yml b/lib/jnpr/junos/op/arp.yml deleted file mode 100644 index 0df478d4b..000000000 --- a/lib/jnpr/junos/op/arp.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -ArpTable: - rpc: get-arp-table-information - args: - no-resolve: True - item: arp-table-entry - key: mac-address - view: ArpView - -ArpView: - fields: - mac_address: mac-address - ip_address: ip-address - interface_name: interface-name diff --git a/lib/jnpr/junos/op/bfd.json b/lib/jnpr/junos/op/bfd.json new file mode 100644 index 000000000..8bed8c9a0 --- /dev/null +++ b/lib/jnpr/junos/op/bfd.json @@ -0,0 +1,57 @@ +{ + "BfdSessionTable" : { + "key" : "session-neighbor", + "rpc" : "get-bfd-session-information", + "args" : { + "extensive" : "True" + }, + "item" : "bfd-session", + "view" : "BfdSessionView" + }, + "_BfdSessionClientView" : { + "fields" : { + "name" : "client-name", + "reception_interval" : "client-reception-interval", + "transmission_interval" : "client-transmission-interval" + } + }, + "_BfdSessionClientTable" : { + "view" : "_BfdSessionClientView", + "item" : "bfd-client" + }, + "BfdSessionView" : { + "fields" : { + "bfd_client" : "_BfdSessionClientTable", + "detection_time" : "session-detection-time", + "remote_state" : "remote-state", + "local_diagnostic" : "local-diagnostic", + "no_absorb" : { + "no-absorb" : "True=regex(no-absorb)" + }, + "neighbor_minimum_transmission_interval" : "neighbor-minimum-transmission_interval", + "remote_diagnostic" : "remote-diagnostic", + "state" : "session-state", + "neighbor_minimum_reception_interval" : "neighbor-minimum-reception_interval", + "neighbor" : "session-neighbor", + "minimum_reception_interval" : "minimum-reception-interval", + "minimum_asynchronous_interval" : "minimum-asynchronous-interval", + "adaptive_asynchronous_transmission_interval" : "adaptive-asynchronous-transmission_interval", + "echo_mode_state" : "echo-mode-state", + "detection_multiplier" : "detection-multiplier", + "minimum_transmission_interval" : "minimum-transmission-interval", + "no_refresh" : { + "no-refresh" : "True=no-refresh" + }, + "echo_mode_desired" : "echo-mode-desired", + "remote_discriminator" : "remote-discriminator", + "adaptive_reception_interval" : "adaptive-reception-interval", + "version" : "session-version", + "adaptive_multiplier" : "session-adaptive-multiplier", + "local_discriminator" : "local-discriminator", + "transmission_interval" : "session-transmission-interval", + "neighbor_session_multiplier" : "neighbor-session-multiplier", + "interface" : "session-interface", + "minimum_slow_interval" : "minimum-slow-interval" + } + } +} diff --git a/lib/jnpr/junos/op/bfd.py b/lib/jnpr/junos/op/bfd.py index e029d0724..b2c70f206 100644 --- a/lib/jnpr/junos/op/bfd.py +++ b/lib/jnpr/junos/op/bfd.py @@ -1,7 +1,7 @@ """ Pythonifier for BFD Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/bfd.yml b/lib/jnpr/junos/op/bfd.yml deleted file mode 100644 index dfeca56e0..000000000 --- a/lib/jnpr/junos/op/bfd.yml +++ /dev/null @@ -1,47 +0,0 @@ -BfdSessionTable: - rpc: get-bfd-session-information - args: - extensive: True - item: bfd-session - key: session-neighbor - view: BfdSessionView - -BfdSessionView: - fields: - neighbor: session-neighbor - state: session-state - interface: session-interface - detection_time: session-detection-time - transmission_interval: session-transmission-interval - adaptive_multiplier: session-adaptive-multiplier - local_diagnostic: local-diagnostic - remote_diagnostic: remote-diagnostic - version: session-version - remote_state: remote-state - minimum_asynchronous_interval: minimum-asynchronous-interval - minimum_slow_interval: minimum-slow-interval - adaptive_asynchronous_transmission_interval: adaptive-asynchronous-transmission_interval - adaptive_reception_interval: adaptive-reception-interval - minimum_transmission_interval: minimum-transmission-interval - minimum_reception_interval: minimum-reception-interval - detection_multiplier: detection-multiplier - neighbor_minimum_transmission_interval: neighbor-minimum-transmission_interval - neighbor_minimum_reception_interval: neighbor-minimum-reception_interval - neighbor_session_multiplier: neighbor-session-multiplier - local_discriminator: local-discriminator - remote_discriminator: remote-discriminator - echo_mode_desired: echo-mode-desired - echo_mode_state: echo-mode-state - no_absorb: { no-absorb: True=regex(no-absorb) } - no_refresh: { no-refresh: True=no-refresh } - bfd_client: _BfdSessionClientTable - -_BfdSessionClientTable: - item: bfd-client - view: _BfdSessionClientView - -_BfdSessionClientView: - fields: - name: client-name - transmission_interval: client-transmission-interval - reception_interval: client-reception-interval diff --git a/lib/jnpr/junos/op/bgp.json b/lib/jnpr/junos/op/bgp.json new file mode 100644 index 000000000..33a6ab91f --- /dev/null +++ b/lib/jnpr/junos/op/bgp.json @@ -0,0 +1,18 @@ +{ + "bgpTable" : { + "rpc" : "get-bgp-neighbor-information", + "item" : "bgp-peer", + "key" : "peer-id", + "view" : "bgpView" + }, + "bgpView" : { + "fields" : { + "local_address" : "local-address", + "local_as" : "local-as", + "peer_id" : "peer-id", + "route_received" : "bgp-rib/received-prefix-count", + "peer_as" : "peer-as", + "local_id" : "local-id" + } + } +} diff --git a/lib/jnpr/junos/op/bgp.py b/lib/jnpr/junos/op/bgp.py index 51754393a..0ecebc94f 100644 --- a/lib/jnpr/junos/op/bgp.py +++ b/lib/jnpr/junos/op/bgp.py @@ -1,7 +1,7 @@ """ Pythonifier for BGP Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/bgp.yml b/lib/jnpr/junos/op/bgp.yml deleted file mode 100644 index 769c17053..000000000 --- a/lib/jnpr/junos/op/bgp.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -bgpTable: - rpc: get-bgp-neighbor-information - item: bgp-peer - view: bgpView - key: peer-id - -bgpView: - fields: - local_as: local-as - peer_as: peer-as - local_address: local-address - peer_id: peer-id - local_id: local-id - route_received: bgp-rib/received-prefix-count diff --git a/lib/jnpr/junos/op/ccc.json b/lib/jnpr/junos/op/ccc.json new file mode 100644 index 000000000..02499a8e3 --- /dev/null +++ b/lib/jnpr/junos/op/ccc.json @@ -0,0 +1,31 @@ +{ + "_CCCPortsView" : { + "fields" : { + "status" : "ccc-circuit-status", + "type" : "ccc-circuit-type" + } + }, + "CCCView" : { + "fields" : { + "ports" : "_CCCPorts", + "status" : "ccc-connection-status" + } + }, + "CCCTable" : { + "key" : "ccc-connection-name", + "view" : "CCCView", + "args" : { + "status" : "True", + "interface-switch" : "True" + }, + "item" : "ccc-connection", + "rpc" : "get-ccc-information" + }, + "_CCCPorts" : { + "key" : [ + "ccc-circuit-name" + ], + "view" : "_CCCPortsView", + "item" : "ccc-connection-circuit" + } +} diff --git a/lib/jnpr/junos/op/ccc.py b/lib/jnpr/junos/op/ccc.py index 5eddacfb7..116fb822e 100644 --- a/lib/jnpr/junos/op/ccc.py +++ b/lib/jnpr/junos/op/ccc.py @@ -1,7 +1,7 @@ """ Pythonifier for Circuit Cross Connect Table/View (ccc) """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/ccc.yml b/lib/jnpr/junos/op/ccc.yml deleted file mode 100644 index 80a8e008c..000000000 --- a/lib/jnpr/junos/op/ccc.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -CCCTable: - rpc: get-ccc-information - args: - status: True - interface-switch: True - item: ccc-connection - key: ccc-connection-name - view: CCCView - -CCCView: - fields: - status: ccc-connection-status - ports: _CCCPorts - -_CCCPorts: - item: ccc-connection-circuit - key: - - ccc-circuit-name - view: _CCCPortsView - -_CCCPortsView: - fields: - type: ccc-circuit-type - status: ccc-circuit-status diff --git a/lib/jnpr/junos/op/ethernetswitchingtable.json b/lib/jnpr/junos/op/ethernetswitchingtable.json new file mode 100644 index 000000000..9a0e0d69e --- /dev/null +++ b/lib/jnpr/junos/op/ethernetswitchingtable.json @@ -0,0 +1,47 @@ +{ + "EthernetSwitchingTable" : { + "args" : { + "detail" : true + }, + "item" : "ethernet-switching-table", + "rpc" : "get-ethernet-switching-table-information", + "view" : "EthernetSwitchingView" + }, + "EthernetSwitchingView" : { + "fields" : { + "count" : "mac-table-count", + "entries" : "_MacTableEntriesTable", + "learned" : "mac-table-learned", + "persistent" : "mac-table-persistent" + } + }, + "_MacTableEntriesTable" : { + "item" : "mac-table-entry", + "key" : "mac-vlan", + "view" : "_MacTableEntriesView" + }, + "_MacTableEntriesView" : { + "fields" : { + "action" : "mac-action", + "age" : "mac-age", + "interface" : "mac-interface", + "interface-list" : "_MacTableInterfacesTable", + "learned_time" : "mac-learned-time", + "mac_address" : "mac-address", + "next_hop" : "mac-nexthop", + "type" : "mac-type", + "vlan" : "mac-vlan", + "vlan_tag" : "mac-vlan-tag" + } + }, + "_MacTableInterfacesTable" : { + "item" : "mac-interfaces-list", + "key" : "mac-interfaces", + "view" : "_MacTableInterfacesView" + }, + "_MacTableInterfacesView" : { + "fields" : { + "interfaces" : "mac-interfaces" + } + } +} diff --git a/lib/jnpr/junos/op/ethernetswitchingtable.py b/lib/jnpr/junos/op/ethernetswitchingtable.py index 2a0a6cc1d..f2b9fdeeb 100644 --- a/lib/jnpr/junos/op/ethernetswitchingtable.py +++ b/lib/jnpr/junos/op/ethernetswitchingtable.py @@ -1,9 +1,7 @@ """ Pythonifier for EthernetSwitchingTable/View """ - -from jnpr.junos.factory import loadyaml -from os.path import splitext - -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/ethernetswitchingtable.yml b/lib/jnpr/junos/op/ethernetswitchingtable.yml deleted file mode 100644 index 1cfc7601b..000000000 --- a/lib/jnpr/junos/op/ethernetswitchingtable.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -EthernetSwitchingTable: - rpc: get-ethernet-switching-table-information - args: - detail: True - item: ethernet-switching-table - view: EthernetSwitchingView - -EthernetSwitchingView: - fields: - count: mac-table-count - learned: mac-table-learned - persistent: mac-table-persistent - entries: _MacTableEntriesTable - -_MacTableEntriesTable: - item: mac-table-entry - key: mac-vlan - view: _MacTableEntriesView - -_MacTableEntriesView: - fields: - vlan: mac-vlan - vlan_tag: mac-vlan-tag - mac_address: mac-address - type: mac-type - age: mac-age - learned_time: mac-learned-time - action: mac-action - next_hop: mac-nexthop - interface: mac-interface - interface-list: _MacTableInterfacesTable - -_MacTableInterfacesTable: - item: mac-interfaces-list - key: mac-interfaces - view: _MacTableInterfacesView - -_MacTableInterfacesView: - fields: - interfaces: mac-interfaces diff --git a/lib/jnpr/junos/op/ethport.json b/lib/jnpr/junos/op/ethport.json new file mode 100644 index 000000000..74ffbb20a --- /dev/null +++ b/lib/jnpr/junos/op/ethport.json @@ -0,0 +1,42 @@ +{ + "EthPortView" : { + "fields" : { + "macaddr" : "current-physical-address", + "admin" : "admin-status", + "oper" : "oper-status", + "description" : "description", + "mtu" : { + "mtu" : "int" + }, + "link_mode" : "link-mode" + }, + "groups" : { + "flags" : "if-device-flags", + "mac_stats" : "ethernet-mac-statistics" + }, + "fields_mac_stats" : { + "tx_packets" : "output-packets", + "tx_bytes" : "output-bytes", + "rx_bytes" : "input-bytes", + "rx_packets" : "input-packets" + }, + "fields_flags" : { + "running" : { + "ifdf-running" : "flag" + }, + "present" : { + "ifdf-present" : "flag" + } + } + }, + "EthPortTable" : { + "args_key" : "interface_name", + "args" : { + "interface_name" : "[afgxe][et]-*", + "media" : "True" + }, + "view" : "EthPortView", + "rpc" : "get-interface-information", + "item" : "physical-interface" + } +} diff --git a/lib/jnpr/junos/op/ethport.py b/lib/jnpr/junos/op/ethport.py index 3af32d198..23e6b5dd0 100644 --- a/lib/jnpr/junos/op/ethport.py +++ b/lib/jnpr/junos/op/ethport.py @@ -1,7 +1,7 @@ """ Pythonifier for EthPort Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/ethport.yml b/lib/jnpr/junos/op/ethport.yml deleted file mode 100644 index 607c3a7d6..000000000 --- a/lib/jnpr/junos/op/ethport.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -EthPortTable: - rpc: get-interface-information - args: - media: True - interface_name: '[afgxe][et]-*' - args_key: interface_name - item: physical-interface - view: EthPortView - -EthPortView: - groups: - mac_stats: ethernet-mac-statistics - flags: if-device-flags - fields: - oper: oper-status - admin: admin-status - description: description - mtu: { mtu : int } - link_mode: link-mode - macaddr: current-physical-address - fields_mac_stats: - rx_bytes: input-bytes - rx_packets: input-packets - tx_bytes: output-bytes - tx_packets: output-packets - fields_flags: - running: { ifdf-running: flag } - present: { ifdf-present: flag } diff --git a/lib/jnpr/junos/op/fpc.json b/lib/jnpr/junos/op/fpc.json new file mode 100644 index 000000000..94662ea63 --- /dev/null +++ b/lib/jnpr/junos/op/fpc.json @@ -0,0 +1,47 @@ +{ + "_fpc_hw_view" : { + "fields" : { + "model" : "model-number", + "ver" : "version", + "sn" : "serial-number", + "pn" : "part-number", + "desc" : "description" + } + }, + "FpcInfoTable" : { + "view" : "_fpc_info_view", + "key" : "slot", + "rpc" : "get-fpc-information", + "item" : ".//fpc" + }, + "_fpc_info_view" : { + "fields" : { + "state" : "state", + "memory" : "memory-heap-utilization", + "cpu" : "cpu-total" + } + }, + "FpcHwTable" : { + "view" : "_fpc_hw_view", + "rpc" : "get-chassis-inventory", + "item" : ".//name[starts-with(.,'FPC')]/parent::*" + }, + "FpcMiReHwTable" : { + "item" : ".//name[starts-with(.,'FPC')]/parent::*", + "rpc" : "get-chassis-inventory", + "key" : [ + "ancestor::multi-routing-engine-item/re-name", + "name" + ], + "view" : "_fpc_hw_view" + }, + "FpcMiReInfoTable" : { + "rpc" : "get-fpc-information", + "item" : ".//fpc", + "view" : "_fpc_info_view", + "key" : [ + "ancestor::multi-routing-engine-item/re-name", + "slot" + ] + } +} diff --git a/lib/jnpr/junos/op/fpc.py b/lib/jnpr/junos/op/fpc.py index 22554b24f..c5bf045af 100644 --- a/lib/jnpr/junos/op/fpc.py +++ b/lib/jnpr/junos/op/fpc.py @@ -1,7 +1,7 @@ """ Pythonifier for Route Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/fpc.yml b/lib/jnpr/junos/op/fpc.yml deleted file mode 100644 index 233133be1..000000000 --- a/lib/jnpr/junos/op/fpc.yml +++ /dev/null @@ -1,66 +0,0 @@ ---- - -# ------------------------------------------------------------------- -# Table -# ------------------------------------------------------------------- -# retrieve the chassis hardware (inventory) and extract the FPC -# items. -# ------------------------------------------------------------------- - -FpcHwTable: - rpc: get-chassis-inventory - item: .//name[starts-with(.,'FPC')]/parent::* - view: _fpc_hw_view - -FpcMiReHwTable: - rpc: get-chassis-inventory - item: .//name[starts-with(.,'FPC')]/parent::* - key: - - ancestor::multi-routing-engine-item/re-name - - name - view: _fpc_hw_view - -# ------------------------------------------------------------------- -# View -# ------------------------------------------------------------------- -# use the underscore (_) so this definition is not -# imported into the glboal namespace. We want to extract various -# bits of information from the FPC items -# ------------------------------------------------------------------- - -_fpc_hw_view: - fields: - sn: serial-number - pn: part-number - desc: description - ver: version - model: model-number - -# ------------------------------------------------------------------- -# Table -# ------------------------------------------------------------------- -# retrieve the FPC status information; corresponds to: -# > show chassis fpc -# ------------------------------------------------------------------- - -FpcInfoTable: - rpc: get-fpc-information - item: .//fpc - key: slot - view: _fpc_info_view - -FpcMiReInfoTable: - rpc: get-fpc-information - item: .//fpc - key: - - ancestor::multi-routing-engine-item/re-name - - slot - view: _fpc_info_view - -_fpc_info_view: - fields: - state: state - memory: memory-heap-utilization - cpu: cpu-total - - diff --git a/lib/jnpr/junos/op/idpattacks.json b/lib/jnpr/junos/op/idpattacks.json new file mode 100644 index 000000000..5f594aa11 --- /dev/null +++ b/lib/jnpr/junos/op/idpattacks.json @@ -0,0 +1,14 @@ +{ + "IDPAttackView" : { + "fields" : { + "attack_name" : "name", + "count" : "value" + } + }, + "IDPAttackTable" : { + "item" : "idp-attack-statistics", + "key" : "name", + "rpc" : "get-idp-attack-table-information", + "view" : "IDPAttackView" + } +} diff --git a/lib/jnpr/junos/op/idpattacks.py b/lib/jnpr/junos/op/idpattacks.py index 1450a3ebc..47e31bb8b 100644 --- a/lib/jnpr/junos/op/idpattacks.py +++ b/lib/jnpr/junos/op/idpattacks.py @@ -1,7 +1,7 @@ """ Pythonifier for IDP Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/idpattacks.yml b/lib/jnpr/junos/op/idpattacks.yml deleted file mode 100644 index b6c9e4f00..000000000 --- a/lib/jnpr/junos/op/idpattacks.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -IDPAttackTable: - rpc: get-idp-attack-table-information - item: idp-attack-statistics - key: name - view: IDPAttackView - -IDPAttackView: - fields: - attack_name: name - count: value diff --git a/lib/jnpr/junos/op/intopticdiag.json b/lib/jnpr/junos/op/intopticdiag.json new file mode 100644 index 000000000..5773c5fd1 --- /dev/null +++ b/lib/jnpr/junos/op/intopticdiag.json @@ -0,0 +1,22 @@ +{ + "PhyPortDiagView" : { + "groups" : { + "diag" : "optics-diagnostics" + }, + "fields_diag" : { + "module_voltage" : "module-voltage", + "rx_optic_power" : "rx-signal-avg-optical-power-dbm", + "tx_optic_power" : "laser-output-power-dbm", + "module_temperature" : "module-temperature" + } + }, + "PhyPortDiagTable" : { + "rpc" : "get-interface-optics-diagnostics-information", + "args_key" : "interface_name", + "view" : "PhyPortDiagView", + "args" : { + "interface_name" : "[efgx][et]-*" + }, + "item" : "physical-interface" + } +} diff --git a/lib/jnpr/junos/op/intopticdiag.py b/lib/jnpr/junos/op/intopticdiag.py index a61c9bcc6..3675a6742 100644 --- a/lib/jnpr/junos/op/intopticdiag.py +++ b/lib/jnpr/junos/op/intopticdiag.py @@ -1,7 +1,7 @@ """ Pythonifier for IntOpticDiag Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/intopticdiag.yml b/lib/jnpr/junos/op/intopticdiag.yml deleted file mode 100644 index 91223d47a..000000000 --- a/lib/jnpr/junos/op/intopticdiag.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -PhyPortDiagTable: - rpc: get-interface-optics-diagnostics-information - args: - interface_name: '[efgx][et]-*' - args_key: interface_name - item: physical-interface - view: PhyPortDiagView - -PhyPortDiagView: - groups: - diag: optics-diagnostics - - # fields that are part of groups are called - # "fields_" - - fields_diag: - rx_optic_power : rx-signal-avg-optical-power-dbm - tx_optic_power : laser-output-power-dbm - module_temperature : module-temperature - module_voltage : module-voltage diff --git a/lib/jnpr/junos/op/inventory.json b/lib/jnpr/junos/op/inventory.json new file mode 100644 index 000000000..483c9f504 --- /dev/null +++ b/lib/jnpr/junos/op/inventory.json @@ -0,0 +1,19 @@ +{ + "ModuleTableView" : { + "fields" : { + "ver" : "version", + "jname" : "name", + "pn" : "part-number", + "sn" : "serial-number", + "type" : "description" + } + }, + "ModuleTable" : { + "key" : [ + "name" + ], + "view" : "ModuleTableView", + "item" : ".//chassis-sub-module|.//chassis-module|.//chassis-sub-sub-module", + "rpc" : "get-chassis-inventory" + } +} diff --git a/lib/jnpr/junos/op/inventory.py b/lib/jnpr/junos/op/inventory.py index 6e303b227..98d2bc7bb 100644 --- a/lib/jnpr/junos/op/inventory.py +++ b/lib/jnpr/junos/op/inventory.py @@ -1,7 +1,7 @@ """ Pythonifier for Inventory Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/inventory.yml b/lib/jnpr/junos/op/inventory.yml deleted file mode 100644 index c236cc5c8..000000000 --- a/lib/jnpr/junos/op/inventory.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -ModuleTable: - rpc: get-chassis-inventory - item: .//chassis-sub-module|.//chassis-module|.//chassis-sub-sub-module - key: - - name - view: ModuleTableView - -ModuleTableView: - fields: - jname: name - sn: serial-number - pn: part-number - ver: version - type: description - diff --git a/lib/jnpr/junos/op/isis.json b/lib/jnpr/junos/op/isis.json new file mode 100644 index 000000000..05fd51e1d --- /dev/null +++ b/lib/jnpr/junos/op/isis.json @@ -0,0 +1,46 @@ +{ + "_IsisAdjacencyLogTable" : { + "key" : [ + "adjacency-when", + "adjacency-state" + ], + "item" : "isis-adjacency-log", + "view" : "_IsisAdjacencyLogView" + }, + "IsisAdjacencyTable" : { + "item" : "isis-adjacency", + "args" : { + "extensive" : "True" + }, + "key" : [ + "interface-name", + "system-name" + ], + "rpc" : "get-isis-adjacency-information", + "view" : "IsisAdjacencyView" + }, + "IsisAdjacencyView" : { + "fields" : { + "adjacency_flag" : "adjacency-flag", + "adjacency_log" : "_IsisAdjacencyLogTable", + "adjacency_state" : "adjacency-state", + "adjacency_topologies" : "adjacency-topologies", + "ip_address" : "ip-address", + "interface_priority" : "interface-priority", + "adjacency_restart_capable" : "adjacency-restart-capable", + "circuit_type" : "circuit-type", + "system_name" : "system-name", + "adjacency_advertisement" : "adjacency-advertisement", + "holdtime" : "holdtime", + "interface_name" : "interface-name", + "level" : "level" + } + }, + "_IsisAdjacencyLogView" : { + "fields" : { + "state" : "adjacency-state", + "when" : "adjacency-when", + "event" : "adjacency-event" + } + } +} diff --git a/lib/jnpr/junos/op/isis.py b/lib/jnpr/junos/op/isis.py index 3407695be..d01813d79 100644 --- a/lib/jnpr/junos/op/isis.py +++ b/lib/jnpr/junos/op/isis.py @@ -1,7 +1,7 @@ """ Pythonifier for ISIS Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/isis.yml b/lib/jnpr/junos/op/isis.yml deleted file mode 100644 index e9789b443..000000000 --- a/lib/jnpr/junos/op/isis.yml +++ /dev/null @@ -1,38 +0,0 @@ -IsisAdjacencyTable: - rpc: get-isis-adjacency-information - args: - extensive: True - item: isis-adjacency - key: - - interface-name - - system-name - view: IsisAdjacencyView - -IsisAdjacencyView: - fields: - interface_name: interface-name - system_name: system-name - level: level - adjacency_state: adjacency-state - holdtime: holdtime - circuit_type: circuit-type - ip_address: ip-address - interface_priority: interface-priority - adjacency_flag: adjacency-flag - adjacency_topologies: adjacency-topologies - adjacency_restart_capable: adjacency-restart-capable - adjacency_advertisement: adjacency-advertisement - adjacency_log: _IsisAdjacencyLogTable - -_IsisAdjacencyLogTable: - item: isis-adjacency-log - key: - - adjacency-when - - adjacency-state - view: _IsisAdjacencyLogView - -_IsisAdjacencyLogView: - fields: - when: adjacency-when - state: adjacency-state - event: adjacency-event diff --git a/lib/jnpr/junos/op/l2circuit.json b/lib/jnpr/junos/op/l2circuit.json new file mode 100644 index 000000000..0efdb3605 --- /dev/null +++ b/lib/jnpr/junos/op/l2circuit.json @@ -0,0 +1,27 @@ +{ + "L2CircuitConnectionTable" : { + "item" : "l2circuit-neighbor/connection", + "view" : "L2CircuitConnectionView", + "rpc" : "get-l2ckt-connection-information", + "key" : [ + "ancestor::l2circuit-neighbor/neighbor-address", + "connection-id" + ] + }, + "L2CircuitConnectionView" : { + "fields" : { + "inboud_label" : "inbound-label", + "connection_status" : "connection-status", + "outbound_label" : "outbound-label", + "connection_type" : "connection-type", + "local_interface" : "local-interface/interface-name", + "remote_pe" : "remote-pe", + "interface_description" : "local-interface/interface-description", + "interface_encapsulation" : "local-interface/interface-encapsulation", + "pw_status_tlv" : "pw-status-tlv", + "connection_id" : "connection-id", + "control_word" : "control-word", + "interface_status" : "local-interface/interface-status" + } + } +} diff --git a/lib/jnpr/junos/op/l2circuit.py b/lib/jnpr/junos/op/l2circuit.py index b9a207d05..b87720e1d 100644 --- a/lib/jnpr/junos/op/l2circuit.py +++ b/lib/jnpr/junos/op/l2circuit.py @@ -1,7 +1,7 @@ """ Pythonifier for Route L2circuit/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/l2circuit.yml b/lib/jnpr/junos/op/l2circuit.yml deleted file mode 100644 index 718722ed7..000000000 --- a/lib/jnpr/junos/op/l2circuit.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- - -### ------------------------------------------------------ -### show l2circuit connections -### ------------------------------------------------------ - -L2CircuitConnectionTable: - rpc: get-l2ckt-connection-information - item: l2circuit-neighbor/connection - key: - - ancestor::l2circuit-neighbor/neighbor-address - - connection-id - view: L2CircuitConnectionView - -L2CircuitConnectionView: - fields: - connection_id: connection-id - connection_type: connection-type - connection_status: connection-status - remote_pe: remote-pe - control_word: control-word - inboud_label: inbound-label - outbound_label: outbound-label - pw_status_tlv: pw-status-tlv - local_interface: local-interface/interface-name - interface_status: local-interface/interface-status - interface_encapsulation: local-interface/interface-encapsulation - interface_description: local-interface/interface-description diff --git a/lib/jnpr/junos/op/lacp.json b/lib/jnpr/junos/op/lacp.json new file mode 100644 index 000000000..b7a855819 --- /dev/null +++ b/lib/jnpr/junos/op/lacp.json @@ -0,0 +1,58 @@ +{ + "LacpPortView" : { + "fields" : { + "state" : "_LacpPortStateTable", + "proto" : "_LacpPortProtoTable" + } + }, + "_LacpPortProtoTable" : { + "item" : "lag-lacp-protocol", + "view" : "_LacpPortProtoView" + }, + "_LacpPortStateView" : { + "fields" : { + "defaulted" : { + "lacp-defaulted" : "True=Yes" + }, + "distributing" : { + "lacp-distributing" : "True=Yes" + }, + "expired" : { + "lacp-expired" : "True=Yes" + }, + "aggregation" : { + "lacp-aggregation" : "True=Yes" + }, + "timeout" : "lacp-timeout", + "sync" : { + "lacp-synchronization" : "True=Yes" + }, + "collecting" : { + "lacp-collecting" : "True=Yes" + }, + "activity" : "lacp-activity" + } + }, + "_LacpPortStateTable" : { + "key" : [ + "name", + "lacp-role" + ], + "item" : "lag-lacp-state", + "view" : "_LacpPortStateView" + }, + "_LacpPortProtoView" : { + "fields" : { + "tx_state" : "lacp-transmit-state", + "mx_state" : "lacp-mux-state", + "rx_state" : "lacp-receive-state" + } + }, + "LacpPortTable" : { + "args_key" : "interface_name", + "key" : "lag-lacp-header/aggregate-name", + "rpc" : "get-lacp-interface-information", + "view" : "LacpPortView", + "item" : "lacp-interface-information" + } +} diff --git a/lib/jnpr/junos/op/lacp.py b/lib/jnpr/junos/op/lacp.py index 53ca4ba8c..5425e2b71 100644 --- a/lib/jnpr/junos/op/lacp.py +++ b/lib/jnpr/junos/op/lacp.py @@ -1,7 +1,7 @@ """ Pythonifier for LACP Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/lacp.yml b/lib/jnpr/junos/op/lacp.yml deleted file mode 100644 index a7a35aca3..000000000 --- a/lib/jnpr/junos/op/lacp.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -# ----------------------------------------------------------------------------- -# LACP ports are aggregating-ethernet interfaces, e.g. 'ae0' -# ----------------------------------------------------------------------------- - -LacpPortTable: - rpc: get-lacp-interface-information - args_key: interface_name - item: lacp-interface-information - key: lag-lacp-header/aggregate-name - view: LacpPortView - -# the view provides access to two tables states and protocols - -LacpPortView: - fields: - state: _LacpPortStateTable - proto: _LacpPortProtoTable - -# ----------------------------------------------------------------------------- -# Each LACP port maintains a "state" table that ha a composite key of the -# interface name and it's role (Actor/Partner). name with the "_" so this -# item does not get exported to the global namespace -# ----------------------------------------------------------------------------- - -_LacpPortStateTable: - item: lag-lacp-state - key: - - name - - lacp-role - view: _LacpPortStateView - -_LacpPortStateView: - fields: - activity: lacp-activity - timeout: lacp-timeout - expired: { lacp-expired: True=Yes } - defaulted: { lacp-defaulted: True=Yes } - distributing: { lacp-distributing: True=Yes } - collecting: { lacp-collecting: True=Yes } - sync : { lacp-synchronization: True=Yes } - aggregation: { lacp-aggregation: True=Yes } - -# ----------------------------------------------------------------------------- -# Each LACP port maintains a "protocol" table -# ----------------------------------------------------------------------------- - -_LacpPortProtoTable: - item: lag-lacp-protocol - view: _LacpPortProtoView - -_LacpPortProtoView: - fields: - rx_state: lacp-receive-state - tx_state: lacp-transmit-state - mx_state: lacp-mux-state diff --git a/lib/jnpr/junos/op/ldp.json b/lib/jnpr/junos/op/ldp.json new file mode 100644 index 000000000..2cb404cf9 --- /dev/null +++ b/lib/jnpr/junos/op/ldp.json @@ -0,0 +1,52 @@ +{ + "_LdpNeighborHelloFlagsView" : { + "fields" : { + "flag" : "ldp-neighbor-hello-flag" + } + }, + "LdpNeighborView" : { + "fields" : { + "label_space_id" : "ldp-label-space-id", + "hello_flags" : "_LdpNeighborHelloFlagsTable", + "proposed_local_holdtime" : "ldp-proposed-local-holdtime", + "reference_count" : "ldp-reference-count", + "neighbor_address" : "ldp-neighbor-address", + "proposed_peer_holdtime" : "ldp-proposed-peer-holdtime", + "hello_interval" : "ldp-hello-interval", + "types" : "_LdpNeighborTypesTable", + "remaining_time" : "ldp-remaining-time", + "interface_name" : "interface-name", + "up_time" : "ldp-up-time", + "holdtime" : "ldp-holdtime", + "config_sequence" : "ldp-config-sequence", + "transport_address" : "ldp-transport-address" + } + }, + "_LdpNeighborHelloFlagsTable" : { + "item" : "ldp-neighbor-hello-flags", + "key" : "ldp-neighbor-hello-flag", + "view" : "_LdpNeighborHelloFlagsView" + }, + "_LdpNeighborTypesTable" : { + "key" : "ldp-neighbor-type", + "view" : "_LdpNeighborTypesView", + "item" : "ldp-neighbor-types" + }, + "_LdpNeighborTypesView" : { + "fields" : { + "type" : "ldp-neighbor-type" + } + }, + "LdpNeighborTable" : { + "item" : "ldp-neighbor", + "args" : { + "extensive" : "True" + }, + "rpc" : "get-ldp-neighbor-information", + "key" : [ + "interface-name", + "ldp-neighbor-address" + ], + "view" : "LdpNeighborView" + } +} diff --git a/lib/jnpr/junos/op/ldp.py b/lib/jnpr/junos/op/ldp.py index c2f88b6a4..df5e43bcf 100644 --- a/lib/jnpr/junos/op/ldp.py +++ b/lib/jnpr/junos/op/ldp.py @@ -1,7 +1,7 @@ """ Pythonifier for LDP Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/ldp.yml b/lib/jnpr/junos/op/ldp.yml deleted file mode 100644 index 77466c3ba..000000000 --- a/lib/jnpr/junos/op/ldp.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -LdpNeighborTable: - rpc: get-ldp-neighbor-information - args: - extensive: True - item: ldp-neighbor - key: - - interface-name - - ldp-neighbor-address - view: LdpNeighborView - -LdpNeighborView: - fields: - interface_name: interface-name - neighbor_address: ldp-neighbor-address - label_space_id: ldp-label-space-id - remaining_time: ldp-remaining-time - transport_address: ldp-transport-address - config_sequence: ldp-config-sequence - up_time: ldp-up-time - reference_count: ldp-reference-count - holdtime: ldp-holdtime - proposed_local_holdtime: ldp-proposed-local-holdtime - proposed_peer_holdtime: ldp-proposed-peer-holdtime - hello_interval: ldp-hello-interval - hello_flags: _LdpNeighborHelloFlagsTable - types: _LdpNeighborTypesTable - -_LdpNeighborHelloFlagsTable: - item: ldp-neighbor-hello-flags - key: ldp-neighbor-hello-flag - view: _LdpNeighborHelloFlagsView - -_LdpNeighborHelloFlagsView: - fields: - flag: ldp-neighbor-hello-flag - -_LdpNeighborTypesTable: - item: ldp-neighbor-types - key: ldp-neighbor-type - view: _LdpNeighborTypesView - -_LdpNeighborTypesView: - fields: - type: ldp-neighbor-type diff --git a/lib/jnpr/junos/op/lldp.json b/lib/jnpr/junos/op/lldp.json new file mode 100644 index 000000000..61243f1e5 --- /dev/null +++ b/lib/jnpr/junos/op/lldp.json @@ -0,0 +1,19 @@ +{ + "LLDPNeighborTable" : { + "view" : "LLDPNeighborView", + "rpc" : "get-lldp-neighbors-information", + "key" : "lldp-local-interface | lldp-local-port-id", + "item" : "lldp-neighbor-information" + }, + "LLDPNeighborView" : { + "fields" : { + "remote_sysname" : "lldp-remote-system-name", + "remote_chassis_id" : "lldp-remote-chassis-id", + "remote_type" : "lldp-remote-chassis-id-subtype", + "remote_port_desc" : "lldp-remote-port-description", + "local_parent" : "lldp-local-parent-interface-name", + "remote_port_id" : "lldp-remote-port-id", + "local_int" : "lldp-local-interface | lldp-local-port-id" + } + } +} diff --git a/lib/jnpr/junos/op/lldp.py b/lib/jnpr/junos/op/lldp.py index a1854eee2..e1a6c84bb 100644 --- a/lib/jnpr/junos/op/lldp.py +++ b/lib/jnpr/junos/op/lldp.py @@ -1,7 +1,7 @@ """ Pythonifier for LLDP Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/lldp.yml b/lib/jnpr/junos/op/lldp.yml deleted file mode 100644 index 04b694c90..000000000 --- a/lib/jnpr/junos/op/lldp.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -LLDPNeighborTable: - rpc: get-lldp-neighbors-information - item: lldp-neighbor-information - key: lldp-local-interface | lldp-local-port-id - view: LLDPNeighborView - -LLDPNeighborView: - fields: - local_int: lldp-local-interface | lldp-local-port-id - local_parent: lldp-local-parent-interface-name - remote_type: lldp-remote-chassis-id-subtype - remote_chassis_id: lldp-remote-chassis-id - remote_port_desc: lldp-remote-port-description - remote_port_id: lldp-remote-port-id - remote_sysname: lldp-remote-system-name diff --git a/lib/jnpr/junos/op/nd.json b/lib/jnpr/junos/op/nd.json new file mode 100644 index 000000000..e361e7b74 --- /dev/null +++ b/lib/jnpr/junos/op/nd.json @@ -0,0 +1,16 @@ +{ + "NdTable" : { + "item" : "ipv6-nd-entry", + "view" : "NdView", + "rpc" : "get-ipv6-nd-information", + "key" : "ipv6-nd-neighbor-l2-address" + }, + "NdView" : { + "fields" : { + "ip_address" : "ipv6-nd-neighbor-address", + "mac_address" : "ipv6-nd-neighbor-l2-address", + "router" : "ipv6-nd-isrouter", + "interface_name" : "ipv6-nd-interface-name" + } + } +} diff --git a/lib/jnpr/junos/op/nd.py b/lib/jnpr/junos/op/nd.py index 6e30cc13f..9ad9f9453 100644 --- a/lib/jnpr/junos/op/nd.py +++ b/lib/jnpr/junos/op/nd.py @@ -1,7 +1,7 @@ """ Pythonifier for IPv6 Neighbor Discovery Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/nd.yml b/lib/jnpr/junos/op/nd.yml deleted file mode 100644 index 35a8e9eb9..000000000 --- a/lib/jnpr/junos/op/nd.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -NdTable: - rpc: get-ipv6-nd-information - item: ipv6-nd-entry - key: ipv6-nd-neighbor-l2-address - view: NdView - -NdView: - fields: - mac_address: ipv6-nd-neighbor-l2-address - ip_address: ipv6-nd-neighbor-address - interface_name: ipv6-nd-interface-name - router: ipv6-nd-isrouter diff --git a/lib/jnpr/junos/op/ospf.json b/lib/jnpr/junos/op/ospf.json new file mode 100644 index 000000000..fca78026c --- /dev/null +++ b/lib/jnpr/junos/op/ospf.json @@ -0,0 +1,66 @@ +{ + "OspfInterfaceView" : { + "fields" : { + "neighbor_count" : "neighbor-count", + "ospf_interface_state" : "ospf-interface-state", + "interface_name" : "interface-name" + } + }, + "ospfTable" : { + "rpc" : "get-ospf-overview-information", + "view" : "ospfView", + "key" : "ospf-area-overview/ospf-area", + "item" : "ospf-overview" + }, + "OspfRoutesTable" : { + "rpc" : "get-ospf-route-information", + "key" : "ospf-route-entry/address-prefix", + "view" : "OspfRoutesView", + "item" : "ospf-topology-route-table/ospf-route" + }, + "OspfNeighborView" : { + "fields" : { + "ospf_neighbor_state" : "ospf-neighbor-state", + "neighbor_id" : "neighbor-id", + "interface_name" : "interface-name", + "neighbor_up_time" : "neighbor-up-time", + "activity_timer" : "activity-timer", + "neighbor_adjacency_time" : "neighbor-adjacency-time", + "ospf_area" : "ospf-area", + "dr_address" : "dr-address", + "bdr_address" : "bdr-address", + "neighbor_address" : "neighbor-address" + } + }, + "OspfNeighborTable" : { + "args" : { + "extensive" : "True" + }, + "item" : "ospf-neighbor", + "view" : "OspfNeighborView", + "key" : [ + "interface-name", + "neighbor-id" + ], + "rpc" : "get-ospf-neighbor-information" + }, + "ospfView" : { + "fields" : { + "router_id" : "ospf-router-id", + "neighbors" : "ospf-area-overview/ospf-nbr-up-count", + "area" : "ospf-area-overview/ospf-area" + } + }, + "OspfRoutesView" : { + "fields" : { + "interface" : "ospf-route-entry/ospf-next-hop/next-hop-name/interface-name", + "prefix" : "ospf-route-entry/address-prefix" + } + }, + "OspfInterfaceTable" : { + "item" : "ospf-interface", + "rpc" : "get-ospf-interface-information", + "key" : "interface-name", + "view" : "OspfInterfaceView" + } +} diff --git a/lib/jnpr/junos/op/ospf.py b/lib/jnpr/junos/op/ospf.py index 5707100f3..c57a4f6e8 100644 --- a/lib/jnpr/junos/op/ospf.py +++ b/lib/jnpr/junos/op/ospf.py @@ -1,7 +1,7 @@ """ Pythonifier for OSPF Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/ospf.yml b/lib/jnpr/junos/op/ospf.yml deleted file mode 100644 index 100b95189..000000000 --- a/lib/jnpr/junos/op/ospf.yml +++ /dev/null @@ -1,58 +0,0 @@ -OspfNeighborTable: - rpc: get-ospf-neighbor-information - args: - extensive: True - item: ospf-neighbor - key: - - interface-name - - neighbor-id - view: OspfNeighborView - -OspfNeighborView: - fields: - neighbor_address: neighbor-address - interface_name: interface-name - ospf_neighbor_state: ospf-neighbor-state - neighbor_id: neighbor-id - activity_timer: activity-timer - ospf_area: ospf-area - dr_address: dr-address - bdr_address: bdr-address - neighbor_up_time: neighbor-up-time - neighbor_adjacency_time: neighbor-adjacency-time - -OspfInterfaceTable: - rpc: get-ospf-interface-information - item: ospf-interface - key: interface-name - view: OspfInterfaceView - -OspfInterfaceView: - fields: - interface_name: interface-name - ospf_interface_state: ospf-interface-state - neighbor_count: neighbor-count - -ospfTable: - rpc: get-ospf-overview-information - item: ospf-overview - key: ospf-area-overview/ospf-area - view: ospfView - -ospfView: - fields: - router_id: ospf-router-id - area: ospf-area-overview/ospf-area - neighbors: ospf-area-overview/ospf-nbr-up-count - - -OspfRoutesTable: - rpc: get-ospf-route-information - item: ospf-topology-route-table/ospf-route - key: ospf-route-entry/address-prefix - view: OspfRoutesView - -OspfRoutesView: - fields: - prefix: ospf-route-entry/address-prefix - interface: ospf-route-entry/ospf-next-hop/next-hop-name/interface-name diff --git a/lib/jnpr/junos/op/phyport.json b/lib/jnpr/junos/op/phyport.json new file mode 100644 index 000000000..4ef4b88ea --- /dev/null +++ b/lib/jnpr/junos/op/phyport.json @@ -0,0 +1,155 @@ +{ + "PhyPortTable" : { + "rpc" : "get-interface-information", + "view" : "PhyPortView", + "args" : { + "interface_name" : "[efgx][et]-*" + }, + "item" : "physical-interface", + "args_key" : "interface_name" + }, + "PhyPortErrorView" : { + "fields_rxerrs" : { + "rx_err_frame" : { + "framing-errors" : "int" + }, + "rx_err_discards" : { + "input-discards" : "int" + }, + "rx_err_fifo" : { + "input-fifo-errors" : "int" + }, + "rx_err_l2-mismatch" : { + "input-l2-mismatch-timeouts" : "int" + }, + "rx_err_resource" : { + "input-resource-errors" : "int" + }, + "rx_err_l3-incompletes" : { + "input-l3-incompletes" : "int" + }, + "rx_err_drops" : { + "input-drops" : "int" + }, + "rx_err_input" : { + "input-errors" : "int" + }, + "rx_err_runts" : { + "input-runts" : "int" + }, + "rx_err_l2-channel" : { + "input-l2-channel-errors" : "int" + } + }, + "fields_ts" : { + "rx_packets" : { + "input-packets" : "int" + }, + "tx_packets" : { + "output-packets" : "int" + }, + "rx_bytes" : { + "input-bytes" : "int" + }, + "tx_bytes" : { + "output-bytes" : "int" + } + }, + "groups" : { + "ts" : "traffic-statistics", + "txerrs" : "output-error-list", + "rxerrs" : "input-error-list" + }, + "fields_txerrs" : { + "tx_err_fifo" : { + "output-fifo-errors" : "int" + }, + "tx_err_aged" : { + "aged-packets" : "int" + }, + "tx_err_drops" : { + "output-drops" : "int" + }, + "tx_err_output" : { + "output-errors" : "int" + }, + "tx_err_collisions" : { + "output-collisions" : "int" + }, + "tx_err_hs-crc" : { + "hs-link-crc-errors" : "int" + }, + "tx_err_mtu" : { + "mtu-errors" : "int" + }, + "tx_err_carrier-transitions" : { + "carrier-transitions" : "int" + }, + "tx_err_resource" : { + "output-resource-errors" : "int" + } + } + }, + "PhyPortStatsView" : { + "fields_rxerrs" : { + "rx_err_drops" : { + "input-drops" : "int" + }, + "rx_err_input" : { + "input-errors" : "int" + } + }, + "fields_ts" : { + "rx_bytes" : { + "input-bytes" : "int" + }, + "tx_bytes" : { + "output-bytes" : "int" + }, + "rx_packets" : { + "input-packets" : "int" + }, + "tx_packets" : { + "output-packets" : "int" + } + }, + "groups" : { + "ts" : "traffic-statistics", + "rxerrs" : "input-error-list" + } + }, + "PhyPortStatsTable" : { + "args_key" : "interface_name", + "item" : "physical-interface", + "rpc" : "get-interface-information", + "view" : "PhyPortStatsView", + "args" : { + "extensive" : "True", + "interface_name" : "[efgx][et]-*" + } + }, + "PhyPortErrorTable" : { + "args" : { + "extensive" : "True", + "interface_name" : "[efgx][et]-*" + }, + "view" : "PhyPortErrorView", + "rpc" : "get-interface-information", + "args_key" : "interface_name", + "item" : "physical-interface" + }, + "PhyPortView" : { + "fields" : { + "admin" : "admin-status", + "link_mode" : "link-mode", + "oper" : "oper-status", + "description" : "description", + "flapped" : "interface-flapped", + "speed" : "speed", + "macaddr" : "current-physical-address", + "mtu" : { + "mtu" : "int" + } + } + } +} diff --git a/lib/jnpr/junos/op/phyport.py b/lib/jnpr/junos/op/phyport.py index 09e668cdd..3419a3888 100644 --- a/lib/jnpr/junos/op/phyport.py +++ b/lib/jnpr/junos/op/phyport.py @@ -1,7 +1,7 @@ """ Pythonifier for PhyPort Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/phyport.yml b/lib/jnpr/junos/op/phyport.yml deleted file mode 100644 index da37bc737..000000000 --- a/lib/jnpr/junos/op/phyport.yml +++ /dev/null @@ -1,97 +0,0 @@ ---- -PhyPortTable: - rpc: get-interface-information - args: - interface_name: '[efgx][et]-*' - args_key: interface_name - item: physical-interface - view: PhyPortView - -PhyPortView: - fields: - oper : oper-status - admin : admin-status - description: description - mtu: { mtu : int } - link_mode: link-mode - speed: speed - macaddr: current-physical-address - flapped: interface-flapped - -### --------------------------------------------------------------------------- -### get extensive information -### --------------------------------------------------------------------------- - -PhyPortStatsTable: - rpc: get-interface-information - args: - extensive: True - interface_name: '[efgx][et]-*' - args_key: interface_name - item: physical-interface - view: PhyPortStatsView - -PhyPortStatsView: - groups: - ts: traffic-statistics - rxerrs: input-error-list - - # fields that are part of groups are called - # "fields_" - - fields_ts: - rx_bytes: { input-bytes: int } - rx_packets: { input-packets: int } - tx_bytes: { output-bytes: int } - tx_packets: { output-packets: int } - - fields_rxerrs: - rx_err_input: { input-errors: int } - rx_err_drops: { input-drops: int } - -PhyPortErrorTable: - rpc: get-interface-information - args: - extensive: True - interface_name: '[efgx][et]-*' - args_key: interface_name - item: physical-interface - view: PhyPortErrorView - -PhyPortErrorView: - groups: - ts: traffic-statistics - rxerrs: input-error-list - txerrs: output-error-list - - # fields that are part of groups are called - # "fields_" - - fields_ts: - rx_bytes: { input-bytes: int } - rx_packets: { input-packets: int } - tx_bytes: { output-bytes: int } - tx_packets: { output-packets: int } - - fields_rxerrs: - rx_err_input: { input-errors: int } - rx_err_drops: { input-drops: int } - rx_err_frame: { framing-errors: int } - rx_err_runts: { input-runts: int } - rx_err_discards: { input-discards: int } - rx_err_l3-incompletes: { input-l3-incompletes: int } - rx_err_l2-channel: { input-l2-channel-errors: int } - rx_err_l2-mismatch: { input-l2-mismatch-timeouts: int } - rx_err_fifo: { input-fifo-errors: int } - rx_err_resource: { input-resource-errors: int } - - fields_txerrs: - tx_err_carrier-transitions: { carrier-transitions: int } - tx_err_output: { output-errors: int } - tx_err_collisions: { output-collisions: int } - tx_err_drops: { output-drops: int } - tx_err_aged: { aged-packets: int } - tx_err_mtu: { mtu-errors: int } - tx_err_hs-crc: { hs-link-crc-errors: int } - tx_err_fifo: { output-fifo-errors: int } - tx_err_resource: { output-resource-errors: int } diff --git a/lib/jnpr/junos/op/routes.json b/lib/jnpr/junos/op/routes.json new file mode 100644 index 000000000..71c81d321 --- /dev/null +++ b/lib/jnpr/junos/op/routes.json @@ -0,0 +1,63 @@ +{ + "RouteSummaryTable" : { + "rpc" : "get-route-summary-information", + "key" : "table-name", + "item" : "route-table", + "view" : "RouteSummaryView" + }, + "RouteTableView" : { + "groups" : { + "entry" : "rt-entry" + }, + "fields_entry" : { + "via" : "nh/via | nh/nh-local-interface", + "protocol" : "protocol-name", + "age" : { + "age/@seconds" : "int" + }, + "nexthop" : "nh/to" + } + }, + "_rspView" : { + "fields" : { + "count" : { + "protocol-route-count" : "int" + }, + "active" : { + "active-route-count" : "int" + } + } + }, + "RouteSummaryView" : { + "fields" : { + "proto" : "_rspTable", + "holddown" : { + "holddown-route-count" : "int" + }, + "total" : { + "total-route-count" : "int" + }, + "active" : { + "active-route-count" : "int" + }, + "hidden" : { + "hidden-route-count" : "int" + }, + "dests" : { + "destination-count" : "int" + } + } + }, + "RouteTable" : { + "args_key" : "destination", + "key" : "rt-destination", + "rpc" : "get-route-information", + "view" : "RouteTableView", + "item" : "route-table/rt" + }, + "_rspTable" : { + "key" : "protocol-name", + "item" : "protocols", + "view" : "_rspView" + } +} diff --git a/lib/jnpr/junos/op/routes.py b/lib/jnpr/junos/op/routes.py index 22554b24f..c5bf045af 100644 --- a/lib/jnpr/junos/op/routes.py +++ b/lib/jnpr/junos/op/routes.py @@ -1,7 +1,7 @@ """ Pythonifier for Route Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/routes.yml b/lib/jnpr/junos/op/routes.yml deleted file mode 100644 index d479453bd..000000000 --- a/lib/jnpr/junos/op/routes.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- - -### ------------------------------------------------------ -### show route -### ------------------------------------------------------ - -RouteTable: - rpc: get-route-information - args_key: destination - item: route-table/rt - key: rt-destination - view: RouteTableView - -RouteTableView: - groups: - entry: rt-entry - fields_entry: - # fields taken from the group 'entry' - protocol: protocol-name - via: nh/via | nh/nh-local-interface - age: { age/@seconds : int } - nexthop: nh/to - -### ------------------------------------------------------ -### show route summary -### ------------------------------------------------------ - -RouteSummaryTable: - rpc: get-route-summary-information - item: route-table - key: table-name - view: RouteSummaryView - -RouteSummaryView: - fields: - dests: { destination-count : int } - total: { total-route-count : int } - active: { active-route-count : int } - holddown: { holddown-route-count : int } - hidden: { hidden-route-count : int } - proto: _rspTable - -_rspTable: - item: protocols - key: protocol-name - view: _rspView - -_rspView: - fields: - count: { protocol-route-count: int } - active: { active-route-count : int } diff --git a/lib/jnpr/junos/op/teddb.json b/lib/jnpr/junos/op/teddb.json new file mode 100644 index 000000000..a22e79d8b --- /dev/null +++ b/lib/jnpr/junos/op/teddb.json @@ -0,0 +1,64 @@ +{ + "TedTable" : { + "args" : { + "extensive" : "True" + }, + "rpc" : "get-ted-database-information", + "key" : "ted-database-id", + "view" : "TedView", + "item" : "ted-database" + }, + "_linkView" : { + "fields" : { + "remoteRTR" : "ted-link-to", + "metric" : { + "ted-link-metric" : "int" + }, + "localIfI" : { + "ted-link-local-ifindex" : "int" + }, + "remoteIfI" : { + "ted-link-remote-ifindex" : "int" + }, + "color" : "admin-groups/color", + "remoteADD" : "ted-link-remote-address", + "localADD" : "ted-link-local-address" + } + }, + "TedSummaryView" : { + "fields" : { + "inet-count" : { + "ted-database-inet-count" : "int" + }, + "iso-count" : { + "ted-database-iso-count" : "int" + } + } + }, + "TedSummaryTable" : { + "item" : "ted-database-summary", + "rpc" : "get-ted-database-information", + "view" : "TedSummaryView" + }, + "_linkTable" : { + "view" : "_linkView", + "key" : "ted-link-local-ifindex", + "item" : "ted-link" + }, + "TedView" : { + "fields" : { + "link" : "_linkTable", + "type" : "ted-database-type", + "age" : { + "ted-database-age" : "int" + }, + "link-in" : { + "ted-database-link-in" : "int" + }, + "link-out" : { + "ted-database-link-out" : "int" + }, + "protocol" : "ted-database-protocol" + } + } +} diff --git a/lib/jnpr/junos/op/teddb.py b/lib/jnpr/junos/op/teddb.py index b490ec4a2..ceffb99d2 100644 --- a/lib/jnpr/junos/op/teddb.py +++ b/lib/jnpr/junos/op/teddb.py @@ -1,7 +1,7 @@ """ Pythonifier for ted database Table/View """ -from ..factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/teddb.yml b/lib/jnpr/junos/op/teddb.yml deleted file mode 100644 index be4db472d..000000000 --- a/lib/jnpr/junos/op/teddb.yml +++ /dev/null @@ -1,46 +0,0 @@ -### ------------------------------------------------------ -#### show ted database -#### ------------------------------------------------------ - -TedTable: - rpc: get-ted-database-information - args: - extensive: True - item: ted-database - key: ted-database-id - view: TedView - -TedView: - fields: - type: ted-database-type - age: { ted-database-age : int } - link-in: { ted-database-link-in : int } - link-out: { ted-database-link-out : int } - protocol: ted-database-protocol - link: _linkTable - -_linkTable: - item: ted-link - key: ted-link-local-ifindex - view: _linkView - -_linkView: - fields: - remoteRTR: ted-link-to - remoteIfI: { ted-link-remote-ifindex : int } - remoteADD: ted-link-remote-address - localIfI: { ted-link-local-ifindex : int } - localADD: ted-link-local-address - metric: { ted-link-metric : int } - color: admin-groups/color - - -TedSummaryTable: - rpc: get-ted-database-information - item: ted-database-summary - view: TedSummaryView - -TedSummaryView: - fields: - iso-count: { ted-database-iso-count : int } - inet-count: { ted-database-inet-count : int } diff --git a/lib/jnpr/junos/op/vlan.json b/lib/jnpr/junos/op/vlan.json new file mode 100644 index 000000000..e8b2d3f37 --- /dev/null +++ b/lib/jnpr/junos/op/vlan.json @@ -0,0 +1,19 @@ +{ + "VlanTable" : { + "rpc" : "get-vlan-information", + "view" : "VlanView", + "key" : "vlan-name", + "item" : "vlan" + }, + "VlanView" : { + "fields" : { + "instance" : "vlan-instance", + "owner" : "vlan-owner", + "name" : "vlan-name", + "created" : "vlan-create-time", + "status" : "vlan-status", + "members" : ".//vlan-member-interface", + "tag" : "vlan-tag" + } + } +} diff --git a/lib/jnpr/junos/op/vlan.py b/lib/jnpr/junos/op/vlan.py index 6ebecb0ef..e7319623f 100644 --- a/lib/jnpr/junos/op/vlan.py +++ b/lib/jnpr/junos/op/vlan.py @@ -1,7 +1,7 @@ """ Pythonifier for Vlan Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/vlan.yml b/lib/jnpr/junos/op/vlan.yml deleted file mode 100644 index d34ed5c81..000000000 --- a/lib/jnpr/junos/op/vlan.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -VlanTable: - rpc: get-vlan-information - item: vlan - key: vlan-name - view: VlanView - -VlanView: - fields: - instance: vlan-instance - name: vlan-name - created: vlan-create-time - status: vlan-status - owner: vlan-owner - tag: vlan-tag - members: .//vlan-member-interface - diff --git a/lib/jnpr/junos/op/xcvr.json b/lib/jnpr/junos/op/xcvr.json new file mode 100644 index 000000000..d806f61dc --- /dev/null +++ b/lib/jnpr/junos/op/xcvr.json @@ -0,0 +1,20 @@ +{ + "XcvrTable" : { + "rpc" : "get-chassis-inventory", + "view" : "XcvrTableView", + "key" : [ + "ancestor::*[starts-with(name,'FPC')]/name", + "ancestor::*[starts-with(name,'PIC')]/name", + "name" + ], + "item" : "//*[starts-with(name,\"Xcvr\")]" + }, + "XcvrTableView" : { + "fields" : { + "ver" : "version", + "sn" : "serial-number", + "type" : "description", + "pn" : "part-number" + } + } +} diff --git a/lib/jnpr/junos/op/xcvr.py b/lib/jnpr/junos/op/xcvr.py index 54d48256d..1dbdb9d1b 100644 --- a/lib/jnpr/junos/op/xcvr.py +++ b/lib/jnpr/junos/op/xcvr.py @@ -1,7 +1,7 @@ """ Pythonifier for Xcvr Table/View """ -from jnpr.junos.factory import loadyaml -from os.path import splitext -_YAML_ = splitext(__file__)[0] + '.yml' -globals().update(loadyaml(_YAML_)) +import jnpr.junos.factory +import os +_PATH_ = os.path.splitext(__file__)[0] +globals().update(jnpr.junos.factory.load(_PATH_) diff --git a/lib/jnpr/junos/op/xcvr.yml b/lib/jnpr/junos/op/xcvr.yml deleted file mode 100644 index 6a738a4c9..000000000 --- a/lib/jnpr/junos/op/xcvr.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -XcvrTable: - rpc: get-chassis-inventory - item: //*[starts-with(name,"Xcvr")] - key: - - ancestor::*[starts-with(name,'FPC')]/name - - ancestor::*[starts-with(name,'PIC')]/name - - name - view: XcvrTableView - -XcvrTableView: - fields: - sn: serial-number - pn: part-number - ver: version - type: description diff --git a/lib/jnpr/junos/resources/autosys.json b/lib/jnpr/junos/resources/autosys.json new file mode 100644 index 000000000..c1c1a2b20 --- /dev/null +++ b/lib/jnpr/junos/resources/autosys.json @@ -0,0 +1,14 @@ +{ + "AutoSysTable" : { + "key-field" : [ + "as_num" + ], + "view" : "AutoSysView", + "set" : "routing-options/autonomous-system" + }, + "AutoSysView" : { + "fields" : { + "as_num" : "as-number" + } + } +} diff --git a/lib/jnpr/junos/resources/autosys.yml b/lib/jnpr/junos/resources/autosys.yml deleted file mode 100644 index c856c3fff..000000000 --- a/lib/jnpr/junos/resources/autosys.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -### ------------------------------------------------------ -### Table-view to configure Autonomous system. -### ------------------------------------------------------ -AutoSysTable: - set: routing-options/autonomous-system - key-field: - - as_num - view: AutoSysView -AutoSysView: - fields: - as_num: as-number \ No newline at end of file diff --git a/lib/jnpr/junos/resources/bgp.json b/lib/jnpr/junos/resources/bgp.json new file mode 100644 index 000000000..be43aea8e --- /dev/null +++ b/lib/jnpr/junos/resources/bgp.json @@ -0,0 +1,42 @@ +{ + "BgpView" : { + "fields_neigh" : { + "neigh_addr" : "name" + }, + "fields" : { + "peer" : { + "peer-as" : { + "type" : "int" + } + }, + "bgp_name" : { + "name" : { + "minValue" : "1", + "maxValue" : "255", + "type" : "str" + } + }, + "local_addr" : "local-address", + "bgp_type" : { + "type" : { + "type" : { + "enum" : [ + "external", + "internal" + ] + } + } + } + }, + "groups" : { + "neigh" : "neighbor" + } + }, + "BgpTable" : { + "view" : "BgpView", + "set" : "protocols/bgp/group", + "key-field" : [ + "bgp_name" + ] + } +} diff --git a/lib/jnpr/junos/resources/bgp.yml b/lib/jnpr/junos/resources/bgp.yml deleted file mode 100644 index 854ebe2e7..000000000 --- a/lib/jnpr/junos/resources/bgp.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -### ------------------------------------------------------ -### Table-view to configure BGP. -### ------------------------------------------------------ -BgpTable: - set: protocols/bgp/group - key-field: - - bgp_name - view: BgpView -BgpView: - groups: - neigh : neighbor - fields: - bgp_name : { 'name' : { 'type' : 'str', 'minValue' : 1, 'maxValue' : 255} } - bgp_type : {'type' : {'type': { 'enum': ['external', 'internal'] } } } - local_addr : local-address - peer : { 'peer-as' : { 'type' : 'int' } } - fields_neigh: - neigh_addr : name \ No newline at end of file diff --git a/lib/jnpr/junos/resources/interface.json b/lib/jnpr/junos/resources/interface.json new file mode 100644 index 000000000..c026cc75c --- /dev/null +++ b/lib/jnpr/junos/resources/interface.json @@ -0,0 +1,34 @@ +{ + "InterfaceTable" : { + "key-field" : [ + "name", + "unit_name" + ], + "view" : "InterfaceView", + "set" : "interfaces/interface" + }, + "InterfaceView" : { + "groups" : { + "unit" : "unit", + "bridge" : "unit/family/bridge" + }, + "fields" : { + "name" : "name", + "native_vlan" : "native-vlan-id", + "disable" : { + "disable" : { + "type" : "bool" + } + }, + "enc" : "encapsulation" + }, + "fields_unit" : { + "desc" : "description", + "unit_name" : "name" + }, + "fields_bridge" : { + "vlan_list" : "vlan-id-list", + "mode" : "interface-mode" + } + } +} diff --git a/lib/jnpr/junos/resources/interface.yml b/lib/jnpr/junos/resources/interface.yml deleted file mode 100644 index 18b35a110..000000000 --- a/lib/jnpr/junos/resources/interface.yml +++ /dev/null @@ -1,22 +0,0 @@ -InterfaceTable: - set: interfaces/interface - key-field: - - name - - unit_name - view: InterfaceView - -InterfaceView: - groups: - unit: unit - bridge: unit/family/bridge - fields: - name: name - disable: { 'disable' : { 'type': 'bool' } } - enc : encapsulation - native_vlan: native-vlan-id - fields_unit: - unit_name : name - desc : description - fields_bridge: - mode: interface-mode - vlan_list: vlan-id-list \ No newline at end of file diff --git a/lib/jnpr/junos/resources/staticroutes.json b/lib/jnpr/junos/resources/staticroutes.json new file mode 100644 index 000000000..bc0b1c086 --- /dev/null +++ b/lib/jnpr/junos/resources/staticroutes.json @@ -0,0 +1,15 @@ +{ + "StaticRouteTable" : { + "key-field" : [ + "route_name" + ], + "set" : "routing-options/static/route", + "view" : "StaticRouteView" + }, + "StaticRouteView" : { + "fields" : { + "hop" : "next-hop", + "route_name" : "name" + } + } +} diff --git a/lib/jnpr/junos/resources/staticroutes.yml b/lib/jnpr/junos/resources/staticroutes.yml deleted file mode 100644 index 6cffccb01..000000000 --- a/lib/jnpr/junos/resources/staticroutes.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -### ------------------------------------------------------ -### Table-view to configure Static routes. -### ------------------------------------------------------ -StaticRouteTable: - set: routing-options/static/route - key-field: - - route_name - view: StaticRouteView - -StaticRouteView: - fields: - route_name: name - hop: next-hop \ No newline at end of file diff --git a/lib/jnpr/junos/resources/syslog.json b/lib/jnpr/junos/resources/syslog.json new file mode 100644 index 000000000..e4a869731 --- /dev/null +++ b/lib/jnpr/junos/resources/syslog.json @@ -0,0 +1,27 @@ +{ + "SyslogView" : { + "fields" : { + "name" : { + "name" : { + "default" : "messages" + } + } + }, + "groups" : { + "contents" : "contents" + }, + "fields_contents" : { + "error" : "error", + "contents_name" : "name", + "info" : "info" + } + }, + "SyslogTable" : { + "key-field" : [ + "name", + "contents_name" + ], + "view" : "SyslogView", + "set" : "system/syslog/file" + } +} diff --git a/lib/jnpr/junos/resources/syslog.yml b/lib/jnpr/junos/resources/syslog.yml deleted file mode 100644 index c7c624e7b..000000000 --- a/lib/jnpr/junos/resources/syslog.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -### ------------------------------------------------------ -### Table-view to configure Syslog. -### ------------------------------------------------------ -SyslogTable: - set: system/syslog/file - key-field: - - name - - contents_name - view: SyslogView -SyslogView: - groups: - contents: contents - fields: - name : { 'name' : { 'default' : 'messages' } } - fields_contents: - info : info - contents_name : name - error : error \ No newline at end of file diff --git a/lib/jnpr/junos/resources/user.json b/lib/jnpr/junos/resources/user.json new file mode 100644 index 000000000..d217e2b96 --- /dev/null +++ b/lib/jnpr/junos/resources/user.json @@ -0,0 +1,36 @@ +{ + "UserTable" : { + "key-field" : "user", + "view" : "userView", + "set" : "system/login/user" + }, + "userView" : { + "groups" : { + "auth" : "authentication" + }, + "fields_auth" : { + "password" : "encrypted-password" + }, + "fields" : { + "uid" : { + "uid" : { + "maxValue" : "64000", + "minValue" : "100", + "type" : "int" + } + }, + "class_name" : { + "class" : { + "type" : { + "enum" : [ + "operator", + "read-only", + "super-user" + ] + } + } + }, + "user" : "name" + } + } +} diff --git a/lib/jnpr/junos/resources/user.yml b/lib/jnpr/junos/resources/user.yml deleted file mode 100644 index 4da2c278f..000000000 --- a/lib/jnpr/junos/resources/user.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -### ------------------------------------------------------ -### Table-view to configure login user. -### ------------------------------------------------------ -UserTable: - set: system/login/user - key-field: user - view: userView - -userView: - groups: - auth: authentication - fields: - user: name - uid: { uid : { 'type' : 'int', 'minValue' : 100, 'maxValue' : 64000 } } - class_name: { class : { 'type' : { 'enum' : ['operator', 'read-only', 'super-user'] } } } - fields_auth: - password: encrypted-password \ No newline at end of file