Skip to content

Commit

Permalink
Merge pull request #65 from ogarraux/junos_timeouts
Browse files Browse the repository at this point in the history
Make Junos timeout configurable
  • Loading branch information
dbarrosop committed Oct 11, 2015
2 parents b60430d + 8847178 commit 9b2e9eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion ansible/napalm_install_config
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ options:
password:
description: Password
required: true
timeout:
description: Timeout for connections and requests to device
required: false
default: 60
config_file:
description: Where to load the configuration from.
required: true
Expand Down Expand Up @@ -83,6 +87,7 @@ EXAMPLES = '''
commit_changes={{ commit_changes }}
replace_config={{ replace_config }}
diff_file=../compiled/{{ inventory_hostname }}/diff
timeout={{timeout}}
From the CLI we would trigger the playbook like:
Expand All @@ -107,6 +112,7 @@ def main():
hostname=dict(required=True),
username=dict(required=True),
password=dict(required=True),
timeout=dict(required=False, default=60, type='int'),
config_file=dict(required=True),
dev_os=dict(required=True),
commit_changes=dict(required=True),
Expand All @@ -120,6 +126,7 @@ def main():
username = module.params['username']
dev_os = module.params['dev_os']
password = module.params['password']
timeout = module.params['timeout']

config_file = module.params['config_file']
commit_changes = module.params['commit_changes']
Expand All @@ -133,7 +140,7 @@ def main():

network_driver = get_network_driver(dev_os)

device = network_driver(hostname, username, password)
device = network_driver(hostname, username, password, timeout)
device.open()

if replace_config:
Expand Down
5 changes: 3 additions & 2 deletions napalm/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@

class JunOSDriver(NetworkDriver):

def __init__(self, hostname, username, password):
def __init__(self, hostname, username, password, timeout=60):
self.hostname = hostname
self.username = username
self.password = password
self.timeout = timeout
self.device = Device(hostname, user=username, password=password)
self.config_replace = False

def open(self):
self.device.open()
self.device.timeout = 60
self.device.timeout = self.timeout
self.device.bind(cu=Config)
self.device.cu.lock()

Expand Down

0 comments on commit 9b2e9eb

Please sign in to comment.