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

Add ssh_keyfile as an optional argument. #145

Merged
Merged
Changes from all commits
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
16 changes: 13 additions & 3 deletions napalm_junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,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 @@ -70,12 +71,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)

def open(self):
"""Open the connection wit the device."""
Expand Down