{"id":7834,"library":"unicon","title":"Unicon Connection Library","description":"Unicon is a Python package that provides a unified connection experience to network devices via typical command-line management interfaces (CLI). It serves as the standard CLI connection implementation within the Cisco pyATS framework, offering direct and proxied connections, expect-like programming, and multi-vendor support through an agnostic API. Initially developed internally by Cisco, it was released publicly in late 2017 through Cisco DevNet. [1, 2, 12] The current version is 26.3, released on April 2, 2026, and the project maintains an active release cadence, often aligned with the broader pyATS/Genie framework releases. [2, 23]","status":"active","version":"26.3","language":"python","source_language":"en","source_url":"https://github.com/CiscoTestAutomation/unicon.plugins","tags":["networking","device management","network automation","cli","cisco","pyats"],"install":[{"cmd":"pip install unicon","lang":"bash","label":"Install Unicon"}],"dependencies":[{"reason":"Used for parsing YAML configurations, common in pyATS testbeds.","package":"pyyaml","optional":false},{"reason":"Likely used for formatting output in a tabular manner.","package":"PrettyTable","optional":false},{"reason":"Required for secure communication protocols like SSH.","package":"cryptography","optional":false}],"imports":[{"wrong":"from unicon.core.connection import Connection","symbol":"Connection","correct":"from unicon import Connection"}],"quickstart":{"code":"import os\nfrom unicon.core.connection import Connection\n\n# Replace with your device details and credentials\ndevice_settings = {\n    'hostname': os.environ.get('DEVICE_HOSTNAME', '10.0.0.1'),\n    'os': os.environ.get('DEVICE_OS', 'ios'), # e.g., ios, nxos, iosxe\n    'type': os.environ.get('DEVICE_TYPE', 'router'),\n    'username': os.environ.get('DEVICE_USERNAME', 'admin'),\n    'password': os.environ.get('DEVICE_PASSWORD', 'Cisco123'),\n    'enable_password': os.environ.get('DEVICE_ENABLE_PASSWORD', 'Cisco123'),\n}\n\ntry:\n    # Create a connection instance\n    conn = Connection(hostname=device_settings['hostname'],\n                      os=device_settings['os'],\n                      type=device_settings['type'],\n                      start_state='exec') # Specify the initial state to reach\n\n    # Provide credentials (Unicon can also retrieve from testbed YAML)\n    conn.settings.CLI_USERNAME = device_settings['username']\n    conn.settings.CLI_PASSWORD = device_settings['password']\n    conn.settings.CLI_ENABLE_PASSWORD = device_settings['enable_password']\n\n    # Connect to the device\n    print(f\"Connecting to {device_settings['hostname']}...\")\n    conn.connect()\n    print(\"Connection successful.\")\n\n    # Execute a command\n    output = conn.execute('show version')\n    print(\"\\n--- show version output ---\")\n    print(output)\n\n    # Disconnect from the device\n    conn.disconnect()\n    print(\"Disconnected.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to establish a basic CLI connection to a network device using Unicon, execute a command, and then disconnect. It uses environment variables for sensitive credentials for security and easy testing. [12]"},"warnings":[{"fix":"Ensure your Python environment is 3.8 or higher. Upgrade Python or activate a compatible virtual environment. [2]","message":"Unicon's Python compatibility officially requires Python 3.8 or newer. Using older Python versions will lead to installation failures or runtime errors.","severity":"breaking","affected_versions":"< 26.0"},{"fix":"Install `unicon.plugins` (`pip install unicon.plugins`). Refer to Cisco DevNet documentation for supported platforms and necessary plugins for your specific device. [1, 12]","message":"Unicon relies heavily on plugins for specific device platforms and OS capabilities. If you encounter issues connecting to a device or executing specific commands, ensure you have the correct `unicon.plugins` package installed and that it supports your target device/OS combination.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Start with common error patterns (e.g., `^%Error`, `^% Invalid`, `Timeout`). Test against various error conditions on your target devices. Use regular expressions carefully and consider broad patterns like `%.*?%` for general error messages, then refine to avoid false positives. Consult device documentation for expected error messages. [24]","message":"When using `conn.execute()` with `reply` or `error_pattern` arguments, comprehensively listing all possible CLI error patterns or prompts for a given command can be challenging due to vendor/OS variations. Incomplete patterns may lead to command failures or timeouts.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1':72 '12':74 '2':73,83,101 '2017':68 '2026':84 '23':102 '26.3':79 'activ':90 'agnost':55 'align':94 'api':56 'april':82 'autom':107 'broader':97 'cadenc':92 'cisco':36,61,70,109 'cli':25,31,108 'command':21 'command-lin':20 'connect':2,13,32,43 'current':76 'develop':58 'devic':17,104 'devnet':71 'direct':40 'expect':45 'expect-lik':44 'experi':14 'framework':38,99 'implement':33 'initi':57 'interfac':24 'intern':59 'late':67 'librari':3 'like':46 'line':22 'maintain':88 'manag':23,105 'multi':50 'multi-vendor':49 'network':16,103,106 'offer':39 'often':93 'packag':8 'program':47 'project':87 'provid':10 'proxi':42 'public':65 'pyat':37,110 'pyats/genie':98 'python':7 'releas':64,80,91,100 'serv':27 'standard':30 'support':52 'typic':19 'unicon':1,4 'unifi':12 'vendor':51 'version':77 'via':18 'within':34","created_at":"2026-04-16T14:15:23.814783+00:00","updated_at":"2026-04-16T14:15:23.814783+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp565wlhtl/venv/lib/python3.12/site-packages/unicon/__init__.py\", line 16, in <module>\n    __plugin_manager__.discover_builtin_plugins()\n  File \"src/unicon/core/pluginmanager.py\", line 258, in unicon.core.pluginm"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"26.5","cli_name":"","cli_version":null,"type":"library","homepage":"https://developer.cisco.com/pyats/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/unicon/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}