From e1015f2e2e5c59c677b4874dbbca617de91991f8 Mon Sep 17 00:00:00 2001 From: Mathias-gt <84408567+Mathias-gt@users.noreply.github.com> Date: Tue, 22 Nov 2022 14:41:16 +0100 Subject: [PATCH 1/2] Adding the new login URL of NSO 5.7.5.1 In the version 5.7.5.1 of NSO "/api" isn't available anymore. The new login URL is "/restconf". --- src/rest/connector/libs/nso/implementation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rest/connector/libs/nso/implementation.py b/src/rest/connector/libs/nso/implementation.py index 2c8a874..2fc807d 100644 --- a/src/rest/connector/libs/nso/implementation.py +++ b/src/rest/connector/libs/nso/implementation.py @@ -118,7 +118,7 @@ def connect(self, ip=ip, port=port) - self.login_url = '{f}/api'.format(f=self.base_url) + self.login_urls = ['{f}/api'.format(f=self.base_url),'{f}/restconf'.format(f=self.base_url)] log.info("Connecting to '{d}' with alias " "'{a}'".format(d=self.device.name, a=self.alias)) @@ -129,7 +129,11 @@ def connect(self, self.session.auth = (username, password) # Connect to the device via requests - response = self.session.get(self.login_url, timeout=timeout) + for login_url in self.login_urls: + response = self.session.get(login_url, timeout=timeout) + if response.status_code == requests.codes.ok: + self.login_url = login_url + break output = response.text log.debug("Response: {c} {r}, headers: {h}".format(c=response.status_code, r=response.reason, h=response.headers)) From 7002f794c21039ccf6508e64d5b7e64c78422bb0 Mon Sep 17 00:00:00 2001 From: Mathias-gt <84408567+Mathias-gt@users.noreply.github.com> Date: Thu, 8 Jun 2023 10:24:26 +0200 Subject: [PATCH 2/2] Update implementation.py Moove the debug inside the for --- src/rest/connector/libs/nso/implementation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rest/connector/libs/nso/implementation.py b/src/rest/connector/libs/nso/implementation.py index 2fc807d..d1a2510 100644 --- a/src/rest/connector/libs/nso/implementation.py +++ b/src/rest/connector/libs/nso/implementation.py @@ -131,12 +131,12 @@ def connect(self, # Connect to the device via requests for login_url in self.login_urls: response = self.session.get(login_url, timeout=timeout) + log.debug("Response: {c} {r}, headers: {h}".format(c=response.status_code, + r=response.reason, h=response.headers)) if response.status_code == requests.codes.ok: self.login_url = login_url break output = response.text - log.debug("Response: {c} {r}, headers: {h}".format(c=response.status_code, - r=response.reason, h=response.headers)) if verbose: log.info("Response text:\n%s" % output)