Skip to content
This repository has been archived by the owner on Feb 10, 2018. It is now read-only.

Commit

Permalink
Add ssh_keyfile as an optional argument. (#145)
Browse files Browse the repository at this point in the history
* Add ssh_keyfile as an optional argument. Also change optional_args to default to an empty dict{}

* Switch back to optional_args=None.

* Add port=self.port and change ssh_keyfile to keyfile to keep it consistent.

* Fix line too long.
  • Loading branch information
stiltzkin10 authored and dbarrosop committed Apr 10, 2017
1 parent b1ce5e8 commit 7421f95
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions napalm_junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)
Initialise JunOS driver.
Optional args:
* port (int): custom port
* config_lock (True/False): lock configuration DB after the connection is established.
* port (int): custom port
* key_file (string): SSH key file path
"""
self.hostname = hostname
self.username = username
Expand All @@ -71,12 +72,21 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)
self.config_replace = False
self.locked = False

# Get optional arguments
if optional_args is None:
optional_args = {}
self.port = optional_args.get('port', 22)

self.config_lock = optional_args.get('config_lock', True)
self.port = optional_args.get('port', 22)
self.key_file = optional_args.get('key_file', None)

self.device = Device(hostname, user=username, password=password, port=self.port)
if self.key_file:
self.device = Device(hostname,
user=username,
ssh_private_key_file=self.key_file,
port=self.port)
else:
self.device = Device(hostname, user=username, password=password, port=self.port)

self.profile = ["junos"]

Expand Down

0 comments on commit 7421f95

Please sign in to comment.