hier_config
hier_config copied to clipboard
POC | Sectional Exiting at Parent Level
In [1]: from hier_config import WorkflowRemediation, get_hconfig, Platform
In [3]: running_config_text = """
...: prefix-set ALL
...: 0.0.0.0/0 eq 32
...: end-set
...: !
...: prefix-set PEERINGS
...: 1.1.1.1/32,
...: 2.2.2.2/32,
...: 10.0.1.0/24,
...: 172.16.0.0/12,
...: 192.168.3.0/26
...: end-set
...: """
In [4]: generated_config_text = """
...: prefix-set ALL
...: 0.0.0.0/0 eq 32
...: end-set
...: !
...: prefix-set PEERINGS
...: 1.1.1.1/32,
...: 172.16.0.0/12,
...: 192.168.3.0/26
...: end-set
...: """
In [5]: running_config = get_hconfig(Platform.CISCO_XR, running_config_text)
...: generated_config = get_hconfig(Platform.CISCO_XR, generated_config_text)
In [6]: workflow = WorkflowRemediation(running_config, generated_config)
In [7]: print(workflow.remediation_config)
prefix-set PEERINGS
1.1.1.1/32,
172.16.0.0/12,
192.168.3.0/26
end-set
In [8]: pfx = running_config.get_child(equals="prefix-set ALL")
...: pfx.sectional_exit_text_parent_level
Out[8]: True