{"id":8192,"library":"genie","title":"Genie","description":"Genie is the standard Python Library System built on top of the pyATS framework, providing a rich set of parsers (Genie Ops) and configuration builders (Genie Conf) for network devices, primarily Cisco platforms. It enables network engineers and developers to automate network operations, testing, and configuration management. The current version is 26.3, and it follows the pyATS release cadence, with major updates typically aligning with major pyATS releases.","status":"active","version":"26.3","language":"en","source_language":"en","source_url":"https://github.com/CiscoTestAutomation/genie","tags":["network","automation","pyats","testing","cisco","devnet","networking"],"install":[{"cmd":"pip install genie","lang":"bash","label":"Install Genie"}],"dependencies":[{"reason":"Genie is built on the pyATS framework and requires a compatible pyATS core installation.","package":"pyats","optional":false}],"imports":[{"note":"While older Genie versions or specific internal Genie modules might use `genie.testbed.Testbed`, the most common and correct way to load a pyATS/Genie testbed is via `pyats.topology.Testbed`.","wrong":"from genie.testbed import Testbed","symbol":"Testbed","correct":"from pyats.topology import Testbed"},{"note":"The `parse()` method on a `pyats.topology.Device` object (extended by Genie) is the primary way to use Genie Ops. You don't directly import `genie.libs.ops` classes for this.","symbol":"device.parse","correct":"output = device.parse('show version')"},{"note":"Similar to `parse()`, `configure()` is a method on the Device object leveraging Genie Conf. Direct imports of `genie.libs.conf` objects are less common for basic configuration.","symbol":"device.configure","correct":"device.configure('interface Loopback0\\n ip address 1.1.1.1 255.255.255.255')"}],"quickstart":{"code":"import os\nfrom pyats.topology import Testbed\n\n# Create a dummy testbed YAML file for the example\ntestbed_content = \"\"\"\ndevices:\n  router1:\n    os: iosxe\n    type: router\n    connections:\n      cli:\n        protocol: ssh\n        ip: 127.0.0.1\n        port: 22\n    credentials:\n      default:\n        username: {}\n        password: {}\n\"\"\".format(os.environ.get('GENIE_DEVICE_USERNAME', 'cisco'),\n           os.environ.get('GENIE_DEVICE_PASSWORD', 'cisco'))\n\ntestbed_path = \"temp_genie_testbed.yaml\"\nwith open(testbed_path, \"w\") as f:\n    f.write(testbed_content)\n\ntry:\n    # Load the testbed using pyATS\n    testbed = Testbed(testbed_path)\n    print(f\"Successfully loaded testbed from {testbed_path}\")\n\n    # Access a device defined in the testbed\n    device = testbed.devices['router1']\n    print(f\"Accessed device: {device.name}\")\n    print(f\"Device OS: {device.os}\")\n    print(f\"Device Type: {device.type}\")\n\n    # To perform actual operations (like device.parse() or device.connect()),\n    # a live connection to a network device is required.\n    # Example (will fail without connection, for demonstration only):\n    # try:\n    #     device.connect()\n    #     output = device.parse('show version')\n    #     print(f\"Parsed 'show version': {output.keys()}\")\n    # finally:\n    #     if device.is_connected():\n    #         device.disconnect()\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up the dummy testbed file\n    if os.path.exists(testbed_path):\n        os.remove(testbed_path)\n","lang":"python","description":"This quickstart demonstrates how to set up a basic testbed YAML, load it using `pyats.topology.Testbed`, and access a device object. It uses environment variables for credentials to keep the example runnable without exposing sensitive data. Note that methods like `device.connect()` and `device.parse()` require an actual network device connection to function, which is omitted for a fully runnable, non-network-dependent example."},"warnings":[{"fix":"Always install `genie` and `pyats` together or ensure their versions are compatible as specified in the official pyATS release notes. `pip install pyats genie` will often install compatible versions.","message":"Genie is tightly coupled with pyATS. Mismatched versions between `genie` and `pyats` core packages are a frequent cause of `ImportError`, `AttributeError`, or unexpected behavior.","severity":"breaking","affected_versions":"All versions, especially across major pyATS/Genie releases (e.g., pyATS 23.x with Genie 23.x, pyATS 24.x with Genie 24.x)."},{"fix":"Ensure your Python environment meets the `requires_python` specification from PyPI, currently `>=3.8` for Genie 26.x.","message":"Python version compatibility. Genie (and pyATS) strictly enforce minimum Python versions. Using an unsupported Python version will lead to installation failures or runtime errors.","severity":"gotcha","affected_versions":"All versions, especially when upgrading Python environments."},{"fix":"Consult the release notes for Genie and pyATS for changes in Ops/Conf models. Update your scripts to reflect the new data structures. Consider using `pip install --upgrade pyats genie` for minor updates, but carefully review changes for major updates.","message":"Genie Ops (`device.parse()`) and Conf (`device.configure()`) output/input structures can change between major releases. This can break existing automation scripts that rely on specific keys or nested data structures.","severity":"breaking","affected_versions":"Major Genie releases (e.g., 23.x to 24.x, 24.x to 25.x)."},{"fix":"Refer to the latest pyATS documentation for the current testbed YAML schema. Use `pyats parse testbed <your_testbed.yaml>` to validate your testbed file.","message":"Testbed YAML schema can evolve. Using an outdated or malformed testbed YAML file with a newer version of pyATS/Genie can lead to schema validation errors.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change your import statement to `from pyats.topology import Testbed`.","cause":"You are trying to import `Testbed` directly from `genie.testbed`, but in current pyATS/Genie versions, the `Testbed` class is part of the `pyats.topology` module.","error":"ImportError: cannot import name 'Testbed' from 'genie.testbed'"},{"fix":"Ensure `genie` is installed (`pip install genie`) and that your testbed device `os` attribute (e.g., `os: iosxe`) is correctly specified and supported by Genie.","cause":"The `parse` method is added to `pyats.topology.Device` objects by Genie. This error usually means Genie is not correctly installed, or the device's OS in the testbed is not recognized by Genie Ops, preventing the extension.","error":"AttributeError: 'Device' object has no attribute 'parse'"},{"fix":"Review your testbed YAML against the official pyATS documentation. Use the `pyats parse testbed <your_testbed.yaml>` command to get detailed schema validation feedback and identify the exact line/issue.","cause":"The testbed YAML file contains syntax errors, is missing required fields, or uses an outdated schema that is no longer valid for your installed pyATS/Genie version.","error":"pyats.exceptions.SchemaError: Testbed schema validation failed:"}]}