Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions osism/commands/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def _check_netbox_instance(self, nb, timeout=20):
or "unauthorized" in error_msg.lower()
):
return "Error: Auth failed"
elif "connection" in error_msg.lower() or "refused" in error_msg.lower():
return "Error: Connection refused"
elif "ssl" in error_msg.lower() or "certificate" in error_msg.lower():
return "Error: SSL error"
elif "connection" in error_msg.lower() or "refused" in error_msg.lower():
return "Error: Connection refused"
else:
# Truncate long error messages
short_msg = error_msg[:50] if len(error_msg) > 50 else error_msg
Expand Down Expand Up @@ -235,12 +235,12 @@ def _check_netbox_connectivity(self, nb, url, token, ignore_ssl_errors, timeout=
base_url = nb.base_url
# Make simple GET request without auth to test reachability
requests.get(base_url, timeout=timeout, verify=not ignore_ssl_errors)
except requests.exceptions.SSLError:
return "Error: SSL error"
except requests.exceptions.Timeout:
return "Error: Timeout"
except requests.exceptions.ConnectionError:
return "Error: Connection refused"
except requests.exceptions.SSLError:
return "Error: SSL error"
except Exception as e:
error_msg = str(e)
short_msg = error_msg[:50] if len(error_msg) > 50 else error_msg
Expand Down Expand Up @@ -268,10 +268,10 @@ def _check_netbox_connectivity(self, nb, url, token, ignore_ssl_errors, timeout=
or "unauthorized" in error_msg.lower()
):
return "Error: Auth failed"
elif "connection" in error_msg.lower() or "refused" in error_msg.lower():
return "Error: Connection refused"
elif "ssl" in error_msg.lower() or "certificate" in error_msg.lower():
return "Error: SSL error"
elif "connection" in error_msg.lower() or "refused" in error_msg.lower():
return "Error: Connection refused"
else:
# Truncate long error messages
short_msg = error_msg[:50] if len(error_msg) > 50 else error_msg
Expand Down
20 changes: 7 additions & 13 deletions osism/commands/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,26 +652,20 @@ def take_action(self, parsed_args):
return 1

# Reload configuration
reload_successful = self._reload_configuration(ssh)

# Save configuration only if reload was successful
if reload_successful:
if not self._save_configuration(ssh):
return 1
else:
if not self._reload_configuration(ssh):
logger.warning("Skipping config save due to reload failure")
return 1

# Save configuration
if not self._save_configuration(ssh):
return 1

# Cleanup
self._cleanup_temp_file(ssh, switch_config_file)

logger.info("SONiC configuration reload completed successfully")
logger.info(f"- Config context saved locally to: {config_context_file}")
if reload_successful:
logger.info("- Configuration loaded, reloaded, and saved on switch")
else:
logger.info(
"- Configuration loaded on switch (save skipped due to reload failure)"
)
logger.info("- Configuration loaded, reloaded, and saved on switch")
logger.info(f"- Backup created on switch: {backup_filename}")

return 0
Expand Down
Loading