{"id":8190,"library":"genie-libs-parser","title":"Genie Libs Parser","description":"Genie Libs Parser, currently at version 26.3, is a sub-component of the pyATS and Genie framework designed to parse raw device output (CLI, XML, YANG) into structured Python data structures. It provides a vast collection of parsers for various network operating systems and commands. The project follows a regular release cadence, often aligned with pyATS and Genie releases, with frequent additions of new parsers and APIs. [2, 8]","status":"active","version":"26.3","language":"python","source_language":"en","source_url":"https://github.com/CiscoTestAutomation/genieparser","tags":["network automation","Cisco","pyATS","parsing","CLI","structured data"],"install":[{"cmd":"pip install pyats[full]","lang":"bash","label":"Recommended for full Genie/pyATS functionality"},{"cmd":"pip install genie","lang":"bash","label":"Installs Genie and its components, including parsers"}],"dependencies":[{"reason":"genie-libs-parser is a core component of the pyATS framework.","package":"pyats","optional":false},{"reason":"Provides the overall library system and device abstraction for parser interaction.","package":"genie","optional":false},{"reason":"The underlying engine for creating and managing parsers.","package":"genie.metaparser","optional":false}],"imports":[{"wrong":"from pyats.topology import loader","symbol":"loader","correct":"from pyats.topology import loader"},{"wrong":"from pyats.topology import loader","symbol":"parse","correct":"from pyats.utils import parse"}],"quickstart":{"code":"import os\nfrom pyats.topology import Device\nfrom genie.libs.parser.iosxe.show_version import ShowVersion\n\n# Simulate a device object for demonstration (in a real scenario, use pyats.topology.loader)\ndevice = Device(name='my_router', os='iosxe')\n# This is a hack to allow parsing without an active connection, typically used for offline parsing\ndevice.custom.setdefault('abstraction', {})['order'] = ['os', 'platform']\n\n# Simulate CLI output\ncli_output = '''\nCisco IOS XE Software, Version 17.03.04a\nCisco IOS Software [Dublin], ISR Software (X86_64_LINUX_IOSD_UNIVERSALK9-VIRT_STD_ML), Version 17.3.4a, RELEASE SOFTWARE (fc2)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2021 by Cisco Systems, Inc.\nCompiled Wed 21-Apr-21 02:40 by mcpre\n\nROM: System Bootstrap, Version 17.3.1R\n\nmy_router uptime is 1 week, 2 days, 3 hours, 4 minutes\nSystem returned to ROM by reload\nSystem image file is \"bootflash:isr4400-universalk9.17.03.04a.SPA.bin\"\nLast reload reason: PowerSupplyFailure\n'''\n\n# --- Option 1: Using device.parse() (recommended) ---\n# In a real scenario, device.parse() would execute the command on the device.\n# For offline parsing, you can pass the 'output' argument.\nparsed_data_via_device = device.parse('show version', output=cli_output)\nprint(\"Parsed data via device.parse():\\n\", parsed_data_via_device)\n\n# --- Option 2: Directly instantiating a parser class (less common for general use) ---\nparser = ShowVersion(device=device) # The device object provides context (OS, etc.)\nparsed_data_via_class = parser.parse(output=cli_output)\nprint(\"\\nParsed data via direct class instantiation:\\n\", parsed_data_via_class)\n","lang":"python","description":"This quickstart demonstrates how to use `genie-libs-parser` to parse device CLI output into a structured dictionary. It shows both the recommended `device.parse()` method (simulating output for offline use) and direct instantiation of a parser class. A dummy `Device` object is created to provide the necessary context for the parsers. In a live environment, the `device` object would be loaded from a pyATS testbed and connected to a physical or virtual device. [8 in previous search, 1]"},"warnings":[{"fix":"Always validate parsed output against expected schema, especially after device OS upgrades. Consider using Genie's 'learn' feature for baseline validation and 'diff' for change detection. If an existing parser fails, it may require a fix or a custom parser to be developed. [9 in previous search]","message":"Parser schemas and regex patterns are highly dependent on the exact CLI output of a device. Minor changes in device OS versions or command output formatting can cause parsers to fail silently or return incomplete data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update connection configurations to use the `credentials` dictionary within your testbed YAML or device object, e.g., `device.credentials.default.username = 'admin'`. [5 in previous search]","message":"Direct arguments like 'username', 'enable_password' for Unicon (a core pyATS connection library) have been deprecated and replaced by a 'credentials' dictionary.","severity":"breaking","affected_versions":"Older pyATS/Genie versions leading up to and including some 24.x versions. (Specifically noted in a GitHub issue dated April 2020 related to Unicon plugins)."},{"fix":"If encountering parsing issues with Nornir multi-worker setups, consider collecting output with Nornir and then processing it with Genie in a single-threaded manner, or limit Nornir's worker count to 1 for parser-intensive tasks. [18 in previous search]","message":"When running pyATS/Genie with Nornir using multiple workers, issues have been reported where Genie processing can fail.","severity":"gotcha","affected_versions":"Reported with Nornir 2.20 and older pyATS/Genie versions."},{"fix":"Check the traceback for the specific parser file and line number. If it's a built-in parser, ensure your `genie-libs-parser` package is up to date. If it's a custom parser, review the Python syntax. [15 in previous search]","message":"Some parser modules might contain syntax errors, particularly in older or custom parsers, leading to `SyntaxError` exceptions during execution.","severity":"gotcha","affected_versions":"Specific versions where a parser file might have been introduced with a bug."}],"env_vars":null,"search_vec":"'2':72 '26.3':10 '8':73 'addit':66 'align':58 'api':71 'autom':75 'cadenc':56 'cisco':76 'cli':28,79 'collect':40 'command':49 'compon':15 'current':7 'data':34,81 'design':22 'devic':26 'follow':52 'framework':21 'frequent':65 'geni':1,4,20,62 'lib':2,5 'network':45,74 'new':68 'often':57 'oper':46 'output':27 'pars':24,78 'parser':3,6,42,69 'project':51 'provid':37 'pyat':18,60,77 'python':33 'raw':25 'regular':54 'releas':55,63 'structur':32,35,80 'sub':14 'sub-compon':13 'system':47 'various':44 'vast':39 'version':9 'xml':29 'yang':30","created_at":"2026-04-16T17:00:53.867232+00:00","updated_at":"2026-04-16T17:00:53.867232+00:00","problems":null,"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/genie-libs-parser/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}