{"id":18797797,"url":"https://github.com/networktocode/ntc-rosetta","last_synced_at":"2025-04-13T08:23:19.082Z","repository":{"id":35962465,"uuid":"189195038","full_name":"networktocode/ntc-rosetta","owner":"networktocode","description":"The missing bridge between industry standard CLIs and YANG","archived":false,"fork":false,"pushed_at":"2023-08-30T00:12:27.000Z","size":904,"stargazers_count":104,"open_issues_count":12,"forks_count":23,"subscribers_count":55,"default_branch":"develop","last_synced_at":"2025-04-04T13:51:23.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ntc-rosetta.readthedocs.io/en/latest/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/networktocode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-29T09:33:55.000Z","updated_at":"2025-01-10T06:38:34.000Z","dependencies_parsed_at":"2022-08-08T12:31:16.783Z","dependency_job_id":"98ee6caa-03d9-461d-8d61-70a0492725bd","html_url":"https://github.com/networktocode/ntc-rosetta","commit_stats":{"total_commits":59,"total_committers":9,"mean_commits":6.555555555555555,"dds":0.576271186440678,"last_synced_commit":"a4a34ae3fa01e8b087d49fcb709a97aefecb19f4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networktocode%2Fntc-rosetta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networktocode%2Fntc-rosetta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networktocode%2Fntc-rosetta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networktocode%2Fntc-rosetta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/networktocode","download_url":"https://codeload.github.com/networktocode/ntc-rosetta/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681836,"owners_count":21144758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T22:09:38.447Z","updated_at":"2025-04-13T08:23:19.046Z","avatar_url":"https://github.com/networktocode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ntc_rosetta\n\nntc_rosetta leverages [yangify](https://github.com/networktocode/yangify) to implement a set of \"drivers\" that can:\n\n1. Transform network devices' native configuration/state into structured data that conform to YANG models\n2. Transform data structures that conform to YANG models into network device's native configuration/data structures\n3. Merge configurations\n\n## Installing NTC Rosetta\n\n### Pip Install\n\n`pip install ntc-rosetta`\n\n### Install From Source\n\n- Clone ntc-rosetta (`git clone https://github.com/networktocode/ntc-rosetta.git`)\n- cd into project root (`cd ntc-rosetta`)\n- `pip install poetry`\n- `poetry install`\n\n## Ways to get started with NTC Rosetta\n\n- Start Executing Jupyter Notebooks\n- [Read the Docs](https://ntc-rosetta.readthedocs.io/en/latest/index.html)\n\n### Start Executing Jupyter Notebooks\n\n#### Step 1\n\nClone the repository:\n`$ git clone https://github.com/networktocode/ntc-rosetta.git`\n\n#### Step 2\n\nChange directory into `ntc-rosetta`:\n`$ cd ntc-rosetta`\n\n#### Step 3\n\nBuild the containers:\n`$ make build_test_containers`\n\n#### Step 4\n\nStart a container so you can run the Jupyter notebooks:\n`$ make jupyter`\n\n#### Step 5\n\nLaunch a browser and navigate to the following URL:\n`http://127.0.0.1:8888/tree/docs/tutorials`\n\nThe same notebooks can be viewed without being interactive in the NTC Rosetta Read the Docs.\n\n## Parsing\n\n    \u003e\u003e\u003e from ntc_rosetta import get_driver\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e ios = get_driver(\"ios\", \"openconfig\")\n    \u003e\u003e\u003e ios_driver = ios()\n    \u003e\u003e\u003e with open(\"data/ios/config.txt\", \"r\") as f:\n    \u003e\u003e\u003e     config = f.read()\n    \u003e\u003e\u003e print(config)\n    interface FastEthernet1\n       description This is Fa1\n       shutdown\n       exit\n    !\n    vlan 10\n       name prod\n       no shutdown\n       exit\n    !\n    vlan 20\n       name dev\n       shutdown\n       exit\n    !\n    \u003e\u003e\u003e parsed = ios_driver.parse(native={\"dev_conf\": config})\n    \u003e\u003e\u003e import json\n    \u003e\u003e\u003e print(json.dumps(parsed.raw_value(), indent=4))\n    {\n        \"openconfig-interfaces:interfaces\": {\n            \"interface\": [\n                {\n                    \"name\": \"FastEthernet1\",\n                    \"config\": {\n                        \"name\": \"FastEthernet1\",\n                        \"type\": \"iana-if-type:ethernetCsmacd\",\n                        \"description\": \"This is Fa1\",\n                        \"enabled\": false\n                    },\n                    \"subinterfaces\": {\n                        \"subinterface\": [\n                            {\n                                \"index\": 1,\n                                \"config\": {\n                                    \"index\": 1,\n                                    \"description\": \"This is Fa1.1\"\n                                }\n                            },\n                            {\n                                \"index\": 2,\n                                \"config\": {\n                                    \"index\": 2,\n                                    \"description\": \"This is Fa1.2\"\n                                }\n                            }\n                        ]\n                    }\n                },\n            ]\n        },\n        \"openconfig-network-instance:network-instances\": {\n            \"network-instance\": [\n                {\n                    \"name\": \"default\",\n                    \"config\": {\n                        \"name\": \"default\"\n                    },\n                    \"vlans\": {\n                        \"vlan\": [\n                            {\n                                \"vlan-id\": 10,\n                                \"config\": {\n                                    \"vlan-id\": 10,\n                                    \"name\": \"prod\",\n                                    \"status\": \"ACTIVE\"\n                                }\n                            },\n                            {\n                                \"vlan-id\": 20,\n                                \"config\": {\n                                    \"vlan-id\": 20,\n                                    \"name\": \"dev\",\n                                    \"status\": \"SUSPENDED\"\n                                }\n                            }\n                        ]\n                    }\n                }\n            ]\n        }\n    }\n\n## Translating\n\n    \u003e\u003e\u003e from ntc_rosetta import get_driver\n    \u003e\u003e\u003e \n    \u003e\u003e\u003e ios = get_driver(\"ios\", \"openconfig\")\n    \u003e\u003e\u003e ios_processor = ios()\n    \u003e\u003e\u003e data = {\n    \u003e\u003e\u003e     \"openconfig-interfaces:interfaces\": {\n    \u003e\u003e\u003e         \"interface\": [\n    \u003e\u003e\u003e             {\n    \u003e\u003e\u003e                 \"name\": \"FastEthernet1\",\n    \u003e\u003e\u003e                 \"config\": {\n    \u003e\u003e\u003e                     \"name\": \"FastEthernet1\",\n    \u003e\u003e\u003e                     \"type\": \"iana-if-type:ethernetCsmacd\",\n    \u003e\u003e\u003e                     \"description\": \"This is Fa1\",\n    \u003e\u003e\u003e                     \"enabled\": False\n    \u003e\u003e\u003e                 },\n    \u003e\u003e\u003e                 \"subinterfaces\": {\n    \u003e\u003e\u003e                     \"subinterface\": [\n    \u003e\u003e\u003e                         {\n    \u003e\u003e\u003e                             \"index\": 1,\n    \u003e\u003e\u003e                             \"config\": {\n    \u003e\u003e\u003e                                 \"index\": 1,\n    \u003e\u003e\u003e                                 \"description\": \"This is Fa1.1\"\n    \u003e\u003e\u003e                             }\n    \u003e\u003e\u003e                         },\n    \u003e\u003e\u003e                         {\n    \u003e\u003e\u003e                             \"index\": 2,\n    \u003e\u003e\u003e                             \"config\": {\n    \u003e\u003e\u003e                                 \"index\": 2,\n    \u003e\u003e\u003e                                 \"description\": \"This is Fa1.2\"\n    \u003e\u003e\u003e                             }\n    \u003e\u003e\u003e                         }\n    \u003e\u003e\u003e                     ]\n    \u003e\u003e\u003e                 }\n    \u003e\u003e\u003e             },\n    \u003e\u003e\u003e         ]\n    \u003e\u003e\u003e     },\n    \u003e\u003e\u003e     \"openconfig-network-instance:network-instances\": {\n    \u003e\u003e\u003e         \"network-instance\": [\n    \u003e\u003e\u003e             {\n    \u003e\u003e\u003e                 \"name\": \"default\",\n    \u003e\u003e\u003e                 \"config\": {\n    \u003e\u003e\u003e                     \"name\": \"default\"\n    \u003e\u003e\u003e                 },\n    \u003e\u003e\u003e                 \"vlans\": {\n    \u003e\u003e\u003e                     \"vlan\": [\n    \u003e\u003e\u003e                         {\n    \u003e\u003e\u003e                             \"vlan-id\": 10,\n    \u003e\u003e\u003e                             \"config\": {\n    \u003e\u003e\u003e                                 \"vlan-id\": 10,\n    \u003e\u003e\u003e                                 \"name\": \"prod\",\n    \u003e\u003e\u003e                                 \"status\": \"ACTIVE\"\n    \u003e\u003e\u003e                             }\n    \u003e\u003e\u003e                         },\n    \u003e\u003e\u003e                         {\n    \u003e\u003e\u003e                             \"vlan-id\": 20,\n    \u003e\u003e\u003e                             \"config\": {\n    \u003e\u003e\u003e                                 \"vlan-id\": 20,\n    \u003e\u003e\u003e                                 \"name\": \"dev\",\n    \u003e\u003e\u003e                                 \"status\": \"SUSPENDED\"\n    \u003e\u003e\u003e                             }\n    \u003e\u003e\u003e                         }\n    \u003e\u003e\u003e                     ]\n    \u003e\u003e\u003e                 }\n    \u003e\u003e\u003e             }\n    \u003e\u003e\u003e         ]\n    \u003e\u003e\u003e     }\n    \u003e\u003e\u003e }\n    \u003e\u003e\u003e native = ios_processor.translate(candidate=data)\n    \u003e\u003e\u003e print(native)\n    interface FastEthernet1\n       description This is Fa1\n       shutdown\n       exit\n    !\n    interface FastEthernet1.1\n       description This is Fa1.1\n       exit\n    !\n    interface FastEthernet1.2\n       description This is Fa1.2\n       exit\n    !\n    interface FastEthernet3\n       description This is Fa3\n       no shutdown\n       switchport mode access\n       switchport access vlan 10\n       exit\n    !\n    interface FastEthernet4\n       shutdown\n       switchport mode trunk\n       switchport trunk allowed vlan 10,20\n       exit\n    !\n    vlan 10\n       name prod\n       no shutdown\n       exit\n    !\n    vlan 20\n       name dev\n       shutdown\n       exit\n    !\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworktocode%2Fntc-rosetta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetworktocode%2Fntc-rosetta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworktocode%2Fntc-rosetta/lists"}