Skip to content

Commit

Permalink
CASMTRIAGE-6179 fix exception on invalid password with shcd cabling (#…
Browse files Browse the repository at this point in the history
…450)

* CASMTRIAGE-6179 fix exception on invalid password with shcd cabling

Signed-off-by: Jacob Salmela <[email protected]>

* changelog

Signed-off-by: Jacob Salmela <[email protected]>

---------

Signed-off-by: Jacob Salmela <[email protected]>
  • Loading branch information
jacobsalmela authored Nov 9, 2023
1 parent 7c6bc7d commit 9dc3b54
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Fixed exception when bad credentials provided when running `canu validate shcd-cabling`

## [1.7.6]

- Add ACL for DHCP
Expand Down
21 changes: 19 additions & 2 deletions canu/validate/shcd_cabling/shcd_cabling.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def shcd_cabling(
elif exception_type == "ConnectionError":
error_message = f"Error connecting to switch {ip}, check the entered username, IP address and password."
elif exception_type == "NetmikoTimeoutException":
error_message = f"Timeout error connecting to {ip}. Check the IP address and try again."
error_message = f"Timeout error connecting to {ip}. Check the IP address or credentials and try again."
elif exception_type == "NetmikoAuthenticationException":
error_message = f"Auth error connecting to {ip}. Check the credentials or IP address and try again"
else:
Expand All @@ -262,6 +262,24 @@ def shcd_cabling(
with open(canu_cache_file, "r+") as file:
canu_cache = yaml.load(file)

double_dash = "=" * 100
# if there are errors and no switches exist or we able to be connected to, error and exit
if len(errors) > 0 and canu_cache["switches"] is None:
click.echo("\n", file=out)
click.echo(double_dash, file=out)
click.secho(
"Errors",
fg="red",
file=out,
)
click.echo(double_dash, file=out)
for error in errors:
click.echo(
"{:<15s} - {}".format(error[0], error[1]),
file=out,
)
sys.exit(1)

# Create Cabling Node factory and model
log.debug("Creating model from switch LLDP data")
cabling_factory = NetworkNodeFactory(architecture_version=architecture)
Expand Down Expand Up @@ -319,7 +337,6 @@ def shcd_cabling(
click.secho(f"{host_mac_string}")
sys.exit(0)

double_dash = "=" * 100
click.echo("\n", file=out)
click.echo(double_dash, file=out)
click.secho(
Expand Down

0 comments on commit 9dc3b54

Please sign in to comment.