From 92da247bb458a86478e27a8cda9450ef5313ad27 Mon Sep 17 00:00:00 2001 From: Oliver Garraux Date: Fri, 9 Oct 2015 18:04:16 -0700 Subject: [PATCH 1/3] Add timeout value to Ansible install config module --- ansible/napalm_install_config | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ansible/napalm_install_config b/ansible/napalm_install_config index cfe7c27..3e1d807 100644 --- a/ansible/napalm_install_config +++ b/ansible/napalm_install_config @@ -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 @@ -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: @@ -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), @@ -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'] @@ -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: From 42f19c94012ebbd8566e70626d0132f5e94974c2 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Mon, 19 Oct 2015 15:08:56 +0200 Subject: [PATCH 2/3] Added timeout to base for description --- napalm/fortios.py | 4 ++-- test/unit/TestFortiOSDriver.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/napalm/fortios.py b/napalm/fortios.py index f0945e4..4899767 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -37,11 +37,11 @@ def execute_get(device, cmd, separator=':', auto=False): class FortiOSDriver(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.device = FortiOS(hostname, username=username, password=password) + self.device = FortiOS(hostname, username=username, password=password, timeout=timeout) self.config_replace = False def open(self): diff --git a/test/unit/TestFortiOSDriver.py b/test/unit/TestFortiOSDriver.py index d4045c8..3e7b8d3 100644 --- a/test/unit/TestFortiOSDriver.py +++ b/test/unit/TestFortiOSDriver.py @@ -27,5 +27,5 @@ class TestFortiOSDriver(unittest.TestCase, TestNetworkDriver): password = 'this_is_not_a_secure_password' cls.vendor = 'fortios' - cls.device = FortiOSDriver(hostname, username, password) + cls.device = FortiOSDriver(hostname, username, password, timeout=60) cls.device.open() From c75ddecbf4d1a5d5db4d68ea3d83a42be80e8bba Mon Sep 17 00:00:00 2001 From: David Barroso Date: Mon, 19 Oct 2015 15:08:56 +0200 Subject: [PATCH 3/3] Added timeout to base for description --- napalm/fortios.py | 4 ++-- test/unit/TestFortiOSDriver.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/napalm/fortios.py b/napalm/fortios.py index f0945e4..4899767 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -37,11 +37,11 @@ def execute_get(device, cmd, separator=':', auto=False): class FortiOSDriver(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.device = FortiOS(hostname, username=username, password=password) + self.device = FortiOS(hostname, username=username, password=password, timeout=timeout) self.config_replace = False def open(self): diff --git a/test/unit/TestFortiOSDriver.py b/test/unit/TestFortiOSDriver.py index d4045c8..3e7b8d3 100644 --- a/test/unit/TestFortiOSDriver.py +++ b/test/unit/TestFortiOSDriver.py @@ -27,5 +27,5 @@ class TestFortiOSDriver(unittest.TestCase, TestNetworkDriver): password = 'this_is_not_a_secure_password' cls.vendor = 'fortios' - cls.device = FortiOSDriver(hostname, username, password) + cls.device = FortiOSDriver(hostname, username, password, timeout=60) cls.device.open()