{"id":7079,"library":"ciscoconfparse","title":"ciscoconfparse","description":"ciscoconfparse is a Python library designed for parsing, auditing, querying, building, and modifying Cisco IOS-style configurations. It also supports other vendor configurations that follow a similar hierarchical structure. The current version is 1.9.52, but it is considered End of Life, with all new development moving to its successor, `ciscoconfparse2`.","status":"deprecated","version":"1.9.52","language":"en","source_language":"en","source_url":"https://github.com/mpenning/ciscoconfparse","tags":["networking","cisco","configuration","parsing","audit","deprecated","eol"],"install":[{"cmd":"pip install ciscoconfparse","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required runtime environment.","package":"python","optional":false,"version_spec":">=3.8, <4.0.0"},{"reason":"Added as a dependency in versions >= 1.9.41 for enhanced configuration handling.","package":"hier_config","optional":false}],"imports":[{"symbol":"CiscoConfParse","correct":"from ciscoconfparse import CiscoConfParse"}],"quickstart":{"code":"from ciscoconfparse import CiscoConfParse\n\n# Example Cisco configuration lines\nconfig_text = [\n    'hostname Router1',\n    '!',\n    'interface GigabitEthernet0/1',\n    ' description Uplink to Core',\n    ' ip address 192.168.1.1 255.255.255.0',\n    ' no shutdown',\n    '!',\n    'interface GigabitEthernet0/2',\n    ' description Access Port',\n    ' switchport mode access',\n    ' switchport access vlan 10',\n    ' shutdown',\n    '!',\n    'router bgp 65000',\n    '  neighbor 10.0.0.1 remote-as 65001'\n]\n\n# Create a CiscoConfParse object from a list of configuration lines\nparse = CiscoConfParse(config_text)\n\n# Find all interfaces that are administratively shutdown\nshutdown_interfaces = parse.find_parent_objects('^interface', 'shutdown')\n\nif shutdown_interfaces:\n    print('Shutdown Interfaces:')\n    for intf in shutdown_interfaces:\n        # intf.text gives the parent line (e.g., 'interface GigabitEthernet0/2')\n        print(f'- {intf.text}')\nelse:\n    print('No shutdown interfaces found.')\n\n# Find all interfaces with an IP address\ninterfaces_with_ip = parse.find_objects_w_child(parentspec='^interface', childspec='ip address')\n\nif interfaces_with_ip:\n    print('\\nInterfaces with IP addresses:')\n    for intf in interfaces_with_ip:\n        ip_line = intf.re_search_children(r'ip address (\\S+ \\S+)', result_type=str, group=1)\n        if ip_line:\n            print(f'- {intf.text}: {ip_line}')\n","lang":"python","description":"This quickstart demonstrates how to initialize `CiscoConfParse` with a list of configuration lines and then use `find_parent_objects` to locate shutdown interfaces and `find_objects_w_child` to find interfaces with IP addresses. The library supports searching using regular expressions."},"warnings":[{"fix":"Migrate your code to `ciscoconfparse2` by installing `pip install ciscoconfparse2` and updating import statements and API calls. Review `ciscoconfparse2` documentation for migration guidance, as APIs are not fully compatible.","message":"`ciscoconfparse` is End of Life (EOL) as of December 2023. No further updates or bug fixes will be released for this package. Users are strongly recommended to migrate to `ciscoconfparse2`, its successor, which is a different PyPI project with a streamlined API and breaking changes.","severity":"breaking","affected_versions":"All versions"},{"fix":"Always call `parse.commit()` or `parse.atomic()` after any modification operations before performing further searches on the updated configuration object.","message":"When modifying a configuration within a `CiscoConfParse` object (e.g., `delete_lines`, `insert_before`), subsequent search methods like `find_objects()` will not reflect these changes until `commit()` or `atomic()` is explicitly called.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Initialize `CiscoConfParse` with `ignore_blank_lines=False` if blank lines are significant to your parsing requirements. Example: `parse = CiscoConfParse(config_data, ignore_blank_lines=False)`.","message":"The `ignore_blank_lines` parameter in `CiscoConfParse` defaults to `True`. This means blank lines in your configuration input will be ignored. If your configurations intentionally use blank lines (e.g., for visual separation) and these are critical for your parsing logic, this default might cause unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `parse.find_objects()` instead of `parse.find_lines()`. Access text via `obj.text` on the returned `IOSCfgLine` objects.","message":"The method `find_lines()` which returns a list of text strings is deprecated in favor of `find_objects()` which returns a list of `IOSCfgLine` objects. Working with `IOSCfgLine` objects is more powerful and efficient for traversing parent/child relationships.","severity":"deprecated","affected_versions":"Versions >= 0.9"},{"fix":"For exact matches, use the `exactmatch=True` parameter if available, or anchor your regular expressions appropriately (e.g., `^interface GigabitEthernet3/2$` for an exact match to the end of the line).","message":"When using methods like `find_children()` or `find_objects()` with a simple string or regex, results might be broader than intended (e.g., `interface GigabitEthernet3/2` matching `interface GigabitEthernet3/21`).","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 the input `config` is either a Python list of strings (e.g., `config_string.splitlines()`) or a valid file path string: `parse = CiscoConfParse(config_lines_list)` or `parse = CiscoConfParse('/path/to/config.txt')`.","cause":"The `CiscoConfParse` constructor expects either a list of configuration lines (strings) or a string representing a file path to the configuration, but received a different type or an improperly formatted string.","error":"TypeError: config must be a list of strings or a filepath"},{"fix":"Call `parse.commit()` or `parse.atomic()` immediately after any modification method to update the internal configuration representation before performing new searches.","cause":"Modifications made to the configuration object (e.g., using `delete_lines`, `insert_before`) are not immediately reflected in the internal parsing structure. Subsequent search queries will operate on the old structure until the changes are committed.","error":"Unexpected or incomplete search results after modifying the configuration object (e.g., after delete_lines)."},{"fix":"When performing configuration modifications, ensure your logic explicitly handles the removal of old, conflicting commands before adding new ones. Consider using `replace_children()` or `replace_all_children()` methods if applicable, or generate a proper diff and apply only the necessary changes.","cause":"Directly editing a configuration string or object and then applying it back to a live device without explicit logic for managing the delta can lead to issues. Commands might be added redundantly, or conflicting commands (e.g., `switchport mode access` vs `switchport mode trunk`) may not be correctly removed/added to achieve the desired state.","error":"Modified configuration copied back to a device results in duplicated commands or incorrect state."}]}