diff --git a/CHANGES.md b/CHANGES.md index b5a7db1..58360bf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,12 @@ ## Version: 0.7.32 +- Released: 2024-03-17 +- Summary: + - Add `options_ios.hier_config.yml` + +## Version: 0.7.32 + - Released: 2024-03-17 - Summary: - Update tests diff --git a/ciscoconfparse2/ciscoconfparse2.py b/ciscoconfparse2/ciscoconfparse2.py index 4af06c3..66beeab 100644 --- a/ciscoconfparse2/ciscoconfparse2.py +++ b/ciscoconfparse2/ciscoconfparse2.py @@ -3703,7 +3703,7 @@ def __init__(self, # _ represents ios options as a dict... for now we use an empty # dict below... try: - _ = yaml.load(open('./options_ios.yml'), Loader=yaml.SafeLoader) + _ = yaml.load(open('./options_ios.hier_config.yml'), Loader=yaml.SafeLoader) except FileNotFoundError: pass diff --git a/options_ios.hier_config.yml b/options_ios.hier_config.yml new file mode 100644 index 0000000..78a3cc5 --- /dev/null +++ b/options_ios.hier_config.yml @@ -0,0 +1,123 @@ +--- +############################################################# +# heir_config yml file +############################################################# +# Indicates the style of the configuration +style: ios + +# if there is a delta, negate the parents and re-write the parents with children +sectional_overwrite: [] + +# if there is a delta, overwrite these parents instead of one of their children +sectional_overwrite_no_negate: [] + +# The default order value is 500, with a range between 1 - 999. +# Commands with smaller order values float to the top in the order of execution. +# Commands with larger order values float to the bottom in the order of execution. +# Syntax Example: +# - lineage: +# - startswith: +# - no route-map +# order: 600 +ordering: +- lineage: + - startswith: no vlan filter + order: 700 +- lineage: + - startswith: interface + - startswith: no shutdown + order: 700 + +# adds +1 indent to lines following start_expression and removes the +1 indent for lines following end_expression +indent_adjust: [] + +parent_allows_duplicate_child: [] + +sectional_exiting: +# This rule is used in the hierarchical_configuration unit test for .add_section_exiting() +- lineage: + - startswith: router bgp + - startswith: template peer-policy + exit_text: exit-peer-policy +- lineage: + - startswith: router bgp + - startswith: template peer-session + exit_text: exit-peer-session +- lineage: + - startswith: router bgp + - startswith: address-family + exit_text: exit-address-family + +# substitions against the full multi-line config text +full_text_sub: [] +#- search: 'banner\s(exec|motd)\s(\S)\n(.*\n){1,}(\2)' +# replace: '' +#- search: 'banner\s(exec|motd)\s(\S.).+\n(.*\n){1,}.*(\2)' +# replace: '' +#- search: 'banner\s(exec|motd)\s(\S.)\n(.*\n){1,}(\2)' +# replace: '' + +# substitions against each line of the config text +per_line_sub: +- search: ^Building configuration.* + replace: '' +- search: ^Current configuration.* + replace: '' +- search: ^! Last configuration change.* + replace: '' +- search: ^! NVRAM config last updated.* + replace: '' +- search: ^ntp clock-period .* + replace: '' +- search: ^version.* + replace: '' +- search: ^ logging event link-status$ + replace: '' +- search: ^ logging event subif-link-status$ + replace: '' +- search: ^\s*ipv6 unreachables disable$ + replace: '' +- search: ^end$ + replace: '' +- search: '^\s*[#!].*' + replace: '' +- search: ^ no ip address + replace: '' +- search: ^ exit-peer-policy + replace: '' +- search: ^ exit-peer-session + replace: '' +- search: ^ exit-address-family + replace: '' +- search: ^crypto key generate rsa general-keys.*$ + replace: '' + +idempotent_commands_blacklist: [] + +# These commands do not require negation, they simply overwrite themselves +# Example Syntax +# - lineage: +# - startswith: interface +# - startswith: description +idempotent_commands: +- lineage: + - startswith: vlan + - startswith: name +- lineage: + - startswith: interface + - startswith: description +- lineage: + - startswith: interface + - startswith: ip address + +# Default when expression: list of expressions +negation_default_when: [] + +# Negate substitutions: expression -> negate with +# Example Syntax: +# - lineage: +# - startswith: route-map +# - startswith: description +# use: no description +negation_negate_with: [] + diff --git a/pyproject.toml b/pyproject.toml index e15fa3f..92b3d8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [project] name = "ciscoconfparse2" -version = "0.7.32" +version = "0.7.33" description = "Parse, Audit, Query, Build, and Modify Cisco IOS-style and JunOS-style configs" readme = "README.md" license = "GPL-3.0-only"