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

Initial skeleton for v2 #56

Open
wants to merge 13 commits into
base: v2
Choose a base branch
from

Conversation

tardoe
Copy link
Collaborator

@tardoe tardoe commented Aug 23, 2024

Major simplifications and new abstractions, renamed napalm-srl --> napalm-srlinux, adding typing and reimplementing PoC methods for get_bgp_neighbors, get_lldp_neighbors, get_users.

…alm-srlinux, adding typing and reimplementing PoC methods for get_bgp_neighbors, get_lldp_neighbors, get_users.
@tardoe tardoe requested a review from hellt August 23, 2024 07:22
@tardoe tardoe self-assigned this Aug 23, 2024
@jbemmel
Copy link
Collaborator

jbemmel commented Aug 23, 2024

CI/CD tests are failing, you can check locally using make run-tests (after deploying the test lab)

Comment on lines +1003 to +1036
def _compose_jsonrpc_url(self):
"""
Compose the JSON RPC URL, based on the initialized arguments.
"""

proto = (
"https"
if (
self.jsonrpc_port == 443
or (self.jsonrpc_port != 80 and not self.insecure)
)
else "http"
)
url = f"{proto}://{self.hostname}:{self.jsonrpc_port}/jsonrpc"
# print(url)

return url

def _determine_jsonrpc_port(self, opt_args):
"""
Determine the JSON RPC port based on the optional arguments.
"""

# by default assume 443 port is used by jsonrpc server
port: int = 443

# if jsonrpc_port is specified, use that
if opt_args.get("jsonrpc_port"):
port = opt_args.get("jsonrpc_port")
# when insecure is set and jsonrpc_port is not specified, use 80
elif opt_args.get("insecure"):
port = 80

return port
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added these two helper functions to have some flexibility and testability on how we determine the jsonrpc port and the resulting URL

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Excellent. There’s a few other methods throughout the place that I think could do with the same treatment. These methods are also a good place to start for unit tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

also added a dumb unit test (which fails for now since the driver wants to have some cert files which we don't have yet in the mock data)

@tardoe
Copy link
Collaborator Author

tardoe commented Aug 24, 2024

CI/CD tests are failing, you can check locally using make run-tests (after deploying the test lab)

Thanks mate, we’ll probably review the tests and look to improve them. We want to make the driver a bit more friendly to stub and test in general.

Copy link
Collaborator Author

@tardoe tardoe left a comment

Choose a reason for hiding this comment

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

@hellt We probably don’t have to reinvent the wheel here, these types are already in napalm.base. https://github.com/napalm-automation/napalm/blob/develop/napalm/base/models.py#L25

@hellt
Copy link
Collaborator

hellt commented Aug 24, 2024

@hellt We probably don’t have to reinvent the wheel here, these types are already in napalm.base. https://github.com/napalm-automation/napalm/blob/develop/napalm/base/models.py#L25

yes, we can use the upstream types (and extend them when needed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants