Skip to content

Commit

Permalink
Merge 8caea2b into 197b7ea
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Piddubny committed Nov 19, 2018
2 parents 197b7ea + 8caea2b commit 9ed9f72
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 10 additions & 3 deletions autodiscovery/commands/connect_ports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from autodiscovery.exceptions import ReportableException
from autodiscovery.output import EmptyOutput


Expand Down Expand Up @@ -35,17 +36,23 @@ def execute(self, parsed_entries):
continue

entry.status = entry.SUCCESS_STATUS

cs_session = self.cs_session_manager.get_session(cs_domain=entry.domain)

cs_session.UpdatePhysicalConnection(resourceAFullPath=parsed_entry.source_port,
resourceBFullPath=parsed_entry.target_port)

except Exception:
except ReportableException as e:
self.output.send("Failed to connect port {} and {}. {}".format(parsed_entry.source_port,
parsed_entry.target_port,
parsed_entry.comment), error=True)
str(e)), error=True)
self.logger.exception("Failed to connect ports due to:")

except Exception:
self.output.send("Failed to connect port {} and {}. See log for details".format(
parsed_entry.source_port,
parsed_entry.target_port), error=True)
self.logger.exception("Failed to connect ports due to:")

else:
msg = "Connection between port {} and port {} was successfully processed".format(
parsed_entry.source_port,
Expand Down
9 changes: 6 additions & 3 deletions autodiscovery/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ def execute(self, devices_ips, snmp_comunity_strings, vendor_settings, additiona
cs_session = self.cs_session_manager.get_session(cs_domain=cs_domain)
handler.upload(entry=discovered_entry, vendor=vendor, cs_session=cs_session)

except ReportableException as e:
self.output.send("Failed to discover {} device. {}".format(device_ip, str(e)), error=True)
self.logger.exception("Failed to discover {} device due to:".format(device_ip))

except Exception:
entry = self.report.get_current_entry()
comment = entry.comment if entry is not None else ""
self.output.send("Failed to discover {} device. {}".format(device_ip, comment), error=True)
self.output.send("Failed to discover {} device. See log for details".format(device_ip), error=True)
self.logger.exception("Failed to discover {} device due to:".format(device_ip))

else:
self.output.send("Device with IP {} was successfully discovered".format(device_ip))
self.logger.info("Device with IP {} was successfully discovered".format(device_ip))
Expand Down

0 comments on commit 9ed9f72

Please sign in to comment.