Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into apigw
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski authored Aug 27, 2024
2 parents dbd6c6f + a2cbb67 commit 88f8634
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ENDPOINTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**THIS FILE WAS AUTO-GENERATED DO NOT EDIT**

Generated for: catalystwan-0.34.0
Generated for: catalystwan-0.34.1

All URIs are relative to */dataservice*
HTTP request | Supported Versions | Method | Payload Type | Return Type | Tenancy Mode
Expand Down
15 changes: 11 additions & 4 deletions catalystwan/api/templates/cli_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
import logging
from difflib import Differ
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, List

from attr import define # type: ignore
from ciscoconfparse import CiscoConfParse # type: ignore
Expand Down Expand Up @@ -126,6 +126,7 @@ def compare_template(
second: CiscoConfParse,
full: bool = False,
debug: bool = False,
ignored_lines: List[str] = [],
) -> str:
"""
Expand All @@ -134,6 +135,7 @@ def compare_template(
second: Second template for comparison.
full: Return a full comparison if True, otherwise only the lines that differ.
debug: Adding debug to the logger. Defaults to False.
ignored_lines: List of configs statements to be excluded from comparison
Returns:
str: The compared templates.
Expand Down Expand Up @@ -162,8 +164,11 @@ def compare_template(
auth-port 151
exit
"""
first_n = list(map(lambda x: x + "\n", first.ioscfg))
second_n = list(map(lambda x: x + "\n", second.ioscfg))
for line in ignored_lines:
first.delete_lines(line)
second.delete_lines(line)
first_n = list(map(lambda x: x.strip() + "\n", first.ioscfg))
second_n = list(map(lambda x: x.strip() + "\n", second.ioscfg))
compare = list(Differ().compare(first_n, second_n))
if not full:
compare = [x for x in compare if x[0] in ["?", "-", "+"]]
Expand All @@ -177,6 +182,7 @@ def compare_with_running(
template: CiscoConfParse,
device: Device,
debug: bool = False,
ignored_lines: List[str] = [],
) -> str:
"""The comparison of the config with the one running on the machine.
Expand All @@ -185,6 +191,7 @@ def compare_with_running(
device: The device on which to compare config.
full: Return a full comparison if True, otherwise only the lines that differ.
debug: Adding debug to the logger. Defaults to False.
ignored_lines: List of configs statements to be excluded from comparison
Returns:
str: The compared templates.
Expand Down Expand Up @@ -216,4 +223,4 @@ def compare_with_running(
.
"""
running_config = self.load_running(session, device)
return self.compare_template(running_config, template, debug)
return self.compare_template(running_config, template, debug=debug, ignored_lines=ignored_lines)
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AutoConfirm(BaseModel):


class ActivateDeactivateTaskId(BaseModel):
id: UUID
id: str


class ConfigurationVSmartTemplatePolicy(APIEndpoints):
Expand Down

0 comments on commit 88f8634

Please sign in to comment.