{"library":"napalm","title":"NAPALM: Network Automation and Programmability Abstraction Layer with Multivendor Support","description":"NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is a Python library that provides a unified API to interact with various network devices from different vendors (e.g., Cisco IOS/XR/NX-OS, Arista EOS, Juniper Junos). It abstracts away vendor-specific complexities, offering a consistent way to retrieve operational data and manage configurations. The current version is 5.1.0, with regular releases, typically major updates every 6-12 months and minor/patch releases in between.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install napalm","pip install napalm[full]"],"cli":{"name":"napalm","version":"usage: napalm [-h] [--user USER] [--password PASSWORD] --vendor VENDOR"}},"imports":["from napalm import get_network_driver","from napalm.base.exceptions import NapalmBaseException"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from napalm import get_network_driver\n\ndef connect_and_get_facts(hostname, username, password):\n    try:\n        driver = get_network_driver(\"ios\") # Replace 'ios' with your device type (e.g., 'eos', 'junos', 'nxos')\n        device = driver(\n            hostname,\n            username,\n            password,\n            optional_args={\n                \"port\": 22, # Or 830 for NETCONF, 443 for API\n                \"secret\": \"\", # If using privilege escalation\n                \"config_file\": None # Path to an external config file\n            }\n        )\n        print(f\"Connecting to {hostname}...\")\n        device.open()\n        print(f\"Successfully connected to {hostname}.\")\n        \n        facts = device.get_facts()\n        print(\"Device Facts:\")\n        for k, v in facts.items():\n            print(f\"  {k}: {v}\")\n            \n        # Example: Get interface details\n        # interfaces = device.get_interfaces()\n        # print(\"Interfaces:\", interfaces)\n            \n    except Exception as e:\n        print(f\"Error connecting or retrieving data: {e}\")\n    finally:\n        if 'device' in locals() and device.is_open:\n            device.close()\n            print(f\"Disconnected from {hostname}.\")\n\nif __name__ == \"__main__\":\n    # Replace with your actual device details\n    DEVICE_HOSTNAME = os.environ.get('NAPALM_TEST_HOSTNAME', '192.168.1.1')\n    DEVICE_USERNAME = os.environ.get('NAPALM_TEST_USERNAME', 'admin')\n    DEVICE_PASSWORD = os.environ.get('NAPALM_TEST_PASSWORD', 'password')\n    \n    # Make sure to set these environment variables or change the default values\n    connect_and_get_facts(DEVICE_HOSTNAME, DEVICE_USERNAME, DEVICE_PASSWORD)","lang":"python","description":"This quickstart demonstrates how to connect to a network device using NAPALM, retrieve basic device facts, and properly close the connection. Remember to replace the placeholder credentials and device type with your actual network environment details. For production, use environment variables or a secure credential management system.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}