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
#after_exec_command, #before_exec_command, #create_service_instance, #execute_command, #msg_pair, #pretty_key, #set_default_config, #validate!, #validate_params!
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::Bootstrap.new
super
end
|
Instance Method Details
#init_bootstrap_options ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 38
def init_bootstrap_options
bootstrap.config[:connection_user] = @config[:connection_user] || "Administrator"
bootstrap.config[:connection_password] = @config[:connection_password]
bootstrap.config[:winrm_ssl] = @config[:winrm_ssl]
bootstrap.config[:connection_port] = @config[:connection_port]
bootstrap.config[:auth_timeout] = @config[:auth_timeout]
bootstrap.config[:winrm_ssl_verify_mode] = @config[:winrm_ssl_verify_mode]
bootstrap.config[:connection_protocol] = @config[:connection_protocol]
super
end
|
#load_winrm_deps ⇒ Object
33
34
35
36
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 33
def load_winrm_deps
require "winrm" unless defined?(WinRM::Connection)
require "chef/knife/core/windows_bootstrap_context"
end
|
#tcp_test_winrm(hostname, port) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 57
def tcp_test_winrm(hostname, port)
tcp_socket = TCPSocket.new(hostname, port)
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
49
50
51
52
53
54
55
|
# File 'lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb', line 49
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[:connection_port]) do
sleep @initial_sleep_delay ||= 10
puts("done")
end
end
|