{ "info": { "author": "David Barroso", "author_email": "dbarrosop@dravetech.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# 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## Parsing\n\n >>> from ntc_rosetta import get_driver\n >>>\n >>> ios = get_driver(\"ios\", \"openconfig\")\n >>> ios_driver = ios()\n >>> with open(\"data/ios/config.txt\", \"r\") as f:\n >>> config = f.read()\n >>> 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 >>> parsed = ios_driver.parse(native={\"dev_conf\": config})\n >>> import json\n >>> 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 >>> from ntc_rosetta import get_driver\n >>> \n >>> ios = get_driver(\"ios\", \"openconfig\")\n >>> ios_processor = ios()\n >>> data = {\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 >>> native = ios_processor.translate(candidate=data)\n >>> 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", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "Apache-2.0", "maintainer": "David Barroso", "maintainer_email": "dbarrosop@dravetech.com", "name": "ntc-rosetta", "package_url": "https://pypi.org/project/ntc-rosetta/", "platform": "", "project_url": "https://pypi.org/project/ntc-rosetta/", "project_urls": null, "release_url": "https://pypi.org/project/ntc-rosetta/0.2.0/", "requires_dist": [ "jmespath (>=0.9.3,<0.10.0)", "lxml (>=4.3,<5.0)", "click (>=7.0,<8.0)", "yangify (>=0.1.1,<0.2.0)" ], "requires_python": ">=3.6,<4.0", "summary": "The missing bridge between industry standard CLIs and YANG", "version": "0.2.0" }, "last_serial": 5592216, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "1665e88032e0c62d33dba76798184b42", "sha256": "1cec9b6d374338fa3a377eed57615e2be0dba33015d5dddf1eecf4cb9882883f" }, "downloads": -1, "filename": "ntc_rosetta-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1665e88032e0c62d33dba76798184b42", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 560845, "upload_time": "2019-05-29T10:39:14", "url": "https://files.pythonhosted.org/packages/db/ea/36f74940389bcd017a3b8a5350354e6f2ade946b96e14d428202efeda6b8/ntc_rosetta-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "228d07c039be7867c962b18764c21d45", "sha256": "4622aa909f32f5f331cb50ff5cacf5a62367b640322bc82fa72911b55e390b44" }, "downloads": -1, "filename": "ntc_rosetta-0.1.0.tar.gz", "has_sig": false, "md5_digest": "228d07c039be7867c962b18764c21d45", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 412611, "upload_time": "2019-05-29T10:39:17", "url": "https://files.pythonhosted.org/packages/a5/e9/387f04fc1c9a98324d7fd8654eea7782ed1ff5d894f292f6e2deca3d076c/ntc_rosetta-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "a79442de3b1deb39168ee493f2ddf5ec", "sha256": "b08309af9f27fbdbafe01d3d06768217c6cbf7ab748d02112a5bd4c7f0cbacca" }, "downloads": -1, "filename": "ntc_rosetta-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a79442de3b1deb39168ee493f2ddf5ec", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 600943, "upload_time": "2019-07-27T07:56:54", "url": "https://files.pythonhosted.org/packages/6c/b6/9a07daa1bda825b7a10a65b65dba4e2e1c6ac8d9c7b2d9635e5f09d50113/ntc_rosetta-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a1cf220ee0cdddec4cb5c25f2fa1225a", "sha256": "5e8c6d495131600758b8e5fcdc721357209d114d07be4bca5daa84a9984fbfea" }, "downloads": -1, "filename": "ntc_rosetta-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a1cf220ee0cdddec4cb5c25f2fa1225a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 437854, "upload_time": "2019-07-27T07:56:57", "url": "https://files.pythonhosted.org/packages/d9/9d/2510ddb595cc69de9b0ee59a47bab275a8f1092f985b54802b62e3c39e8b/ntc_rosetta-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a79442de3b1deb39168ee493f2ddf5ec", "sha256": "b08309af9f27fbdbafe01d3d06768217c6cbf7ab748d02112a5bd4c7f0cbacca" }, "downloads": -1, "filename": "ntc_rosetta-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a79442de3b1deb39168ee493f2ddf5ec", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 600943, "upload_time": "2019-07-27T07:56:54", "url": "https://files.pythonhosted.org/packages/6c/b6/9a07daa1bda825b7a10a65b65dba4e2e1c6ac8d9c7b2d9635e5f09d50113/ntc_rosetta-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a1cf220ee0cdddec4cb5c25f2fa1225a", "sha256": "5e8c6d495131600758b8e5fcdc721357209d114d07be4bca5daa84a9984fbfea" }, "downloads": -1, "filename": "ntc_rosetta-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a1cf220ee0cdddec4cb5c25f2fa1225a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 437854, "upload_time": "2019-07-27T07:56:57", "url": "https://files.pythonhosted.org/packages/d9/9d/2510ddb595cc69de9b0ee59a47bab275a8f1092f985b54802b62e3c39e8b/ntc_rosetta-0.2.0.tar.gz" } ] }