Skip to content
Snippets Groups Projects
Commit 3df39993 authored by JORGE SASIAIN's avatar JORGE SASIAIN
Browse files

Merge branch 'NAT-66-CLI' of gitlab.geant.org:nat/resource-management into NAT-66-CLI

parents f03b4b35 840bcdf9
No related branches found
No related tags found
No related merge requests found
......@@ -31,14 +31,16 @@ class junos_router(object):
def _open_device(self):
# Establish connection to router
creds = self.creds
dev = NONE
try:
dev = NONE
if "password" in creds and "ssh-config" in creds:
dev = Device(host=self.fqdn,
passwd=creds["password"],
ssh_config=creds["ssh-config"])
elif "password" in creds:
dev = Device(host=self.fqdn, passwd=creds["password"])
dev = Device(host=self.fqdn,
user=creds["username"],
passwd=creds["password"])
elif "private-key" in creds and "ssh-config" in creds:
dev = Device(host=self.fqdn,
ssh_private_key_file=creds["private-key"],
......@@ -47,12 +49,6 @@ class junos_router(object):
dev = Device(host=self.fqdn,
ssh_private_key_file=creds["private-key"])
if dev:
dev.open()
self.dev = dev
else:
raise Exception("Error parsing SSH credentials")
except ConnectError as err:
logger.error("Cannot connect to device: {0}".format(err))
except ConnectTimeoutError as err:
......@@ -61,6 +57,12 @@ class junos_router(object):
logger.error("Error reading hardware information for {1}: {0}"
.format(err, self.fqdn))
if dev:
dev.open()
self.dev = dev
else:
raise Exception("Error during connection to router")
def _get_hardware_info(self):
# For line_cards table
self._line_cards = FpcHwTable(self.dev)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment