diff --git a/docs/colliecting-diffs.md b/docs/colliecting-diffs.md index b5cd95f..565c0bf 100644 --- a/docs/colliecting-diffs.md +++ b/docs/colliecting-diffs.md @@ -63,6 +63,41 @@ After script is done you can find results in `Config Compliances` menu. Each dev Also result is storing rendered and actual configurations from devices. +Compliance finished with error + +![Screenshot of the compliance error](media/screenshots/compliance-error.png) + +Render diff between configurations + +![Screenshot of diff](media/screenshots/compliance-diff.png) + +No diff + +![Screenshot of the compliance ok](media/screenshots/compliance-ok.png) + +### Patch commands + +With [hier_config](https://github.com/netdevops/hier_config) library you are able to take a actual configuration of a network device, compare it to its rendered configuration, + and build the remediation steps necessary to bring a device into spec with its intended configuration. + +![Screenshot of the patch commands](media/screenshots/compliance-patch.png) + +Supported platforms: + +* Arista EOS (arista_eos) +* Cisco IOS-XE (cisco_iosxe) +* Cisco IOS-XR (cisco_iosxr) +* Cisco NX-OS (cisco_nxos) + +However, any NOS that utilizes a CLI syntax that is structured in a similar fasion to IOS should work mostly out of the box. + +NOS's that utilize a `set` based CLI syntax has been added as experimental functionality: + +* Juniper JunOS (juniper_junos) +* VyOS (vyos_vyos) + +### Missing/extra + With the help of [netutils](https://github.com/networktocode/netutils) library plugin stores missing and extra config lines. ![Screenshot of the missing/extra lines](media/screenshots/compliance-missing-extra.png) @@ -81,15 +116,3 @@ Supported platforms for missing/extra lines: * Nokia SROS (nokia_sros) * PaloAlto PanOS (paloalto_panos) * Ruckus FastIron (ruckus_fastiron) - -Compliance finished with error - -![Screenshot of the compliance error](media/screenshots/compliance-error.png) - -Render diff between configurations - -![Screenshot of diff](media/screenshots/compliance-diff.png) - -No diff - -![Screenshot of the compliance ok](media/screenshots/compliance-ok.png) diff --git a/docs/media/screenshots/compliance-patch.png b/docs/media/screenshots/compliance-patch.png new file mode 100644 index 0000000..b70509e Binary files /dev/null and b/docs/media/screenshots/compliance-patch.png differ diff --git a/netbox_config_diff/compliance/base.py b/netbox_config_diff/compliance/base.py index 187f05d..48a945c 100644 --- a/netbox_config_diff/compliance/base.py +++ b/netbox_config_diff/compliance/base.py @@ -18,14 +18,7 @@ from netbox_config_diff.models import ConplianceDeviceDataClass from .secrets import SecretsMixin -from .utils import ( - PLATFORM_MAPPING, - REMEDIATION_MAPPING, - CustomChoiceVar, - exclude_lines, - get_remediation_commands, - get_unified_diff, -) +from .utils import PLATFORM_MAPPING, CustomChoiceVar, exclude_lines, get_remediation_commands, get_unified_diff class ConfigDiffBase(SecretsMixin): @@ -211,7 +204,6 @@ def get_diff(self, devices: list[ConplianceDeviceDataClass]) -> None: device.extra = diff_network_config( cleaned_config, device.rendered_config, PLATFORM_MAPPING[device.platform] ) - if device.platform in REMEDIATION_MAPPING: - device.patch = get_remediation_commands( - device.name, device.platform, cleaned_config, device.rendered_config - ) + device.patch = get_remediation_commands( + device.name, device.platform, cleaned_config, device.rendered_config + ) diff --git a/netbox_config_diff/compliance/utils.py b/netbox_config_diff/compliance/utils.py index 6802258..7451a71 100644 --- a/netbox_config_diff/compliance/utils.py +++ b/netbox_config_diff/compliance/utils.py @@ -56,7 +56,7 @@ def exclude_lines(text: str, regexs: list) -> str: def get_remediation_commands(name: str, platform: str, actual_config: str, rendered_config: str) -> str: - host = Host(hostname=name, os=REMEDIATION_MAPPING.get(platform)) + host = Host(hostname=name, os=REMEDIATION_MAPPING.get(platform, "ios")) host.load_running_config(config_text=actual_config) host.load_generated_config(config_text=rendered_config) return host.remediation_config_filtered_text(include_tags={}, exclude_tags={})