Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the new login URL of NSO 5.7.5.1 #95

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/rest/connector/libs/nso/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the debug logging into the for loop

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Expand Down