{"id":8188,"library":"genie-libs-conf","title":"Genie Configuration Libraries (genie-libs-conf)","description":"Genie libs Conf is a Python library within the pyATS/Genie framework, designed to configure network device topologies through Python object attributes. It provides a programmatic way to define and apply configurations, often used in network automation and testing. Version 26.3 is current, and releases typically align with the broader pyATS/Genie framework, which has a regular, frequent release cycle.","status":"active","version":"26.3","language":"en","source_language":"en","source_url":"https://github.com/CiscoTestAutomation/genie.libs.conf","tags":["network-automation","cisco","pyats","genie","configuration-management","iosxe"],"install":[{"cmd":"pip install genie-libs-conf","lang":"bash","label":"Install core library"},{"cmd":"pip install genie","lang":"bash","label":"Install core Genie framework (recommended for 'Genie' object)"}],"dependencies":[{"reason":"Provides configuration schema definitions required by conf objects.","package":"genie.libs.schema"},{"reason":"Core data structures for the pyATS framework.","package":"pyats.datastructures","optional":true},{"reason":"Provides the top-level 'Genie' object for managing devices and configurations, essential for practical use.","package":"genie","optional":true}],"imports":[{"symbol":"Device","correct":"from genie.libs.conf.base import Device"},{"symbol":"Interface","correct":"from genie.libs.conf.interface import Interface"},{"note":"'Genie' class is part of the core 'genie' package, not 'genie.libs.conf'.","wrong":"from genie.libs.conf import Genie","symbol":"Genie","correct":"from genie.conf import Genie"}],"quickstart":{"code":"from genie.conf import Genie\nfrom genie.libs.conf.base import Device\nfrom genie.libs.conf.interface import Interface\n\n# Create a new Genie configuration object\ngen = Genie()\n\n# Create a device and add it to Genie\ndevice = Device(name='my_router', os='iosxe')\ngen.add_device(device)\n\n# Configure an interface on the device\nintf = Interface(name='GigabitEthernet1', device=device)\nintf.description = 'Management Interface'\nintf.ip_address = '192.168.1.1/24'\nintf.shutdown = False\n\n# Build and print the configuration string\nconfig_string = device.build_config()\nprint(f\"Generated Configuration for {device.name}:\\n{config_string}\")\n\n# Expected output might look like:\n# interface GigabitEthernet1\n#  description Management Interface\n#  ip address 192.168.1.1 255.255.255.0\n#  no shutdown","lang":"python","description":"This quickstart demonstrates how to create a `Genie` instance, define a `Device`, and then configure an `Interface` with IP address and description using `genie.libs.conf` objects, finally generating the CLI configuration string."},"warnings":[{"fix":"Consult the official `pyATS` release notes and documentation for your specific version to adapt API calls, especially for `Genie` and `Device` object methods.","message":"API Changes in PyATS/Genie Major Versions: Older `pyATS`/`Genie` versions (e.g., pre-20.x) might use different API patterns for configuration objects or methods (e.g., `config_builder` instead of `build_config` directly on device objects). Migration is needed.","severity":"breaking","affected_versions":"< 20.0"},{"fix":"Ensure configuration objects are correctly associated with their parent objects, typically through the object's constructor (e.g., `Interface(..., device=device)`) or by adding them to the parent's feature list where appropriate.","message":"Incorrect Hierarchical Assignment: Attempting to assign configuration objects (e.g., an `Interface` object) directly to a `Device` object's attribute without using proper constructors or `add_feature` can lead to unexpected behavior or no configuration generation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the specific configuration object's schema documentation to verify attribute names, expected types, and valid values. Some attributes might use common names (like `ip_address`) which are internally mapped.","message":"Schema Attribute Naming Mismatches: Incorrect attribute names (e.g., `ip_address` vs `ipv4_address`) or data types when setting configuration values on `genie.libs.conf` objects can silently fail to generate the desired configuration or raise schema validation errors during `build_config`.","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":"Ensure your `Device` instance is created with `Device(name='...', os='...')` and added to the `Genie` instance using `gen.add_device(device)`.","cause":"The `Device` object was not properly initialized or added to the `Genie` instance, making its internal state incomplete.","error":"AttributeError: 'NoneType' object has no attribute 'build_config'"},{"fix":"Check the `genie.libs.conf` documentation or the source code for the specific object (e.g., `Interface`) to verify the correct attribute name and its expected type.","cause":"You are trying to set an attribute on a `genie.libs.conf` object that does not exist in its defined schema or is misspelled. The attribute might be valid in a different context or spelled differently (e.g. `ipv4_address`).","error":"KeyError: 'Cannot set attribute ip_address, it does not exist in the schema.'"},{"fix":"Install the core `genie` package using `pip install genie` (or `pip install pyats[full]` for the entire framework).","cause":"The `genie.conf` package (which provides the top-level `Genie` object) is not installed. `genie-libs-conf` itself doesn't include it.","error":"ModuleNotFoundError: No module named 'genie.conf'"}]}