Class: Chef::Knife::Cloud::WinrmBootstrapProtocol
Instance Attribute Summary
#bootstrap, #config, #initial_sleep_delay, #ui
Instance Method Summary
collapse
#send_bootstrap_command
Methods included from Helpers
#locate_config_value, #msg_pair
Constructor Details
Returns a new instance of WinrmBootstrapProtocol.
27
28
29
30
31
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 27
def initialize(config)
load_winrm_deps
@bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
super
end
|
Instance Method Details
#init_bootstrap_options ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 41
def init_bootstrap_options
bootstrap.config[:winrm_user] = @config[:winrm_user] || 'Administrator'
bootstrap.config[:winrm_password] = @config[:winrm_password]
bootstrap.config[:winrm_transport] = @config[:winrm_transport]
bootstrap.config[:winrm_port] = @config[:winrm_port]
bootstrap.config[:auth_timeout] = @config[:auth_timeout]
super
end
|
#load_winrm_deps ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 33
def load_winrm_deps
require 'winrm'
require 'em-winrm'
require 'chef/knife/bootstrap_windows_winrm'
require 'chef/knife/core/windows_bootstrap_context'
require 'chef/knife/winrm'
end
|
#tcp_test_winrm(hostname, port) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 58
def tcp_test_winrm(hostname, port)
tcp_socket = TCPSocket.new(hostname, port)
return true
rescue SocketError
sleep 2
false
rescue Errno::ETIMEDOUT
false
rescue Errno::EPERM
false
rescue Errno::ECONNREFUSED
sleep 2
false
rescue Errno::EHOSTUNREACH
sleep 2
false
rescue Errno::ENETUNREACH
sleep 2
false
ensure
tcp_socket && tcp_socket.close
end
|
#wait_for_server_ready ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 50
def wait_for_server_ready
print "\n#{ui.color("Waiting for winrm to host (#{@config[:bootstrap_ip_address]})", :magenta)}"
print(".") until tcp_test_winrm(@config[:bootstrap_ip_address], @config[:winrm_port]){
sleep @initial_sleep_delay ||= 10
puts("done")
}
end
|