Skip to content

Commit

Permalink
Merge pull request #16 from Swiff/master
Browse files Browse the repository at this point in the history
Timeout addition and fix
  • Loading branch information
spheromak committed Mar 23, 2016
2 parents 6ce1758 + 2685749 commit 9bea7bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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



Expand Down
9 changes: 7 additions & 2 deletions lib/chef/knife/xapi_guest_create.rb
Expand Up @@ -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',
Expand Down Expand Up @@ -131,9 +132,13 @@ 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,
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'
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit 9bea7bd

Please sign in to comment.