The missing bridge between industry standard CLIs and YANG

networktocode, updated 🕥 2022-07-29 23:28:30

ntc_rosetta

ntc_rosetta leverages yangify to implement a set of "drivers" that can:

  1. Transform network devices' native configuration/state into structured data that conform to YANG models
  2. Transform data structures that conform to YANG models into network device's native configuration/data structures
  3. Merge configurations

Installing NTC Rosetta

Pip Install

pip install ntc-rosetta

Install From Source

  • Clone ntc-rosetta (git clone https://github.com/networktocode/ntc-rosetta.git)
  • cd into project root (cd ntc-rosetta)
  • pip install poetry
  • poetry install

Ways to get started with NTC Rosetta

Start Executing Jupyter Notebooks

Step 1

Clone the repository: $ git clone https://github.com/networktocode/ntc-rosetta.git

Step 2

Change directory into ntc-rosetta: $ cd ntc-rosetta

Step 3

Build the containers: $ make build_test_containers

Step 4

Start a container so you can run the Jupyter notebooks: $ make jupyter

Step 5

Launch a browser and navigate to the following URL: http://127.0.0.1:8888/tree/docs/tutorials

The same notebooks can be viewed without being interactive in the NTC Rosetta Read the Docs.

Parsing

>>> from ntc_rosetta import get_driver
>>>
>>> ios = get_driver("ios", "openconfig")
>>> ios_driver = ios()
>>> with open("data/ios/config.txt", "r") as f:
>>>     config = f.read()
>>> print(config)
interface FastEthernet1
   description This is Fa1
   shutdown
   exit
!
vlan 10
   name prod
   no shutdown
   exit
!
vlan 20
   name dev
   shutdown
   exit
!
>>> parsed = ios_driver.parse(native={"dev_conf": config})
>>> import json
>>> print(json.dumps(parsed.raw_value(), indent=4))
{
    "openconfig-interfaces:interfaces": {
        "interface": [
            {
                "name": "FastEthernet1",
                "config": {
                    "name": "FastEthernet1",
                    "type": "iana-if-type:ethernetCsmacd",
                    "description": "This is Fa1",
                    "enabled": false
                },
                "subinterfaces": {
                    "subinterface": [
                        {
                            "index": 1,
                            "config": {
                                "index": 1,
                                "description": "This is Fa1.1"
                            }
                        },
                        {
                            "index": 2,
                            "config": {
                                "index": 2,
                                "description": "This is Fa1.2"
                            }
                        }
                    ]
                }
            },
        ]
    },
    "openconfig-network-instance:network-instances": {
        "network-instance": [
            {
                "name": "default",
                "config": {
                    "name": "default"
                },
                "vlans": {
                    "vlan": [
                        {
                            "vlan-id": 10,
                            "config": {
                                "vlan-id": 10,
                                "name": "prod",
                                "status": "ACTIVE"
                            }
                        },
                        {
                            "vlan-id": 20,
                            "config": {
                                "vlan-id": 20,
                                "name": "dev",
                                "status": "SUSPENDED"
                            }
                        }
                    ]
                }
            }
        ]
    }
}

Translating

>>> from ntc_rosetta import get_driver
>>> 
>>> ios = get_driver("ios", "openconfig")
>>> ios_processor = ios()
>>> data = {
>>>     "openconfig-interfaces:interfaces": {
>>>         "interface": [
>>>             {
>>>                 "name": "FastEthernet1",
>>>                 "config": {
>>>                     "name": "FastEthernet1",
>>>                     "type": "iana-if-type:ethernetCsmacd",
>>>                     "description": "This is Fa1",
>>>                     "enabled": False
>>>                 },
>>>                 "subinterfaces": {
>>>                     "subinterface": [
>>>                         {
>>>                             "index": 1,
>>>                             "config": {
>>>                                 "index": 1,
>>>                                 "description": "This is Fa1.1"
>>>                             }
>>>                         },
>>>                         {
>>>                             "index": 2,
>>>                             "config": {
>>>                                 "index": 2,
>>>                                 "description": "This is Fa1.2"
>>>                             }
>>>                         }
>>>                     ]
>>>                 }
>>>             },
>>>         ]
>>>     },
>>>     "openconfig-network-instance:network-instances": {
>>>         "network-instance": [
>>>             {
>>>                 "name": "default",
>>>                 "config": {
>>>                     "name": "default"
>>>                 },
>>>                 "vlans": {
>>>                     "vlan": [
>>>                         {
>>>                             "vlan-id": 10,
>>>                             "config": {
>>>                                 "vlan-id": 10,
>>>                                 "name": "prod",
>>>                                 "status": "ACTIVE"
>>>                             }
>>>                         },
>>>                         {
>>>                             "vlan-id": 20,
>>>                             "config": {
>>>                                 "vlan-id": 20,
>>>                                 "name": "dev",
>>>                                 "status": "SUSPENDED"
>>>                             }
>>>                         }
>>>                     ]
>>>                 }
>>>             }
>>>         ]
>>>     }
>>> }
>>> native = ios_processor.translate(candidate=data)
>>> print(native)
interface FastEthernet1
   description This is Fa1
   shutdown
   exit
!
interface FastEthernet1.1
   description This is Fa1.1
   exit
!
interface FastEthernet1.2
   description This is Fa1.2
   exit
!
interface FastEthernet3
   description This is Fa3
   no shutdown
   switchport mode access
   switchport access vlan 10
   exit
!
interface FastEthernet4
   shutdown
   switchport mode trunk
   switchport trunk allowed vlan 10,20
   exit
!
vlan 10
   name prod
   no shutdown
   exit
!
vlan 20
   name dev
   shutdown
   exit
!

Issues

Bump mistune from 0.8.4 to 2.0.3

opened on 2022-07-29 23:28:29 by dependabot[bot]

Bumps mistune from 0.8.4 to 2.0.3.

Release notes

Sourced from mistune's releases.

Version 2.0.2

Fix escape_url via lepture/mistune#295

Version 2.0.1

Fix XSS for image link syntax.

Version 2.0.0

First release of Mistune v2.

Version 2.0.0 RC1

In this release, we have a Security Fix for harmful links.

Version 2.0.0 Alpha 1

This is the first release of v2. An alpha version for users to have a preview of the new mistune.

Changelog

Sourced from mistune's changelog.

Changelog

Here is the full history of mistune v2.

Version 2.0.4


Released on Jul 15, 2022
  • Fix url plugin in <a> tag
  • Fix * formatting

Version 2.0.3

Released on Jun 27, 2022

  • Fix table plugin
  • Security fix for CVE-2022-34749

Version 2.0.2


Released on Jan 14, 2022

Fix escape_url

Version 2.0.1

Released on Dec 30, 2021

XSS fix for image link syntax.

Version 2.0.0


Released on Dec 5, 2021

This is the first non-alpha release of mistune v2.

Version 2.0.0rc1

Released on Feb 16, 2021

Version 2.0.0a6


</tr></table> 

... (truncated)

Commits
  • 3f422f1 Version bump 2.0.3
  • a6d4321 Fix asteris emphasis regex CVE-2022-34749
  • 5638e46 Merge pull request #307 from jieter/patch-1
  • 0eba471 Fix typo in guide.rst
  • 61e9337 Fix table plugin
  • 76dec68 Add documentation for renderer heading when TOC enabled
  • 799cd11 Version bump 2.0.2
  • babb0cf Merge pull request #295 from dairiki/bug.escape_url
  • fc2cd53 Make mistune.util.escape_url less aggressive
  • 3e8d352 Version bump 2.0.1
  • Additional commits viewable in compare view


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/networktocode/ntc-rosetta/network/alerts).

Documentation: Updating yang library to reflect current openconfig modules

opened on 2022-06-06 16:41:42 by adam-hamilton

I would like to update the openconfig models to reflect the latest in https://github.com/openconfig/public.git

In order to make this work I need to generate an updated file containing JSON-encoded data model specification in the YANG library format.

How can I generate a version of openconfig.json which reflects updated model data? https://github.com/networktocode/ntc-rosetta/blob/develop/ntc_rosetta/yang/openconfig.json

Thank you

Bump notebook from 6.0.3 to 6.4.10

opened on 2022-04-06 19:32:43 by dependabot[bot]

Bumps notebook from 6.0.3 to 6.4.10.

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/networktocode/ntc-rosetta/network/alerts).

Bump ipython from 7.12.0 to 7.16.3

opened on 2022-01-21 20:46:19 by dependabot[bot]

Bumps ipython from 7.12.0 to 7.16.3.

Commits


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/networktocode/ntc-rosetta/network/alerts).

Bump lxml from 4.5.0 to 4.6.5

opened on 2021-12-13 21:02:29 by dependabot[bot]

Bumps lxml from 4.5.0 to 4.6.5.

Changelog

Sourced from lxml's changelog.

4.6.5 (2021-12-12)

Bugs fixed

  • A vulnerability (GHSL-2021-1038) in the HTML cleaner allowed sneaking script content through SVG images.

  • A vulnerability (GHSL-2021-1037) in the HTML cleaner allowed sneaking script content through CSS imports and other crafted constructs.

4.6.4 (2021-11-01)

Features added

  • GH#317: A new property system_url was added to DTD entities. Patch by Thirdegree.

  • GH#314: The STATIC_* variables in setup.py can now be passed via env vars. Patch by Isaac Jurado.

4.6.3 (2021-03-21)

Bugs fixed

  • A vulnerability (CVE-2021-28957) was discovered in the HTML Cleaner by Kevin Chung, which allowed JavaScript to pass through. The cleaner now removes the HTML5 formaction attribute.

4.6.2 (2020-11-26)

Bugs fixed

  • A vulnerability (CVE-2020-27783) was discovered in the HTML Cleaner by Yaniv Nizry, which allowed JavaScript to pass through. The cleaner now removes more sneaky "style" content.

4.6.1 (2020-10-18)

... (truncated)

Commits
  • a9611ba Fix a test in Py2.
  • a3eacbc Prepare release of 4.6.5.
  • b7ea687 Update changelog.
  • 69a7473 Cleaner: cover some more cases where scripts could sneak through in specially...
  • 54d2985 Fix condition in test decorator.
  • 4b220b5 Use the non-depcrecated TextTestResult instead of _TextTestResult (GH-333)
  • d85c6de Exclude a test when using the macOS system libraries because it fails with li...
  • cd4bec9 Add macOS-M1 as wheel build platform.
  • fd0d471 Install automake and libtool in macOS build to be able to install the latest ...
  • f233023 Cleaner: Remove SVG image data URLs since they can embed script content.
  • Additional commits viewable in compare view


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/networktocode/ntc-rosetta/network/alerts).

travis-ci token fix

opened on 2021-09-16 14:35:31 by LoneStar-Swish

Review for PyPI token fix. Ran test locally with Mikhail and verified push to PyPI is working

Releases

v0.2.0 2019-07-27 07:45:03

  • Add management interface (fxp) as an ethernet interface #2
  • Adding et, ae, and irb interfaces to junos #6
  • Junos allow named vlan #8
  • added support for ntc-yang-models #9
  • expose paths so they can be consumed from the outside #12
  • Use fork of openconfig models #13
  • copy vendored files #15
  • Add yangson tutorial and junos config snippet #17
  • load datamodels once and only once and only when/if needed #19

Thanks to:

  • @benmcbenben
  • @dbarrosop
  • @dgjustice

v0.1.0 2019-05-29 09:56:21

First version