From bfeb271025a486dae95b77557025c3e62bf7d405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Timmerman?= Date: Mon, 22 Feb 2016 09:12:43 +0100 Subject: [PATCH 1/2] add option to set the timeout when connecting to a guest --- README.md | 1 + lib/chef/knife/xapi_guest_create.rb | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0093833..58587b1 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Config options are extendable in the knife.rb the folowing config options can be * __knife[:host_key_verify]__ true/false Honor hostkey verification or don't * __knife[:ping_timeout]__ Seconds to timeout while waiting for an IP to be returned from guest * __knife[:json_attributes]__ A JSON string to be added to the first run of chef-client +* __knife[:connect_timeout]__ Seconds to timeout while trying to connect to a guest diff --git a/lib/chef/knife/xapi_guest_create.rb b/lib/chef/knife/xapi_guest_create.rb index 963c0d0..57094d9 100644 --- a/lib/chef/knife/xapi_guest_create.rb +++ b/lib/chef/knife/xapi_guest_create.rb @@ -31,6 +31,7 @@ class XapiGuestCreate < Knife ssh_user: 'root', ssh_port: '22', ping_timeout: 600, + connect_timeout: 600, install_repo: 'http://isoredirect.centos.org/centos/6/os/x86_64/', kernel_params: 'graphical utf8', xapi_disk_size: '8g', @@ -134,6 +135,10 @@ class XapiGuestCreate < Knife long: '--ping-timeout', description: 'Seconds to timeout waiting for ip from guest' + option :connect_timeout, + long: '--connect-timeout SECONDS', + description: 'Seconds to timeout while trying to connect to a guest' + option :bootstrap_version, long: '--bootstrap-version VERSION', description: 'The version of Chef to install' @@ -384,7 +389,7 @@ def run ui.msg "Trying to connect to guest @ #{guest_addr} " begin - timeout(480) do + timeout(locate_config_value(:connect_timeout).to_i) do print('.') until tcp_test_ssh(guest_addr) do sleep @initial_sleep_delay ||= 10 ui.msg("#{ h.color 'OK!', :green}") From 26857496a8eba815b8ed89be9cf93496b1788e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Timmerman?= Date: Mon, 22 Feb 2016 09:13:33 +0100 Subject: [PATCH 2/2] fix bug when setting timeout for waiting for IP from guest tools --- lib/chef/knife/xapi_guest_create.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/knife/xapi_guest_create.rb b/lib/chef/knife/xapi_guest_create.rb index 57094d9..1e5d1a9 100644 --- a/lib/chef/knife/xapi_guest_create.rb +++ b/lib/chef/knife/xapi_guest_create.rb @@ -132,7 +132,7 @@ class XapiGuestCreate < Knife description: 'The ssh port' option :ping_timeout, - long: '--ping-timeout', + long: '--ping-timeout SECONDS', description: 'Seconds to timeout waiting for ip from guest' option :connect_timeout,