{ "info": { "author": "Network to Code", "author_email": "ntc@networktocode.com", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://travis-ci.org/networktocode/pyntc.svg?branch=master)](https://travis-ci.org/networktocode/pyntc) [![Coverage Status](https://coveralls.io/repos/github/networktocode/pyntc/badge.svg?branch=master)](https://coveralls.io/github/networktocode/pyntc?branch=master)\n\n# Introduction\n\npyntc is an open source multi-vendor Python library that establishes a common framework for working with different network APIs & device types (including IOS devices)\n\nIt's main purpose to is to simplify the execution of common tasks including:\n - Executing commands\n - Copying files\n - Upgrading devices\n - Rebooting devices\n - Saving / Backing Up Configs\n\n# Supported Platforms\n\n* Cisco IOS platforms - uses SSH (netmiko)\n* Cisco NX-OS - uses pynxos (NX-API)\n* Arista EOS - uses pyeapi (eAPI)\n* Juniper Junos - uses PyEz (NETCONF)\n\nIt is a multi-vendor AND multi-API library.\n\n# Installing pyntc\n\nOption 1:\n\n```\n\"sudo pip install pyntc\" or \"sudo pip install pyntc --upgrade\"\n```\n\nOption 2:\n\n```\ngit clone https://github.com/networktocode/pyntc.git\ncd pyntc\nsudo python setup.py install\n```\n\n\n# Getting Started with pyntc\n\nThere are two ways to get started with pyntc. \n\nThe first way is to use the `ntc_device` object. Just pass in all required parameters to the object to initialize your device. Here we are showing the import, but renaming the object to `NTC`.\n\n```\n>>> from pyntc import ntc_device as NTC\n>>> \n```\n\nLike many libraries, we need to pass in the host/IP and credentials. Because this is a multi-vendor/API library, we also use the `device_type` parameter to identify which device we are building an instance of.\n\npyntc currently supports four device types:\n* cisco_ios_ssh\n* cisco_nxos_nxapi\n* arista_eos_eapi\n* juniper_junos_netconf\n\nThe example below shows how to build a device object when working with a Cisco IOS router.\n\n```\n>>> # CREATE DEVICE OBJECT FOR AN IOS DEVICE\n>>> \n>>> csr1 = NTC(host='csr1', username='ntc', password='ntc123', device_type='cisco_ios_ssh')\n>>>\n```\n\nAnd here is an object for a Cisco Nexus device:\n\n```\n>>> # CREATE DEVICE OBJECT FOR A NEXUS DEVICE\n>>> \n>>> nxs1 = NTC(host='nxos-spine1', username='ntc', password='ntc123', device_type='cisco_nxos_nxapi')\n>>> \n```\n\nThe second way to get started with pyntc is to use the pyntc configuration file. This was modeled after Arista's `.eapi.conf` file. Our file is called `.ntc.conf`\n\nThis simplifies creating device objects since you no longer need to specify credentials and other device specific parameters when you build the device object. Instead, they are stored in the conf file.\n\n\n# pyntc Configration File\n\n- filename: `.ntc.conf`\n- Priority of locating the conf file:\n - `filename` param in `ntc_device_by_name` \n - Environment Variable aka `PYNTC_CONF`\n - Home directory `.ntc.conf`\n- Specify device_type and a name \n- host is not required if the name is the device's FQDN\n- Four supported device types: `cisco_nxos_nxapi`, `cisco_ios_ssh`, `arista_eos_eapi`, and `juniper_junos_netconf`\n\nHere is an example `.ntc.conf` file:\n\n```bash\n[cisco_nxos_nxapi:nxos-spine1]\nhost: 31.220.64.117\nusername: ntc\npassword: ntc123\ntransport: http\n\n[cisco_ios_ssh:csr1]\nhost: 176.126.88.94\nusername: ntc\npassword: ntc123\nport: 22\n\n[juniper_junos_netconf:vmx1]\nhost: 176.126.88.99\nusername: ntc\npassword: ntc123\n\n```\n\nWe can now build device objects just by referencing the name of the device from the conf file.\n\n```\n>>> from pyntc import ntc_device_by_name as NTCNAME\n>>> \n>>> csr1 = NTCNAME('csr1')\n>>>\n>>> nxs1 = NTCNAME('nxos-spine1')\n>>> \n>>> vmx1 = NTCNAME('vmx1')\n```\n\n\nOnce the device object is creating using either `ntc_device` or `ntc_device_by_name`, you can start using the built-in device methods in pyntc.\n\nNote: the only method and property not supported on all devices is `install_os`. It is not supported on Juniper Junos devices.\n\n### Gathering Facts\n\n- Use `facts` device property\n\nOn a Nexus device:\n\n```\n>>> nxs1 = NTCNAME('nxos-spine1')\n>>> \n>>> nxs1.facts\n{'vendor': 'cisco', 'interfaces': [], u'hostname': 'nxos-spine1', u'os_version': '7.1(0)D1(1) [build 7.2(0)ZD(0.17)]', u'serial_number': 'TM600C2833B', u'model': 'NX-OSv Chassis', 'vlans': ['1']}\n>>> \n>>> print(json.dumps(nxs1.facts, indent=4))\n{\n \"vendor\": \"cisco\", \n \"interfaces\": [], \n \"hostname\": \"nxos-spine1\", \n \"os_version\": \"7.1(0)D1(1) [build 7.2(0)ZD(0.17)]\", \n \"serial_number\": \"TM600C2833B\", \n \"model\": \"NX-OSv Chassis\", \n \"vlans\": [\n \"1\"\n ]\n}\n```\n\nOn an IOS device:\n\n```\n>>> csr1 = NTCNAME('csr1')\n>>> \n>>> print(json.dumps(csr1.facts, indent=4))\n{\n \"uptime\": 87060, \n \"vendor\": \"cisco\", \n \"uptime_string\": \"01:00:11:00\", \n \"interfaces\": [\n \"GigabitEthernet1\", \n \"GigabitEthernet2\", \n \"GigabitEthernet3\", \n \"GigabitEthernet4\", \n \"Loopback100\"\n ], \n \"hostname\": \"csr1\", \n \"ios\": {\n \"config_register\": \"0x2102\"\n }, \n \"fqdn\": \"N/A\", \n \"os_version\": \"15.5(1)S1\", \n \"serial_number\": \"\", \n \"model\": \"CSR1000V\", \n \"vlans\": []\n}\n\n```\n\n### Sending Show Commands\n\n- `show` method\n- Note: API enabled devices return JSON by default\n\n```\n>>> nxs1.show('show hostname')\n{'hostname': 'nxos-spine1'}\n>>>\n```\n\n- Use `raw_text=True` to get unstructured data from the device\n\n```\n>>> nxs1.show('show hostname', raw_text=True)\n'nxos-spine1 \\n'\n>>> \n```\n\n### Sending Multiple Commands\n\n- `show_list` method\n\n```\n>>> cmds = ['show hostname', 'show run int Eth2/1']\n\n>>> data = nxs1.show_list(cmds, raw_text=True)\n```\n\n```\n>>> for d in data:\n... print(d)\n... \nnxos-spine1 \n\n!Command: show running-config interface Ethernet2/1\n!Time: Wed Jan 6 18:10:01 2016\nversion 7.1(0)D1(1)\ninterface Ethernet2/1\n switchport\n no shutdown\n```\n\n### Config Commands\n\n- Use `config` and `config_list`\n\n```\n>>> csr1.config('hostname testname')\n>>> \n```\n\n```\n>>> csr1.config_list(['interface Gi3', 'shutdown'])\n>>> \n```\n\n### Viewing Running/Startup Configs\n\n- Use `running_config` and `start_up` device properties\n - Only showing partial config (manually shortened for this slide)\n\n```\n>>> run = csr1.running_config\n>>> \n>>> print(run)\nBuilding configuration...\n\nCurrent configuration : 2062 bytes\n!\n! Last configuration change at 18:26:59 UTC Wed Jan 6 2016 by ntc\n!\nversion 15.5\nservice timestamps debug datetime msec\n\nlldp run\ncdp run\n!\nip scp server enable\n!\ninterface GigabitEthernet1\n ip address 10.0.0.50 255.255.255.0\n cdp enable\n```\n\n### Copying files\n\n- `file_copy` method\n\n```\n>>> devices = [csr1, nxs1]\n>>> \n>>> for device in devices:\n... device.file_copy('newconfig.cfg')\n...\n>>>\n```\n\n### Save Configs\n\n- `save` method\n\n`copy run start` for Cisco/Arista and `commit` for Juniper\n\n```\n>>> csr1.save()\nTrue\n\n```\n\nYou can also do the equivalent of `copy running-config ` by specifying a filename:\n\n```\n>>> csr1.save('mynewconfig.cfg')\nTrue\n```\n\n### Backup Configs\n\nBackup current running configuration and store it locally\n\n```\n>>> csr1.backup_running_config('csr1.cfg')\n>>> \n```\n\n### Reboot\n\nReboot target device\n\nParameters:\n - `timer=0` by default\n - `confirm=False` by default\n\n```\n>>> csr1.reboot(confirm=True)\n>>> \n```\n\n### Installing Operating Systems\n\n```\n>>> device.install_os('nxos.7.0.3.I2.1.bin')\n>>> \n```\n\nFull workflow example:\n\n```\n>>> device.file_copy('nxos.7.0.3.I2.1.bin')\n>>> device.install_os('nxos.7.0.3.I2.1.bin')\n>>> device.save()\n>>> device.reboot() # IF NEEDED, NXOS automatically reboots\n>>> \n```\n\n\n\n\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/networktocode/pyntc", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyntc", "package_url": "https://pypi.org/project/pyntc/", "platform": "", "project_url": "https://pypi.org/project/pyntc/", "project_urls": { "Homepage": "https://github.com/networktocode/pyntc" }, "release_url": "https://pypi.org/project/pyntc/0.0.9/", "requires_dist": [ "requests>=2.7.0", "jsonschema", "future", "netmiko", "paramiko", "pynxos>=0.0.3", "coverage", "mock>=1.3", "textfsm", "terminal", "f5-sdk", "bigsuds", "pyeapi", "junos-eznc", "scp" ], "requires_python": "", "summary": "Kickoff functions for getting instancs of device objects.", "version": "0.0.9" }, "last_serial": 4540242, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "aae97352c2be4148f5a002b4a7be59b4", "sha256": "0044563918da63514523aee2dd2a8e6ce1ad87a37ec4bf203df52cba809c2297" }, "downloads": -1, "filename": "pyntc-0.0.1.tar.gz", "has_sig": false, "md5_digest": "aae97352c2be4148f5a002b4a7be59b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12193, "upload_time": "2016-02-04T21:38:22", "url": "https://files.pythonhosted.org/packages/c5/fa/0b0180a210d8ec65cf439f0f1c4243e900c7b57890ac684fb13264b22cde/pyntc-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "7e6fd19f0680749172dc74c92fdf9f06", "sha256": "4f12beac46895b227c92b01c7108bf558fb5892409825ba5c18f982aeb997c38" }, "downloads": -1, "filename": "pyntc-0.0.2.tar.gz", "has_sig": false, "md5_digest": "7e6fd19f0680749172dc74c92fdf9f06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12197, "upload_time": "2016-02-04T22:33:16", "url": "https://files.pythonhosted.org/packages/87/f6/eed30eace33b9e3da599e246d4f545dcea86a4c8588bab89a08d6c36387c/pyntc-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "ea209eddee57a1ac2a3a9977a2247d40", "sha256": "57004b90998f199805120f58d3016088671e890597b950254cef83b3ef6af86e" }, "downloads": -1, "filename": "pyntc-0.0.3.tar.gz", "has_sig": false, "md5_digest": "ea209eddee57a1ac2a3a9977a2247d40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14388, "upload_time": "2016-03-14T22:01:20", "url": "https://files.pythonhosted.org/packages/e6/00/0c0f352c46f462a642aef62075b9117f71f2eb4f50c3f87a8c2a71c54940/pyntc-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "58b31fe1698909eaf37d9d21581455a8", "sha256": "bac1dfc365e2b0f22066262af32fe128005265671ead23feb502647cf90bbbee" }, "downloads": -1, "filename": "pyntc-0.0.4.tar.gz", "has_sig": false, "md5_digest": "58b31fe1698909eaf37d9d21581455a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14440, "upload_time": "2016-10-29T16:26:28", "url": "https://files.pythonhosted.org/packages/d4/62/c22a9bae4e727f5a559fd1c2c2a1a738938ff956894c2b5fa636eb4cfda4/pyntc-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "5a1304d52554e754f763f39a2dbf6f1e", "sha256": "c6fdafd7187e92aa58c9e535dd12540a70883f97946dae600e98f7d74386fcf0" }, "downloads": -1, "filename": "pyntc-0.0.5.tar.gz", "has_sig": false, "md5_digest": "5a1304d52554e754f763f39a2dbf6f1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14439, "upload_time": "2016-10-29T16:31:32", "url": "https://files.pythonhosted.org/packages/b0/2d/d7001e8f5c2976bf7571378c02bfca33dd1a414c64c236db9b48ee5f12f6/pyntc-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "831f371cf5dda7f7ef3bd7a9861cc28b", "sha256": "97e117956fdcc2223687cc205173ba6fc483a98ba5af65b15cfbf2c6c4f3d9fe" }, "downloads": -1, "filename": "pyntc-0.0.6.tar.gz", "has_sig": false, "md5_digest": "831f371cf5dda7f7ef3bd7a9861cc28b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14585, "upload_time": "2018-07-05T12:30:27", "url": "https://files.pythonhosted.org/packages/f3/4f/0c44671abf2f73197594d13178014d973d42c0e5f042794c5ab99d3eac9e/pyntc-0.0.6.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "76a03aba49c0de8a0be0f4d37b9493dd", "sha256": "2a50f952edb657beff9d9b846de61b21dbab5d376941e25b953fa0caead2783f" }, "downloads": -1, "filename": "pyntc-0.0.8.tar.gz", "has_sig": false, "md5_digest": "76a03aba49c0de8a0be0f4d37b9493dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21915, "upload_time": "2018-10-16T21:53:44", "url": "https://files.pythonhosted.org/packages/f1/2b/ad68076cdd8d1cccee130c9af7c5865f86cf1bc9e600230c861bf9f6bca8/pyntc-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "45e137fe0937407c01101d862a8dbcba", "sha256": "bfe056848e22077810cc83fb66a51b5dbfb238984951413da418dd573f88d615" }, "downloads": -1, "filename": "pyntc-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "45e137fe0937407c01101d862a8dbcba", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 112144, "upload_time": "2018-11-28T21:11:38", "url": "https://files.pythonhosted.org/packages/69/11/5845a8062f379259ef8748ad1e0cc39a6abd4cdb422c5233b4455601d96a/pyntc-0.0.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "293f0148f474a16c5a8929f8baad9c19", "sha256": "2b95d262d6d8023d991120fea698f5a5313acd7cf8d6daa8b2d2b5a879e70150" }, "downloads": -1, "filename": "pyntc-0.0.9.tar.gz", "has_sig": false, "md5_digest": "293f0148f474a16c5a8929f8baad9c19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 53600, "upload_time": "2018-11-28T21:11:51", "url": "https://files.pythonhosted.org/packages/1c/00/643949512b61f89931b85a8a996cf1e3573b97b619dc1706e632e2ceb8bd/pyntc-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "45e137fe0937407c01101d862a8dbcba", "sha256": "bfe056848e22077810cc83fb66a51b5dbfb238984951413da418dd573f88d615" }, "downloads": -1, "filename": "pyntc-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "45e137fe0937407c01101d862a8dbcba", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 112144, "upload_time": "2018-11-28T21:11:38", "url": "https://files.pythonhosted.org/packages/69/11/5845a8062f379259ef8748ad1e0cc39a6abd4cdb422c5233b4455601d96a/pyntc-0.0.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "293f0148f474a16c5a8929f8baad9c19", "sha256": "2b95d262d6d8023d991120fea698f5a5313acd7cf8d6daa8b2d2b5a879e70150" }, "downloads": -1, "filename": "pyntc-0.0.9.tar.gz", "has_sig": false, "md5_digest": "293f0148f474a16c5a8929f8baad9c19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 53600, "upload_time": "2018-11-28T21:11:51", "url": "https://files.pythonhosted.org/packages/1c/00/643949512b61f89931b85a8a996cf1e3573b97b619dc1706e632e2ceb8bd/pyntc-0.0.9.tar.gz" } ] }