-
Notifications
You must be signed in to change notification settings - Fork 42
Add ssh_keyfile as an optional argument. #145
Add ssh_keyfile as an optional argument. #145
Conversation
… default to an empty dict{}
napalm_junos/junos.py
Outdated
@@ -55,13 +55,14 @@ | |||
class JunOSDriver(NetworkDriver): | |||
"""JunOSDriver class - inherits NetworkDriver from napalm_base.""" | |||
|
|||
def __init__(self, hostname, username, password, timeout=60, optional_args=None): | |||
def __init__(self, hostname, username, password='', timeout=60, optional_args={}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to switch this back to optional_args=None (as otherwise we will have a problem with Python mutable).
napalm_junos/junos.py
Outdated
@@ -70,12 +71,15 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) | |||
self.config_replace = False | |||
self.locked = False | |||
|
|||
if optional_args is None: | |||
optional_args = {} | |||
self.port = optional_args.get('port', 22) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should be retained as otherwise have a Python mutable problem.
I added a couple of comments about fixing the Did you test validate that this change works using SSH keys. |
Got it. Reverted back to optional_args=None. Thanks! I have tested this and it works fine on the JUNOS devices I have access to. To my knowledge the API does not support fall back to username/password. |
napalm_junos/junos.py
Outdated
|
||
self.device = Device(hostname, user=username, password=password, port=self.port) | ||
if self.ssh_keyfile: | ||
self.device = Device(hostname, user=username, ssh_private_key_file=self.ssh_keyfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need the port=self.port
here.
Okay, I added one more comment about self.port missing at one point. I also think we should make the optional argument be |
Agree. Updated. |
@stiltzkin10 This looks good to me. Let me get @dbarrosop or @mirceaulinic to sanity check since they use Juniper driver more than I do. |
Yep, no worries. Thanks! |
1 similar comment
I don't use juniper devices anymore but I could confirm with Thanks! :) |
Oh, just one thing. Would you mind updating the |
Sure, I created napalm-automation/napalm#368. I actually created sub bullets since vyos/junos are slightly different. |
Awesome, thanks! |
Also change optional_args to default to an empty dict.
This is for issue/FR: #143