Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
miaow2 committed May 12, 2024
1 parent 62f94fe commit 15fabda
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
47 changes: 35 additions & 12 deletions docs/colliecting-diffs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Binary file added docs/media/screenshots/compliance-patch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 4 additions & 12 deletions netbox_config_diff/compliance/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion netbox_config_diff/compliance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={})

0 comments on commit 15fabda

Please sign in to comment.