Add a method to predict the running config after a change is applied
This feature is useful in cases where you need to determine what the configuration state will be after a change is applied. Such as:
Ensuring that a configuration change was applied successfully to a device.
i.e. Does the post-change config match the predicted future config?
Providing a future state config that can be fed into batfish, or similar, to predict if a change will cause an impact.
Building rollback configs. If you have the future config state, then generating a rollback config can be done by simply building the remediation config in the reverse direction rollback = future.config_to_get_to(running).
If you are building rollbacks for a series of config changes, you can feed the post-change-1 future config into the process for determining the post-change-2 future config e.g.
In [1]: from hier_config import HConfig, Host
...:
...:
...: host = Host("test.dfw1", "ios")
...: running_config = HConfig(host)
...: running_config.load_from_file("./tests/fixtures/running_config.conf")
...: remediation_config = HConfig(host)
...: remediation_config.load_from_file("./tests/fixtures/remediation_config_without_tags.conf")
...: future_config = running_config.future(remediation_config)
...:
...: print("\n##### running config")
...: for line in running_config.all_children():
...: print(line.cisco_style_text())
...:
...: print("\n##### remediation config")
...: for line in remediation_config.all_children():
...: print(line.cisco_style_text())
...:
...: print("\n##### future config")
...: for line in future_config.all_children():
...: print(line.cisco_style_text())
...:
##### running config
hostname aggr-example.rtr
ip access-list extended TEST
10 permit ip 10.0.0.0 0.0.0.7 any
vlan 2
name switch_mgmt_10.0.2.0/24
vlan 3
name switch_mgmt_10.0.4.0/24
interface Vlan2
descripton switch_10.0.2.0/24
ip address 10.0.2.1 255.255.255.0
shutdown
interface Vlan3
mtu 9000
description switch_mgmt_10.0.4.0/24
ip address 10.0.4.1 255.255.0.0
ip access-group TEST in
no shutdown
##### remediation config
vlan 3
name switch_mgmt_10.0.3.0/24
vlan 4
name switch_mgmt_10.0.4.0/24
interface Vlan2
mtu 9000
ip access-group TEST in
no shutdown
interface Vlan3
description switch_mgmt_10.0.3.0/24
ip address 10.0.3.1 255.255.0.0
interface Vlan4
mtu 9000
description switch_mgmt_10.0.4.0/24
ip address 10.0.4.1 255.255.0.0
ip access-group TEST in
no shutdown
##### future config
vlan 3
name switch_mgmt_10.0.3.0/24
vlan 4
name switch_mgmt_10.0.4.0/24
interface Vlan2
mtu 9000
ip access-group TEST in
descripton switch_10.0.2.0/24
ip address 10.0.2.1 255.255.255.0
interface Vlan3
description switch_mgmt_10.0.3.0/24
ip address 10.0.3.1 255.255.0.0
mtu 9000
ip address 10.0.4.1 255.255.0.0
ip access-group TEST in
no shutdown
interface Vlan4
mtu 9000
description switch_mgmt_10.0.4.0/24
ip address 10.0.4.1 255.255.0.0
ip access-group TEST in
no shutdown
hostname aggr-example.rtr
ip access-list extended TEST
10 permit ip 10.0.0.0 0.0.0.7 any
vlan 2
name switch_mgmt_10.0.2.0/24
Add a method to predict the running config after a change is applied
This feature is useful in cases where you need to determine what the configuration state will be after a change is applied. Such as:
rollback = future.config_to_get_to(running)
.