Skip to main content

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
!

Metadata

Release files for ntc-rosetta 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ntc-rosetta 0.2.1
File Size Uploaded Provenance
ntc_rosetta-0.2.1.tar.gz 453.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ntc-rosetta 0.2.1
File Interpreter ABI Platform
ntc_rosetta-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / ntc_rosetta-0.2.1.tar.gz

Download URL ntc_rosetta-0.2.1.tar.gz
Size 453.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4474f614f3be2aa5819b53f7663b209e8aa3e46e16f36548d2f5289e7119b5cc
BLAKE2b-256 checksum
How to use checksums
eda2622d81c2a4215b112be0d76bbb234fca4ea2ef10709c7ee5c393c029e226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/3.6.14 Linux/5.10.47-linuxkit

Release files / ntc_rosetta-0.2.1-py3-none-any.whl

Download URL ntc_rosetta-0.2.1-py3-none-any.whl
Size 615.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa780093cb2b73a3daa8bc5700c05ae7764133d3400b5d74eda45613ec1767a0
BLAKE2b-256 checksum
How to use checksums
c99252dd608d6985e9679d661aff60973a46d79d8864589b948c14adc0af146d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/3.6.14 Linux/5.10.47-linuxkit

Security for ntc-rosetta 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page