diff --git a/interactive_demo/tutorial.ipynb b/interactive_demo/tutorial.ipynb index fee5449b..305b0ca5 100644 --- a/interactive_demo/tutorial.ipynb +++ b/interactive_demo/tutorial.ipynb @@ -1479,7 +1479,7 @@ "\n", "running_config = napalm_yang.base.Root()\n", "running_config.add_model(napalm_yang.models.openconfig_interfaces)\n", - "running_config.parse_config(config=config, profile=[\"junos\"])\n", + "running_config.parse_config(native=[config], profile=[\"junos\"])\n", "\n", "pretty_print(running_config.get(filter=True))" ] @@ -1805,6 +1805,7 @@ " \n", " \n", " \n", + " \n", " ae0.1\n", " \n", " \n", @@ -1968,6 +1969,7 @@ " \n", " \n", " \n", + " \n", " ae0.1\n", " \n", " \n", @@ -2352,6 +2354,568 @@ "* \"Replace\" configuration. This one allows you to fully control the configuration. If you can use this, it means you dictate the fate of your network and not the other way around." ] }, + { + "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true, + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "# Getting state\n", + "\n", + "Getting state from a device works pretty much like getting configuration." + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false, + "deletable": true, + "editable": true, + "slideshow": { + "slide_type": "fragment" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"interfaces\": {\n", + " \"interface\": {\n", + " \".local.\": {\n", + " \"name\": \".local.\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 0, \n", + " \"last-change\": 0, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"softwareLoopback\"\n", + " }, \n", + " \"subinterfaces\": {\n", + " \"subinterface\": {\n", + " \".local..0\": {\n", + " \"index\": \".local..0\", \n", + " \"state\": {\n", + " \"ifindex\": 0, \n", + " \"name\": \".local..0\"\n", + " }\n", + " }, \n", + " \".local..1\": {\n", + " \"index\": \".local..1\", \n", + " \"state\": {\n", + " \"ifindex\": 0, \n", + " \"name\": \".local..1\"\n", + " }\n", + " }, \n", + " \".local..2\": {\n", + " \"index\": \".local..2\", \n", + " \"state\": {\n", + " \"ifindex\": 0, \n", + " \"name\": \".local..2\"\n", + " }\n", + " }, \n", + " \".local..3\": {\n", + " \"index\": \".local..3\", \n", + " \"state\": {\n", + " \"ifindex\": 0, \n", + " \"name\": \".local..3\"\n", + " }\n", + " }, \n", + " \".local..4\": {\n", + " \"index\": \".local..4\", \n", + " \"state\": {\n", + " \"ifindex\": 0, \n", + " \"name\": \".local..4\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }, \n", + " \"ae0\": {\n", + " \"name\": \"ae0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 531, \n", + " \"last-change\": 254456, \n", + " \"mtu\": 1518, \n", + " \"oper-status\": \"DOWN\"\n", + " }, \n", + " \"subinterfaces\": {\n", + " \"subinterface\": {\n", + " \"ae0.0\": {\n", + " \"index\": \"ae0.0\", \n", + " \"state\": {\n", + " \"description\": \"ASDASDASD\", \n", + " \"ifindex\": 532, \n", + " \"name\": \"ae0.0\"\n", + " }\n", + " }, \n", + " \"ae0.1\": {\n", + " \"index\": \"ae0.1\", \n", + " \"state\": {\n", + " \"description\": \"ae0.1\", \n", + " \"ifindex\": 533, \n", + " \"name\": \"ae0.1\"\n", + " }\n", + " }, \n", + " \"ae0.2\": {\n", + " \"index\": \"ae0.2\", \n", + " \"state\": {\n", + " \"description\": \"ae0.2\", \n", + " \"ifindex\": 534, \n", + " \"name\": \"ae0.2\"\n", + " }\n", + " }, \n", + " \"ae0.32767\": {\n", + " \"index\": \"ae0.32767\", \n", + " \"state\": {\n", + " \"ifindex\": 535, \n", + " \"name\": \"ae0.32767\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }, \n", + " \"dsc\": {\n", + " \"name\": \"dsc\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 5, \n", + " \"last-change\": 0, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"ge-0/0/0\": {\n", + " \"name\": \"ge-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-broadcast-pkts\": 0, \n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"in-multicast-pkts\": 0, \n", + " \"in-unicast-pkts\": 15740, \n", + " \"out-broadcast-pkts\": 0, \n", + " \"out-errors\": 0, \n", + " \"out-multicast-pkts\": 0, \n", + " \"out-unicast-pkts\": 14704\n", + " }, \n", + " \"description\": \"management interface\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 507, \n", + " \"last-change\": 257720, \n", + " \"mtu\": 1400, \n", + " \"oper-status\": \"UP\"\n", + " }, \n", + " \"subinterfaces\": {\n", + " \"subinterface\": {\n", + " \"ge-0/0/0.0\": {\n", + " \"index\": \"ge-0/0/0.0\", \n", + " \"state\": {\n", + " \"description\": \"ge-0/0/0.0\", \n", + " \"ifindex\": 521, \n", + " \"name\": \"ge-0/0/0.0\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }, \n", + " \"ge-0/0/1\": {\n", + " \"name\": \"ge-0/0/1\", \n", + " \"state\": {\n", + " \"admin-status\": \"DOWN\", \n", + " \"counters\": {\n", + " \"in-broadcast-pkts\": 0, \n", + " \"in-discards\": 1, \n", + " \"in-errors\": 0, \n", + " \"in-multicast-pkts\": 0, \n", + " \"in-unicast-pkts\": 2931, \n", + " \"out-broadcast-pkts\": 0, \n", + " \"out-errors\": 0, \n", + " \"out-multicast-pkts\": 0, \n", + " \"out-unicast-pkts\": 0\n", + " }, \n", + " \"description\": \"ge-0/0/1\", \n", + " \"enabled\": False, \n", + " \"ifindex\": 508, \n", + " \"last-change\": 254454, \n", + " \"mtu\": 1514, \n", + " \"oper-status\": \"DOWN\"\n", + " }\n", + " }, \n", + " \"ge-0/0/2\": {\n", + " \"name\": \"ge-0/0/2\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-broadcast-pkts\": 0, \n", + " \"in-discards\": 2, \n", + " \"in-errors\": 0, \n", + " \"in-multicast-pkts\": 0, \n", + " \"in-unicast-pkts\": 371, \n", + " \"out-broadcast-pkts\": 0, \n", + " \"out-errors\": 0, \n", + " \"out-multicast-pkts\": 0, \n", + " \"out-unicast-pkts\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 509, \n", + " \"last-change\": 257720, \n", + " \"mtu\": 1514, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"gr-0/0/0\": {\n", + " \"name\": \"gr-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 516, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"gre\": {\n", + " \"name\": \"gre\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 8, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"ip-0/0/0\": {\n", + " \"name\": \"ip-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 517, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"ipip\": {\n", + " \"name\": \"ipip\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 9, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"irb\": {\n", + " \"name\": \"irb\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 502, \n", + " \"last-change\": 0, \n", + " \"mtu\": 1514, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"ethernetCsmacd\"\n", + " }\n", + " }, \n", + " \"lo0\": {\n", + " \"name\": \"lo0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"description\": \"lo0\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 6, \n", + " \"last-change\": 0, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"softwareLoopback\"\n", + " }, \n", + " \"subinterfaces\": {\n", + " \"subinterface\": {\n", + " \"lo0.0\": {\n", + " \"index\": \"lo0.0\", \n", + " \"state\": {\n", + " \"description\": \"lo0.0\", \n", + " \"ifindex\": 16, \n", + " \"name\": \"lo0.0\"\n", + " }\n", + " }, \n", + " \"lo0.16384\": {\n", + " \"index\": \"lo0.16384\", \n", + " \"state\": {\n", + " \"ifindex\": 21, \n", + " \"name\": \"lo0.16384\"\n", + " }\n", + " }, \n", + " \"lo0.16385\": {\n", + " \"index\": \"lo0.16385\", \n", + " \"state\": {\n", + " \"ifindex\": 22, \n", + " \"name\": \"lo0.16385\"\n", + " }\n", + " }, \n", + " \"lo0.32768\": {\n", + " \"index\": \"lo0.32768\", \n", + " \"state\": {\n", + " \"ifindex\": 248, \n", + " \"name\": \"lo0.32768\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }, \n", + " \"lsi\": {\n", + " \"name\": \"lsi\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 4, \n", + " \"last-change\": 0, \n", + " \"mtu\": 1496, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"lsq-0/0/0\": {\n", + " \"name\": \"lsq-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 518, \n", + " \"last-change\": 257721, \n", + " \"mtu\": 1504, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"lt-0/0/0\": {\n", + " \"name\": \"lt-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 520, \n", + " \"last-change\": 0, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"mt-0/0/0\": {\n", + " \"name\": \"mt-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 519, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"mtun\": {\n", + " \"name\": \"mtun\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 12, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"pimd\": {\n", + " \"name\": \"pimd\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 11, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"pime\": {\n", + " \"name\": \"pime\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 10, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"pp0\": {\n", + " \"name\": \"pp0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 501, \n", + " \"mtu\": 1532, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"ppd0\": {\n", + " \"name\": \"ppd0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 504, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"ppe0\": {\n", + " \"name\": \"ppe0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 505, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"sp-0/0/0\": {\n", + " \"name\": \"sp-0/0/0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 515, \n", + " \"last-change\": 257721, \n", + " \"mtu\": 9192, \n", + " \"oper-status\": \"UP\"\n", + " }, \n", + " \"subinterfaces\": {\n", + " \"subinterface\": {\n", + " \"sp-0/0/0.0\": {\n", + " \"index\": \"sp-0/0/0.0\", \n", + " \"state\": {\n", + " \"ifindex\": 522, \n", + " \"name\": \"sp-0/0/0.0\"\n", + " }\n", + " }, \n", + " \"sp-0/0/0.16383\": {\n", + " \"index\": \"sp-0/0/0.16383\", \n", + " \"state\": {\n", + " \"ifindex\": 523, \n", + " \"name\": \"sp-0/0/0.16383\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }, \n", + " \"st0\": {\n", + " \"name\": \"st0\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"enabled\": True, \n", + " \"ifindex\": 503, \n", + " \"mtu\": 9192, \n", + " \"oper-status\": \"UP\", \n", + " \"type\": \"tunnel\"\n", + " }\n", + " }, \n", + " \"tap\": {\n", + " \"name\": \"tap\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 7, \n", + " \"last-change\": 0, \n", + " \"oper-status\": \"UP\"\n", + " }\n", + " }, \n", + " \"vlan\": {\n", + " \"name\": \"vlan\", \n", + " \"state\": {\n", + " \"admin-status\": \"UP\", \n", + " \"counters\": {\n", + " \"in-discards\": 0, \n", + " \"in-errors\": 0, \n", + " \"out-errors\": 0\n", + " }, \n", + " \"enabled\": True, \n", + " \"ifindex\": 506, \n", + " \"last-change\": 257729, \n", + " \"mtu\": 1518, \n", + " \"oper-status\": \"DOWN\", \n", + " \"type\": \"l2vlan\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "state = napalm_yang.base.Root()\n", + "state.add_model(napalm_yang.models.openconfig_interfaces)\n", + "\n", + "with junos_device as d:\n", + " state.parse_state(device=d)\n", + "\n", + "pretty_print(state.get(filter=True))" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true, + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "Note that `parse_state` accepts the same parameters as `parse_config` which means you can override profiles or even parse from files." + ] + }, { "cell_type": "markdown", "metadata": { @@ -2369,7 +2933,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 27, "metadata": { "collapsed": false, "deletable": true, @@ -2413,6 +2977,19 @@ "diff = napalm_yang.utils.diff(candidate, running)\n", "pretty_print(diff)" ] + }, + { + "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true, + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "Diff'ing models with state is also supported." + ] } ], "metadata": { diff --git a/napalm_yang/base.py b/napalm_yang/base.py index 266357a4..3f79fa37 100644 --- a/napalm_yang/base.py +++ b/napalm_yang/base.py @@ -133,19 +133,19 @@ def load_dict(self, data, overwrite=False): attr = getattr(self, k) pybindJSONDecoder.load_json(v, None, None, obj=attr, overwrite=overwrite) - def parse_config(self, device=None, profile=None, config=None): + def parse_config(self, device=None, profile=None, native=None): """ Parse native configuration and load it into the corresponding models. Only models that have been added to the root object will be parsed. - If ``config`` is passed to the method that's what we will parse, otherwise, we will use the + If ``native`` is passed to the method that's what we will parse, otherwise, we will use the ``device`` to retrieve it. Args: device (NetworkDriver): Device to load the configuration from. profile (list): Profiles that the device supports. If no ``profile`` is passed it will be read from ``device``. - config (string): Configuration to parse. + native (list of strings): Native configuration to parse. Examples: @@ -160,11 +160,44 @@ def parse_config(self, device=None, profile=None, config=None): >>> >>> running_config = napalm_yang.base.Root() >>> running_config.add_model(napalm_yang.models.openconfig_interfaces) - >>> running_config.parse_config(config=config, profile="junos") + >>> running_config.parse_config(native=config, profile="junos") """ for k, v in self: - parser = Parser(v, device=device, profile=profile, config=config, is_config=True) + parser = Parser(v, device=device, profile=profile, native=native, is_config=True) + parser.parse() + + def parse_state(self, device=None, profile=None, native=None): + """ + Parse native state and load it into the corresponding models. Only models + that have been added to the root object will be parsed. + + If ``native`` is passed to the method that's what we will parse, otherwise, we will use the + ``device`` to retrieve it. + + Args: + device (NetworkDriver): Device to load the configuration from. + profile (list): Profiles that the device supports. If no ``profile`` is passed it will + be read from ``device``. + native (list string): Native output to parse. + + Examples: + + >>> # Load from device + >>> state = napalm_yang.base.Root() + >>> state.add_model(napalm_yang.models.openconfig_interfaces) + >>> state.parse_config(device=d) + + >>> # Load from file + >>> with open("junos.state", "r") as f: + >>> state_data = f.read() + >>> + >>> state = napalm_yang.base.Root() + >>> state.add_model(napalm_yang.models.openconfig_interfaces) + >>> state.parse_config(native=state_data, profile="junos") + """ + for k, v in self: + parser = Parser(v, device=device, profile=profile, native=native, is_config=False) parser.parse() def translate_config(self, profile, merge=None, replace=None): diff --git a/napalm_yang/helpers.py b/napalm_yang/helpers.py index a9a9ab39..c5ca4c18 100644 --- a/napalm_yang/helpers.py +++ b/napalm_yang/helpers.py @@ -56,7 +56,7 @@ def read_yang_map(yang_prefix, attribute, profile, parser_path): try: filepath = find_yang_file(p, filename, parser_path) found = True - logger.debug("Found on profile: {}".format(p)) + logger.debug("Found on profile: {}, {}".format(p, filepath)) except IOError: pass diff --git a/napalm_yang/mappings/eos/parsers/config/openconfig-interfaces/interfaces.yaml b/napalm_yang/mappings/eos/parsers/config/openconfig-interfaces/interfaces.yaml index 1c34ac72..e984d9ca 100644 --- a/napalm_yang/mappings/eos/parsers/config/openconfig-interfaces/interfaces.yaml +++ b/napalm_yang/mappings/eos/parsers/config/openconfig-interfaces/interfaces.yaml @@ -11,7 +11,7 @@ interfaces: _parse: mode: block regexp: "(?Pinterface (?P(\\w|-)*\\d+)\n(?:.|\n)*?^!$)" - from: "{{ bookmarks.interfaces }}" + from: "{{ bookmarks.interfaces.0 }}" name: _parse: unnecessary hold_time: @@ -58,7 +58,7 @@ interfaces: _parse: mode: block regexp: "(?Pinterface {{interface_key}}\\.(?P\\d+)\\n(?:.|\\n)*?^!$)" - from: "{{ bookmarks.interfaces }}" + from: "{{ bookmarks.interfaces.0 }}" index: _parse: unnecessary config: diff --git a/napalm_yang/mappings/ios/parsers/config/openconfig-interfaces/interfaces.yaml b/napalm_yang/mappings/ios/parsers/config/openconfig-interfaces/interfaces.yaml index 69ea8712..d35ad6cb 100644 --- a/napalm_yang/mappings/ios/parsers/config/openconfig-interfaces/interfaces.yaml +++ b/napalm_yang/mappings/ios/parsers/config/openconfig-interfaces/interfaces.yaml @@ -11,7 +11,7 @@ interfaces: _parse: mode: block regexp: "(?Pinterface (?P(\\w|-)*\\d+)\n(?:.|\n)*?^!$)" - from: "{{ bookmarks.interfaces }}" + from: "{{ bookmarks.interfaces.0 }}" name: _parse: unnecessary hold_time: @@ -59,7 +59,7 @@ interfaces: _parse: mode: block regexp: "(?Pinterface {{interface_key}}\\.(?P\\d+)\\n(?:.|\\n)*?^!$)" - from: "{{ bookmarks.interfaces }}" + from: "{{ bookmarks.interfaces.0 }}" index: _parse: unnecessary config: diff --git a/napalm_yang/mappings/junos/parsers/config/openconfig-interfaces/interfaces.yaml b/napalm_yang/mappings/junos/parsers/config/openconfig-interfaces/interfaces.yaml index 83b37990..5ffa6831 100644 --- a/napalm_yang/mappings/junos/parsers/config/openconfig-interfaces/interfaces.yaml +++ b/napalm_yang/mappings/junos/parsers/config/openconfig-interfaces/interfaces.yaml @@ -13,7 +13,7 @@ interfaces: mode: xpath xpath: "interfaces/interface" key: name - from: "{{ bookmarks.interfaces }}" + from: "{{ bookmarks.interfaces.0 }}" name: _parse: unnecessary hold_time: diff --git a/napalm_yang/mappings/junos/parsers/state/openconfig-interfaces/interfaces.yaml b/napalm_yang/mappings/junos/parsers/state/openconfig-interfaces/interfaces.yaml new file mode 100644 index 00000000..98dda86b --- /dev/null +++ b/napalm_yang/mappings/junos/parsers/state/openconfig-interfaces/interfaces.yaml @@ -0,0 +1,221 @@ +--- +metadata: + parser: XMLParser + execute: + - method: _rpc + args: + get: "" + +interfaces: + _parse: not_implemented + interface: + _parse: + mode: xpath + xpath: "physical-interface" + key: name + from: "{{ bookmarks.interfaces.0 }}" + config: + _parse: unnecessary + hold_time: + _parse: not_implemented + config: + _parse: unnecessary + state: + _parse: not_implemented + down: + _parse: not_implemented + up: + _parse: not_implemented + state: + _parse: not_implemented + admin_status: + _parse: + mode: map + xpath: "admin-status" + from: "{{ bookmarks['parent'] }}" + map: + up: UP + down: DOWN + description: + _parse: + mode: xpath + xpath: "description" + from: "{{ bookmarks['parent'] }}" + enabled: + _parse: + mode: map + xpath: "admin-status" + from: "{{ bookmarks['parent'] }}" + map: + up: true + down: false + ifindex: + _parse: + mode: xpath + xpath: "snmp-index" + from: "{{ bookmarks['parent'] }}" + last_change: + _parse: + mode: xpath + xpath: "interface-flapped" + attribute: "seconds" + from: "{{ bookmarks['parent'] }}" + mtu: + _parse: + mode: xpath + xpath: "mtu" + regexp: "(?P\\d+)" # Someone thought mixing strings and ints was a good idea + from: "{{ bookmarks['parent'] }}" + name: + _parse: unnecessary + oper_status: + _parse: + mode: map + xpath: "oper-status" + from: "{{ bookmarks['parent'] }}" + map: + up: UP + down: DOWN + type: + _parse: + mode: map + xpath: "if-type" + from: "{{ bookmarks['parent'] }}" + map: + GRE: tunnel + IPIP: tunnel + Logical-tunnel: tunnel + Multicast-GRE: tunnel + Secure-Tunnel: tunnel + Ethernet: ethernetCsmacd + Loopback: softwareLoopback + VLAN: l2vlan + Adaptive-Services: null + Software-Pseudo: null + PIMD: null + PIME: null + PPPoE: null + counters: + _parse: not_implemented + in_broadcast_pkts: + _parse: + mode: xpath + xpath: "ethernet-mac-statistics/input-broadcasts" + from: "{{ bookmarks['parent'] }}" + in_discards: + _parse: + mode: xpath + xpath: "input-error-list/input-discards" + from: "{{ bookmarks['parent'] }}" + in_errors: + _parse: + mode: xpath + xpath: "input-error-list/input-errors" + from: "{{ bookmarks['parent'] }}" + in_multicast_pkts: + _parse: + mode: xpath + xpath: "ethernet-mac-statistics/input-multicasts" + from: "{{ bookmarks['parent'] }}" + in_octets: + _parse: not_implemented + in_unicast_pkts: + _parse: + mode: xpath + xpath: "ethernet-mac-statistics/input-unicasts" + from: "{{ bookmarks['parent'] }}" + in_unknown_protos: + _parse: not_implemented + last_clear: + _parse: not_implemented + out_broadcast_pkts: + _parse: + mode: xpath + xpath: "ethernet-mac-statistics/output-broadcasts" + from: "{{ bookmarks['parent'] }}" + out_discards: + _parse: not_implemented + out_errors: + _parse: + mode: xpath + xpath: "output-error-list/output-errors" + from: "{{ bookmarks['parent'] }}" + out_multicast_pkts: + _parse: + mode: xpath + xpath: "ethernet-mac-statistics/output-multicasts" + from: "{{ bookmarks['parent'] }}" + out_octets: + _parse: not_implemented + out_unicast_pkts: + _parse: + mode: xpath + xpath: "ethernet-mac-statistics/output-unicasts" + from: "{{ bookmarks['parent'] }}" + subinterfaces: + _parse: unnecessary + subinterface: + _parse: + mode: xpath + xpath: "logical-interface" + from: "{{ bookmarks['parent'] }}" + index: + _parse: unnecessary + config: + _parse: unnecessary + state: + _parse: not_implemented + index: + _parse: not_implemented + description: + _parse: + mode: xpath + xpath: "description" + from: "{{ bookmarks['parent'] }}" + enabled: + _parse: not_implemented + admin_status: + _parse: not_implemented + ifindex: + _parse: + mode: xpath + xpath: "snmp-index" + from: "{{ bookmarks['parent'] }}" + last_change: + _parse: not_implemented + name: + _parse: + mode: value + value: "{{ subinterface_key }}" + oper_status: + _parse: not_implemented + counters: + _parse: not_implemented + in_broadcast_pkts: + _parse: not_implemented + in_discards: + _parse: not_implemented + in_errors: + _parse: not_implemented + in_multicast_pkts: + _parse: not_implemented + in_octets: + _parse: not_implemented + in_unicast_pkts: + _parse: not_implemented + in_unknown_protos: + _parse: not_implemented + last_clear: + _parse: not_implemented + out_broadcast_pkts: + _parse: not_implemented + out_discards: + _parse: not_implemented + out_errors: + _parse: not_implemented + out_multicast_pkts: + _parse: not_implemented + out_octets: + _parse: not_implemented + out_unicast_pkts: + _parse: not_implemented diff --git a/napalm_yang/parser.py b/napalm_yang/parser.py index a876800e..ad19d9f1 100644 --- a/napalm_yang/parser.py +++ b/napalm_yang/parser.py @@ -10,7 +10,7 @@ class Parser(object): def __init__(self, model, device=None, profile=None, is_config=None, - config=None, keys=None, bookmarks=None, extra_vars=None): + native=None, keys=None, bookmarks=None, extra_vars=None): self.model = model self.device = device self.profile = profile or device.profile @@ -25,22 +25,24 @@ def __init__(self, model, device=None, profile=None, is_config=None, self.keys = keys or {"parent_key": None} self.extra_vars = extra_vars or {} - self.config = config or "" - if self.mapping and device: device_config = self._execute_methods(device, self.mapping["metadata"].get("execute", [])) else: - device_config = "" + device_config = [] + + native = native or [] + + self.native = [] - self.config = "{}\n{}".format(self.config, device_config) - self.config = self.config.replace("\r", "") # Parsing will be easier + for n in native + device_config: + self.native.append(n.replace("\r", "")) # Parsing will be easier - if not self.config: + if not self.native: raise Exception("I don't have any data to operate with") - self.bookmarks = {self._yang_name: self.config, "parent": self.config} + self.bookmarks = {self._yang_name: self.native, "parent": self.native} self.bookmarks = bookmarks or self.bookmarks if self.mapping: @@ -54,13 +56,13 @@ def _execute_methods(self, device, methods): attr = getattr(attr, p) r = attr(**m["args"]) - if isinstance(r, dict): + if isinstance(r, dict) and all([isinstance(x, (str, unicode)) for x in r.values()]): # Some vendors like junos return commands enclosed by a key r = "\n".join(r.values()) result.append(r) - return "\n".join(result) + return result def parse(self): if not self.mapping: @@ -84,12 +86,13 @@ def _parse_container(self, attribute, model, mapping): logger.debug("Parsing attribute: {}".format(v._yang_path())) if self.is_config and (not v._is_config or k == "state"): continue - elif not self.is_config and (v._is_config or k == "config"): + elif not self.is_config and (v._is_config or k == "config") \ + and v._yang_type not in ("container", "list"): continue if v._defining_module != self._defining_module and v._defining_module is not None: logger.debug("Skipping attribute: {}:{}".format(v._defining_module, attribute)) - parser = Parser(v, self.device, self.profile, self.is_config, self.config, + parser = Parser(v, self.device, self.profile, self.is_config, self.native, self.keys, self.bookmarks, self.extra_vars) parser.parse() else: diff --git a/napalm_yang/parsers/xml.py b/napalm_yang/parsers/xml.py index 4c3d5759..2784fd46 100644 --- a/napalm_yang/parsers/xml.py +++ b/napalm_yang/parsers/xml.py @@ -11,7 +11,7 @@ def _parse_list_xpath(cls, mapping): xml = etree.fromstring(mapping["from"]) for element in xml.xpath(mapping["xpath"]): - key = element.xpath("name")[0].text + key = element.xpath("name")[0].text.strip() yield key, etree.tostring(element), {} @classmethod @@ -20,11 +20,18 @@ def _parse_leaf_xpath(cls, mapping, check_default=True, check_presence=False): element = xml.xpath(mapping["xpath"]) if element and not check_presence: + if "attribute" in mapping.keys(): + element = element[0].get(mapping["attribute"]) + else: + element = element[0].text.strip() + regexp = mapping.get("regexp", None) if regexp: - return re.search(mapping["regexp"], element[0].text).group("value") + match = re.search(mapping["regexp"], element) + if match: + return match.group("value") else: - return element[0].text + return element elif element and check_presence: return True elif check_default: @@ -35,9 +42,11 @@ def _parse_leaf_xpath(cls, mapping, check_default=True, check_presence=False): @classmethod def _parse_leaf_map(cls, mapping): value = cls._parse_leaf_xpath(mapping) - value = re.search(mapping["regexp"], value).group("value") - return mapping["map"][value] + if "regex" in mapping.keys(): + value = re.search(mapping["regexp"], value).group("value") + + return mapping["map"][value] if value else None @classmethod def _parse_leaf_is_present(cls, mapping): diff --git a/setup.py b/setup.py index ecf2b5d1..c80bd3bf 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-yang", - version="0.0.4", + version="0.0.5", packages=find_packages(), author="David Barroso", author_email="dbarrosop@dravetech.com", diff --git a/test/integration/profiles_data/junos/openconfig-interfaces/default/openconfig-interfaces.expected b/test/integration/profiles_data/junos/openconfig-interfaces/default/openconfig-interfaces.expected new file mode 100644 index 00000000..475e8329 --- /dev/null +++ b/test/integration/profiles_data/junos/openconfig-interfaces/default/openconfig-interfaces.expected @@ -0,0 +1,505 @@ +{ + "interfaces": { + "interface": { + ".local.": { + "name": ".local.", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 0, + "last-change": 0, + "oper-status": "UP", + "type": "softwareLoopback" + }, + "subinterfaces": { + "subinterface": { + ".local..0": { + "index": ".local..0", + "state": { + "ifindex": 0, + "name": ".local..0" + } + }, + ".local..1": { + "index": ".local..1", + "state": { + "ifindex": 0, + "name": ".local..1" + } + }, + ".local..2": { + "index": ".local..2", + "state": { + "ifindex": 0, + "name": ".local..2" + } + }, + ".local..3": { + "index": ".local..3", + "state": { + "ifindex": 0, + "name": ".local..3" + } + }, + ".local..4": { + "index": ".local..4", + "state": { + "ifindex": 0, + "name": ".local..4" + } + } + } + } + }, + "ae0": { + "name": "ae0", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 531, + "last-change": 250256, + "mtu": 1518, + "oper-status": "DOWN" + }, + "subinterfaces": { + "subinterface": { + "ae0.0": { + "index": "ae0.0", + "state": { + "description": "ASDASDASD", + "ifindex": 532, + "name": "ae0.0" + } + }, + "ae0.1": { + "index": "ae0.1", + "state": { + "description": "ae0.1", + "ifindex": 533, + "name": "ae0.1" + } + }, + "ae0.2": { + "index": "ae0.2", + "state": { + "description": "ae0.2", + "ifindex": 534, + "name": "ae0.2" + } + }, + "ae0.32767": { + "index": "ae0.32767", + "state": { + "ifindex": 535, + "name": "ae0.32767" + } + } + } + } + }, + "dsc": { + "name": "dsc", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 5, + "last-change": 0, + "oper-status": "UP" + } + }, + "ge-0/0/0": { + "name": "ge-0/0/0", + "state": { + "admin-status": "UP", + "counters": { + "in-broadcast-pkts": 0, + "in-discards": 0, + "in-errors": 0, + "in-multicast-pkts": 0, + "in-unicast-pkts": 11627, + "out-broadcast-pkts": 0, + "out-errors": 0, + "out-multicast-pkts": 0, + "out-unicast-pkts": 10927 + }, + "description": "management interface", + "enabled": true, + "ifindex": 507, + "last-change": 253520, + "mtu": 1400, + "oper-status": "UP" + }, + "subinterfaces": { + "subinterface": { + "ge-0/0/0.0": { + "index": "ge-0/0/0.0", + "state": { + "description": "ge-0/0/0.0", + "ifindex": 521, + "name": "ge-0/0/0.0" + } + } + } + } + }, + "ge-0/0/1": { + "name": "ge-0/0/1", + "state": { + "admin-status": "DOWN", + "counters": { + "in-broadcast-pkts": 0, + "in-discards": 1, + "in-errors": 0, + "in-multicast-pkts": 0, + "in-unicast-pkts": 2931, + "out-broadcast-pkts": 0, + "out-errors": 0, + "out-multicast-pkts": 0, + "out-unicast-pkts": 0 + }, + "description": "ge-0/0/1", + "enabled": false, + "ifindex": 508, + "last-change": 250254, + "mtu": 1514, + "oper-status": "DOWN" + } + }, + "ge-0/0/2": { + "name": "ge-0/0/2", + "state": { + "admin-status": "UP", + "counters": { + "in-broadcast-pkts": 0, + "in-discards": 2, + "in-errors": 0, + "in-multicast-pkts": 0, + "in-unicast-pkts": 371, + "out-broadcast-pkts": 0, + "out-errors": 0, + "out-multicast-pkts": 0, + "out-unicast-pkts": 0 + }, + "enabled": true, + "ifindex": 509, + "last-change": 253520, + "mtu": 1514, + "oper-status": "UP" + } + }, + "gr-0/0/0": { + "name": "gr-0/0/0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 516, + "oper-status": "UP", + "type": "tunnel" + } + }, + "gre": { + "name": "gre", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 8, + "oper-status": "UP", + "type": "tunnel" + } + }, + "ip-0/0/0": { + "name": "ip-0/0/0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 517, + "oper-status": "UP", + "type": "tunnel" + } + }, + "ipip": { + "name": "ipip", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 9, + "oper-status": "UP", + "type": "tunnel" + } + }, + "irb": { + "name": "irb", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 502, + "last-change": 0, + "mtu": 1514, + "oper-status": "UP", + "type": "ethernetCsmacd" + } + }, + "lo0": { + "name": "lo0", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "description": "lo0", + "enabled": true, + "ifindex": 6, + "last-change": 0, + "oper-status": "UP", + "type": "softwareLoopback" + }, + "subinterfaces": { + "subinterface": { + "lo0.0": { + "index": "lo0.0", + "state": { + "description": "lo0.0", + "ifindex": 16, + "name": "lo0.0" + } + }, + "lo0.16384": { + "index": "lo0.16384", + "state": { + "ifindex": 21, + "name": "lo0.16384" + } + }, + "lo0.16385": { + "index": "lo0.16385", + "state": { + "ifindex": 22, + "name": "lo0.16385" + } + }, + "lo0.32768": { + "index": "lo0.32768", + "state": { + "ifindex": 248, + "name": "lo0.32768" + } + } + } + } + }, + "lsi": { + "name": "lsi", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 4, + "last-change": 0, + "mtu": 1496, + "oper-status": "UP" + } + }, + "lsq-0/0/0": { + "name": "lsq-0/0/0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 518, + "last-change": 253521, + "mtu": 1504, + "oper-status": "UP" + } + }, + "lt-0/0/0": { + "name": "lt-0/0/0", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 520, + "last-change": 0, + "oper-status": "UP", + "type": "tunnel" + } + }, + "mt-0/0/0": { + "name": "mt-0/0/0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 519, + "oper-status": "UP", + "type": "tunnel" + } + }, + "mtun": { + "name": "mtun", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 12, + "oper-status": "UP", + "type": "tunnel" + } + }, + "pimd": { + "name": "pimd", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 11, + "oper-status": "UP" + } + }, + "pime": { + "name": "pime", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 10, + "oper-status": "UP" + } + }, + "pp0": { + "name": "pp0", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 501, + "mtu": 1532, + "oper-status": "UP" + } + }, + "ppd0": { + "name": "ppd0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 504, + "oper-status": "UP" + } + }, + "ppe0": { + "name": "ppe0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 505, + "oper-status": "UP" + } + }, + "sp-0/0/0": { + "name": "sp-0/0/0", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 515, + "last-change": 253521, + "mtu": 9192, + "oper-status": "UP" + }, + "subinterfaces": { + "subinterface": { + "sp-0/0/0.0": { + "index": "sp-0/0/0.0", + "state": { + "ifindex": 522, + "name": "sp-0/0/0.0" + } + }, + "sp-0/0/0.16383": { + "index": "sp-0/0/0.16383", + "state": { + "ifindex": 523, + "name": "sp-0/0/0.16383" + } + } + } + } + }, + "st0": { + "name": "st0", + "state": { + "admin-status": "UP", + "enabled": true, + "ifindex": 503, + "mtu": 9192, + "oper-status": "UP", + "type": "tunnel" + } + }, + "tap": { + "name": "tap", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 7, + "last-change": 0, + "oper-status": "UP" + } + }, + "vlan": { + "name": "vlan", + "state": { + "admin-status": "UP", + "counters": { + "in-discards": 0, + "in-errors": 0, + "out-errors": 0 + }, + "enabled": true, + "ifindex": 506, + "last-change": 253529, + "mtu": 1518, + "oper-status": "DOWN", + "type": "l2vlan" + } + } + } + } +} diff --git a/test/integration/profiles_data/junos/openconfig-interfaces/default/openconfig-interfaces.native b/test/integration/profiles_data/junos/openconfig-interfaces/default/openconfig-interfaces.native new file mode 100644 index 00000000..f0a8293f --- /dev/null +++ b/test/integration/profiles_data/junos/openconfig-interfaces/default/openconfig-interfaces.native @@ -0,0 +1,6967 @@ + + + +ge-0/0/0 + + +up + + +up + + +134 + + +507 + + +137 + + +management interface + + +Ethernet + + +1400 + + +disabled + + +Full-duplex + + +1000mbps + + +none + + +none + + +disabled + + +enabled + + +enabled + + +online + + + + + + + + +0x4000 + + + + + + + +8 + + +8 + + + +0 + + +0 + + +08:00:27:aa:8c:76 + + +08:00:27:aa:8c:76 + + +2017-03-21 10:38:24 UTC (2d 22:25 ago) + + +2017-03-24 08:04:59 UTC (00:58:45 ago) + + + +601607 + + +33320 + + +6898593 + + +83264 + + +11622 + + +54 + + +10955 + + +48 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +Egress queues + + +8 + + +4 + + + + +0 + + +best-effort + + +10955 + + +10955 + + +0 + + + + +1 + + +expedited-forwarding + + +0 + + +0 + + +0 + + + + +2 + + +assured-forwarding + + +0 + + +0 + + +0 + + + + +3 + + +network-control + + +0 + + +0 + + +0 + + + + + +0 + + +best-effort + + + + +1 + + +expedited-forwarding + + + + +2 + + +assured-forwarding + + + + +3 + + +network-control + + + + + + + + + + + + + + +0 + + +0 + + +0 + + +0 + + +11627 + + +10927 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +2 + + +0 + + + + +complete + + +OK + + +full-duplex + + +1000 Mbps + + +None + + + +None + + +Link OK + + + + + +0 + + + + + + +Output + + + +0 + + +best-effort + + +95 + + +950000000 + + +95 + + +0 + + +low + + +none + + + + +3 + + +network-control + + +5 + + +50000000 + + +5 + + +0 + + +low + + +none + + + + + +Disabled + + + +ge-0/0/0.0 + + +69 + + +521 + + +141 + + +ge-0/0/0.0 + + + + +0x4000 + + + +ENET2 + + + +604535 + + +6460861 + + +11658 + + +10957 + + + + +603895 + + +6460861 + + +11642 + + +10957 + + + + +640 + + +0 + + +0 + + +0 + + +16 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +1386 + + +155 + + +0 + + + + + + + + + + + + + + + + +10.0.2/24 + + +10.0.2.15 + + +10.0.2.255 + + +160 + + + + + + + +gr-0/0/0 + + +up + + +up + + +138 + + +516 + + +141 + + +GRE + + +GRE + + +Unlimited + + +800mbps + + + + + + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +ip-0/0/0 + + +up + + +up + + +139 + + +517 + + +142 + + +IPIP + + +IP-over-IP + + +Unlimited + + +800mbps + + + + + + + +0 + + +0 + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +lsq-0/0/0 + + +up + + +up + + +140 + + +518 + + +143 + + +LinkService + + +1504 + + + + + + + + + +0x4000 + + + +2017-03-21 10:38:23 UTC (2d 22:25 ago) + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +lt-0/0/0 + + +up + + +up + + +142 + + +520 + + +145 + + +Logical-tunnel + + +Logical-tunnel + + +Unlimited + + +800mbps + + +Unspecified + + + + + + + + + + +Unspecified + + + + + +13 + + +0 + + +0 + + +02:96:14:8c:76:b3 + + +02:96:14:8c:76:b3 + + +Unspecified + + +Never + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +1 + + +0 + + +0 + + +0 + + +0 + + + + + +mt-0/0/0 + + +up + + +up + + +141 + + +519 + + +144 + + +Multicast-GRE + + +GRE + + +Unlimited + + +800mbps + + + + + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +sp-0/0/0 + + +up + + +up + + +137 + + +515 + + +140 + + +Adaptive-Services + + +Adaptive-Services + + +9192 + + +800mbps + + +Unspecified + + + + + + + + + +0x4000 + + + +Full-Duplex + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +2017-03-21 10:38:23 UTC (2d 22:25 ago) + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +1 + + +0 + + +0 + + +0 + + +0 + + + + +sp-0/0/0.0 + + +70 + + +522 + + +135 + + + + + + +Adaptive-Services + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +9192 + + +149 + + +0 + + + + + + + + +inet6 + + +9192 + + +150 + + +0 + + + + + + + + + + + +sp-0/0/0.16383 + + +71 + + +523 + + +136 + + + + + + +Adaptive-Services + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +9192 + + +151 + + +1 + + + + + + + + + + + + +10.0.0.16 + + +10.0.0.1 + + +Unspecified + + +141 + + + + + + + +Unspecified + + +10.0.0.6 + + +Unspecified + + +143 + + + + + + + +128.0.1.16 + + +128.0.0.1 + + +Unspecified + + +144 + + + + + + + +Unspecified + + +128.0.0.6 + + +Unspecified + + +146 + + + + + + + +ge-0/0/1 + + +down + + +down + + +135 + + +508 + + +138 + + +ge-0/0/1 + + +Ethernet + + +1514 + + +disabled + + +Full-duplex + + +1000mbps + + +none + + +none + + +disabled + + +enabled + + +enabled + + +online + + + + + + + + + + + +0x4000 + + + + + + + +8 + + +8 + + + +0 + + +0 + + +08:00:27:8d:47:bc + + +08:00:27:8d:47:bc + + +2017-03-21 11:32:50 UTC (2d 21:30 ago) + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +1 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +2 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + + + + + + + + + +0 + + +0 + + +0 + + +0 + + +2931 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +1 + + +0 + + + + +complete + + +OK + + +full-duplex + + +1000 Mbps + + +None + + + +None + + +Link OK + + + + + +0 + + + + + + +Output + + + +0 + + +best-effort + + +95 + + +950000000 + + +95 + + +0 + + +low + + +none + + + + +3 + + +network-control + + +5 + + +50000000 + + +5 + + +0 + + +low + + +none + + + + + +Disabled + + + + +ge-0/0/2 + + +up + + +up + + +136 + + +509 + + +139 + + +Ethernet + + +1514 + + +disabled + + +Full-duplex + + +1000mbps + + +none + + +none + + +disabled + + +enabled + + +enabled + + +online + + + + + + + + +0x4000 + + + + + + + +8 + + +8 + + + +0 + + +0 + + +08:00:27:1e:e6:0f + + +08:00:27:1e:e6:0f + + +2017-03-21 10:38:24 UTC (2d 22:25 ago) + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +2 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +1 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + + + + + + + + + +0 + + +0 + + +0 + + +0 + + +371 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +1 + + +0 + + + + +complete + + +OK + + +full-duplex + + +1000 Mbps + + +None + + + +None + + +Link OK + + + + + +0 + + + + + + +Output + + + +0 + + +best-effort + + +95 + + +950000000 + + +95 + + +0 + + +low + + +none + + + + +3 + + +network-control + + +5 + + +50000000 + + +5 + + +0 + + +low + + +none + + + + + +Disabled + + + + +.local. + + +up + + +up + + +0 + + +0 + + +1 + + +Loopback + + +Interface-Specific + + +Unlimited + + +Unlimited + + +Unspecified + + + + + + + + + + +Unspecified + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +Never + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +.local..0 + + +0 + + +0 + + +1 + + + + + +Unspecified + + +0 + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +Unlimited + + +138 + + +0 + + + + + + + + + +Unspecified + + +10.0.2.15 + + +Unspecified + + +159 + + + + + + + +Unspecified + + +172.20.100.1 + + +Unspecified + + +161 + + + + + + + +Unspecified + + +192.168.100.1 + + +Unspecified + + +163 + + + + + + + +Unspecified + + +192.168.101.1 + + +Unspecified + + +165 + + + + + + + +Unspecified + + +192.168.102.1 + + +Unspecified + + +167 + + + + + +iso + + +Unlimited + + +141 + + +0 + + + + + + + +inet6 + + +Unlimited + + +136 + + +0 + + + + + + + +mpls + + +Unlimited + + +3 + + +135 + + +0 + + + + + + + +eth-switch + + +Unlimited + + +130 + + +0 + + + + + + + +56 + + +Unlimited + + +129 + + +0 + + + + + + + +57 + + +Unlimited + + +133 + + +0 + + + + + + + +60 + + +Unlimited + + +131 + + +0 + + + + + + + +61 + + +Unlimited + + +132 + + +0 + + + + + + + + +.local..1 + + +1 + + +0 + + +2 + + + + + +Unspecified + + +0 + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +Unlimited + + +139 + + +1 + + + + + + + + + +Unspecified + + +10.0.0.1 + + +Unspecified + + +131 + + + + + + + +Unspecified + + +10.0.0.6 + + +Unspecified + + +142 + + + + + + + +Unspecified + + +10.0.0.16 + + +Unspecified + + +133 + + + + + + + +Unspecified + + +128.0.0.1 + + +Unspecified + + +135 + + + + + + + +Unspecified + + +128.0.0.4 + + +Unspecified + + +137 + + + + + + + +Unspecified + + +128.0.0.6 + + +Unspecified + + +145 + + + + + + + +Unspecified + + +128.0.1.16 + + +Unspecified + + +139 + + + + + +inet6 + + +Unlimited + + +137 + + +1 + + + + + + + +vpls + + +Unlimited + + +134 + + +1 + + + + + + + + +.local..2 + + +2 + + +0 + + +2 + + + + + +Unspecified + + +0 + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +Unlimited + + +140 + + +2 + + + + + + + + + + +Unspecified + + +127.0.0.1 + + +Unspecified + + +129 + + + + + + +.local..3 + + +67 + + +0 + + +132 + + + + + +Unspecified + + +0 + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +Unlimited + + +144 + + +3 + + + + + + + +iso + + +Unlimited + + +145 + + +3 + + + + + + + +inet6 + + +Unlimited + + +147 + + +3 + + + + + + + + +.local..4 + + +68 + + +0 + + +133 + + + + + +Unspecified + + +0 + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +mpls + + +Unlimited + + +3 + + +146 + + +4 + + + + + + + + + +ae0 + + +up + + +down + + +143 + + +531 + + +146 + + +Ethernet + + +1518 + + +disabled + + +Unspecified + + +none + + +none + + +disabled + + +disabled + + +1 + + +0 + + + + + + + + + +0x4000 + + + +4c:96:14:8c:76:80 + + +4c:96:14:8c:76:80 + + +2017-03-21 11:32:48 UTC (2d 21:30 ago) + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +ae0.0 + + +77 + + +532 + + +143 + + +ASDASDASD + + + + + + +0x4000 + + + +[ 0x8100.100 ] + + +ENET2 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +1500 + + +156 + + +0 + + + + + + + + + + + + + + + +172.20.100/24 + + +172.20.100.1 + + +172.20.100.255 + + +162 + + + + + + + + +192.168.100/24 + + +192.168.100.1 + + +192.168.100.255 + + +164 + + + + + + +ae0.1 + + +78 + + +533 + + +144 + + +ae0.1 + + + + + + + +0x4000 + + + +[ 0x8100.1 ] + + +ENET2 + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +1500 + + +157 + + +0 + + + + + + + + + + + + + + + +192.168.101/24 + + +192.168.101.1 + + +192.168.101.255 + + +166 + + + + + + +ae0.2 + + +79 + + +534 + + +145 + + +ae0.2 + + + + + + +0x4000 + + + +[ 0x8100.2 ] + + +ENET2 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +1500 + + +158 + + +0 + + + + + + + + + + + + + + + +192.168.102/24 + + +192.168.102.1 + + +192.168.102.255 + + +168 + + + + + + +ae0.32767 + + +72 + + +535 + + +146 + + + + + + +0x4000 + + + +[ 0x0000.0 ] + + +ENET2 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + +dsc + + +up + + +up + + +5 + + +5 + + +6 + + +Software-Pseudo + + +Unspecified + + +Unlimited + + +Unspecified + + +Unspecified + + + + + + + + + + +Unspecified + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +Never + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +gre + + +up + + +up + + +10 + + +8 + + +11 + + +GRE + + +GRE + + +Unlimited + + +Unlimited + + + + + + +0 + + +0 + + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + + +ipip + + +up + + +up + + +11 + + +9 + + +12 + + +IPIP + + +IP-over-IP + + +Unlimited + + +Unlimited + + + + + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + + +irb + + +up + + +up + + +129 + + +502 + + +132 + + +Ethernet + + +Ethernet + + +1514 + + +Unspecified + + +Unspecified + + + + + + + + + +Full-Duplex + + + + + +Unspecified + + +0 + + +0 + + +4c:96:14:8c:76:b0 + + +4c:96:14:8c:76:b0 + + +Unspecified + + +Never + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +lo0 + + +up + + +up + + +6 + + +6 + + +7 + + +lo0 + + +Loopback + + +Unspecified + + +Unlimited + + +Unspecified + + +Unspecified + + + + + + + + + + +Unspecified + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +Never + + +Never + + + +36383917 + + +36383917 + + +777746 + + +777746 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +lo0.0 + + +76 + + +16 + + +142 + + +lo0.0 + + + + + +Unspecified + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +lo0.16384 + + +65 + + +21 + + +130 + + + + + +Unspecified + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +Unlimited + + +142 + + +2 + + + + + + + + + +Unspecified + + +127.0.0.1 + + +Unspecified + + +130 + + + + + + +lo0.16385 + + +66 + + +22 + + +131 + + + + + +Unspecified + + + +36383917 + + +36383917 + + +777746 + + +777746 + + + + +36383917 + + +36383917 + + +777746 + + +777746 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +inet + + +Unlimited + + +143 + + +1 + + + + + + + + + + +Unspecified + + +10.0.0.1 + + +Unspecified + + +132 + + + + + + + +Unspecified + + +10.0.0.16 + + +Unspecified + + +134 + + + + + + + +Unspecified + + +128.0.0.1 + + +Unspecified + + +136 + + + + + + + +Unspecified + + +128.0.0.4 + + +Unspecified + + +138 + + + + + + + +Unspecified + + +128.0.1.16 + + +Unspecified + + +140 + + + + + + +lo0.32768 + + +64 + + +248 + + +129 + + + + +Unspecified + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + + + + +Null + + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + + +lsi + + +up + + +up + + +4 + + +4 + + +5 + + +Software-Pseudo + + +LSI + + +1496 + + +Unlimited + + +Unspecified + + + + + + + + +Unspecified + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +Never + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +mtun + + +up + + +up + + +64 + + +12 + + +1 + + +Multicast-GRE + + +GRE + + +Unlimited + + +Unlimited + + + + + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + + +pimd + + +up + + +up + + +26 + + +11 + + +129 + + +PIMD + + +PIM-Decapsulator + + +Unlimited + + +Unlimited + + +0 + + +0 + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + + +pime + + +up + + +up + + +25 + + +10 + + +130 + + +PIME + + +PIM-Encapsulator + + +Unlimited + + +Unlimited + + +0 + + +0 + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + + +pp0 + + +up + + +up + + +128 + + +501 + + +131 + + +PPPoE + + +PPPoE + + +1532 + + +Unspecified + + + + + + + + + + +Full-Duplex + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +ppd0 + + +up + + +up + + +131 + + +504 + + +134 + + +PIMD + + +PIM-Decapsulator + + +Unlimited + + +800mbps + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +ppe0 + + +up + + +up + + +132 + + +505 + + +135 + + +PIME + + +PIM-Encapsulator + + +Unlimited + + +800mbps + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +st0 + + +up + + +up + + +130 + + +503 + + +133 + + +Secure-Tunnel + + +Secure-Tunnel + + +9192 + + +Unspecified + + +0 + + +0 + + + + + + + + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +tap + + +up + + +up + + +12 + + +7 + + +13 + + +Software-Pseudo + + +Interface-Specific + + +Unlimited + + +Unlimited + + +Unspecified + + + + + + + + + +Unspecified + + + + + +Unspecified + + +0 + + +0 + + +Unspecified + + +Unspecified + + +Unspecified + + +Never + + +Never + + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + + +vlan + + +up + + +down + + +133 + + +506 + + +136 + + +VLAN + + +VLAN + + +1518 + + +1000mbps + + +Unspecified + + + + + + + + + + +Full-Duplex + + + +0x8000 + + + +Unspecified + + + +8 + + +8 + + + +0 + + +0 + + +00:00:00:00:00:00 + + +00:00:00:00:00:00 + + +Unspecified + + +2017-03-21 10:38:15 UTC (2d 22:25 ago) + + +Never + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + +0 + + + + +0 + + +0 + + +0 + + +0 + + +0 + + + + diff --git a/test/integration/test_profiles.py b/test/integration/test_profiles.py index 45bd91ef..c2432ff4 100644 --- a/test/integration/test_profiles.py +++ b/test/integration/test_profiles.py @@ -32,10 +32,14 @@ def pretty_json(dictionary): BASE_PATH = os.path.dirname(__file__) -test_profile_models = [ +test_config_profile_models = [ ["ios", napalm_yang.models.openconfig_interfaces, "default"], ] +test_state_profile_models = [ + ["junos", napalm_yang.models.openconfig_interfaces, "default"], +] + def read_file_content(profile, model, case, filename): full_path = os.path.join(BASE_PATH, "profiles_data", @@ -50,14 +54,14 @@ def read_json(profile, model, case, filename): class Tests(object): - @pytest.mark.parametrize("profile, model, case", test_profile_models) - def test_parse(self, profile, model, case): + @pytest.mark.parametrize("profile, model, case", test_config_profile_models) + def test_parse_config(self, profile, model, case): config_txt = read_file_content(profile, model, case, "config.txt") expected_json = read_json(profile, model, case, "expected.json") config = napalm_yang.base.Root() config.add_model(model) - config.parse_config(config=config_txt, profile=[profile]) + config.parse_config(native=[config_txt], profile=[profile]) expected = napalm_yang.base.Root() expected.add_model(model) @@ -67,7 +71,7 @@ def test_parse(self, profile, model, case): assert not napalm_yang.utils.diff(config, expected) - @pytest.mark.parametrize("profile, model, case", test_profile_models) + @pytest.mark.parametrize("profile, model, case", test_config_profile_models) def test_translate(self, profile, model, case): json_blob = read_json(profile, model, case, "expected.json") expected_translation = read_file_content(profile, model, case, "translation.txt") @@ -82,7 +86,7 @@ def test_translate(self, profile, model, case): assert configuration == expected_translation @pytest.mark.parametrize("action", ["merge", "replace"]) - @pytest.mark.parametrize("profile, model, case", test_profile_models) + @pytest.mark.parametrize("profile, model, case", test_config_profile_models) def test_translate_merge(self, action, profile, model, case): json_running = read_json(profile, model, case, "expected.json") json_candidate = read_json(profile, model, case, "candidate.json") @@ -106,3 +110,18 @@ def test_translate_merge(self, action, profile, model, case): # print(configuration) assert configuration == expected_translation + + @pytest.mark.parametrize("profile, model, case", test_state_profile_models) + def test_parse_state(self, profile, model, case): + native = read_file_content(profile, model, case, "{}.native".format(model._yang_name)) + expected_json = read_json(profile, model, case, "{}.expected".format(model._yang_name)) + + state = napalm_yang.base.Root() + state.add_model(model) + state.parse_state(native=[native], profile=[profile]) + + expected = napalm_yang.base.Root() + expected.add_model(model) + expected.load_dict(expected_json) + + assert not napalm_yang.utils.diff(state, expected) diff --git a/test/integration/test_tutorial.py b/test/integration/test_tutorial.py index cc22a436..9d78e63a 100644 --- a/test/integration/test_tutorial.py +++ b/test/integration/test_tutorial.py @@ -116,7 +116,7 @@ def test_populating_from_file(self, profile): config = napalm_yang.base.Root() config.add_model(napalm_yang.models.openconfig_interfaces) - config.parse_config(config=read_file_content(config_path), profile=profile) + config.parse_config(native=[read_file_content(config_path)], profile=profile) # print(json.dumps(config.get(filter=True), indent=4)) assert config.get(filter=True) == read_json(expected_path) @@ -151,7 +151,7 @@ def test_advanced_manipulation_junos(self): candidate = napalm_yang.base.Root() candidate.add_model(napalm_yang.models.openconfig_interfaces) - candidate.parse_config(config=read_file_content(config_file), profile=profile) + candidate.parse_config(native=[read_file_content(config_file)], profile=profile) # now let's do a few changes, let's remove lo0.0 and create lo0.1 candidate.interfaces.interface["lo0"].subinterfaces.subinterface.delete("0") @@ -164,7 +164,7 @@ def test_advanced_manipulation_junos(self): # We will also need a running configuration to compare against running = napalm_yang.base.Root() running.add_model(napalm_yang.models.openconfig_interfaces) - running.parse_config(config=read_file_content(config_file), profile=profile) + running.parse_config(native=[read_file_content(config_file)], profile=profile) merge_config = candidate.translate_config(profile=profile, merge=running) assert merge_config == read_file_content(merge_file) @@ -181,7 +181,7 @@ def test_advanced_manipulation_eos(self): candidate = napalm_yang.base.Root() candidate.add_model(napalm_yang.models.openconfig_interfaces) - candidate.parse_config(config=read_file_content(config_file), profile=profile) + candidate.parse_config(native=[read_file_content(config_file)], profile=profile) # now let's do a few changes, let's remove lo1 and create lo0 candidate.interfaces.interface.delete("Loopback1") @@ -194,7 +194,7 @@ def test_advanced_manipulation_eos(self): # We will also need a running configuration to compare against running = napalm_yang.base.Root() running.add_model(napalm_yang.models.openconfig_interfaces) - running.parse_config(config=read_file_content(config_file), profile=profile) + running.parse_config(native=[read_file_content(config_file)], profile=profile) merge_config = candidate.translate_config(profile=profile, merge=running) assert merge_config == read_file_content(merge_file) @@ -210,7 +210,7 @@ def test_diffing_objects(self): candidate = napalm_yang.base.Root() candidate.add_model(napalm_yang.models.openconfig_interfaces) - candidate.parse_config(config=read_file_content(config_file), profile=profile) + candidate.parse_config(native=[read_file_content(config_file)], profile=profile) # now let's do a few changes, let's remove lo1 and create lo0 candidate.interfaces.interface.delete("Loopback1") @@ -223,6 +223,6 @@ def test_diffing_objects(self): # We will also need a running configuration to compare against running = napalm_yang.base.Root() running.add_model(napalm_yang.models.openconfig_interfaces) - running.parse_config(config=read_file_content(config_file), profile=profile) + running.parse_config(native=[read_file_content(config_file)], profile=profile) assert napalm_yang.utils.diff(candidate, running) == read_json(expected_file)