128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/chef/knife/voxel_voxservers_reimage.rb', line 128
def run
$stdout.sync = true
unless @name_args.empty?
create = hapi.voxel_voxservers_reimage(
:device_id => @name_args.first,
:image_id => config[:image_id],
:hostname => config[:hostname],
:swap_space => config[:swap_size]
)
if create['stat'] == "fail"
ui.error(create['err']['msg'])
else
sleep 2
device = hapi.voxel_devices_list( :device_id => create['device']['id'], :verbosity => 'extended' )
if device['stat'] == "fail"
ui.error(device['err']['msg'])
else
device = device['devices']['device']
puts "#{ui.color("Device ID", :cyan)}: #{device['id']}"
puts "#{ui.color("Name", :cyan)}: #{device['label']}"
puts "#{ui.color("Image Id", :cyan)}: #{config[:image_id]}"
puts "#{ui.color("Facility", :cyan)}: #{device['location']['facility']['code']}"
puts "#{ui.color("Public IP Address", :cyan)}: #{device['ipassignments']['ipassignment'].select { |i| i['type'] == 'frontend' }.first['content']}"
puts "#{ui.color("Private IP Address", :cyan)}: #{device['ipassignments']['ipassignment'].select { |i| i['type'] == 'backend' }.first['content']}"
puts "#{ui.color("Root Password", :cyan)}: #{device['accessmethods']['accessmethod'].select { |a| a['type'] == 'admin' }.first['password']}"
status = hapi.voxel_voxservers_status( :device_id => device['id'], :verbosity => 'extended' )
while %w{ QUEUED IN_PROGRESS }.include?( status['devices']['device']['status'] ) do
print "."
status = hapi.voxel_voxservers_status( :device_id => device['id'], :verbosity => 'extended' )
sleep 10
end
print "\n#{ui.color("Waiting for sshd", :magenta)}"
print(".") until tcp_test_ssh(device['ipassignments']['ipassignment'].select { |i| i['type'] == 'frontend' }.first['content']) { sleep @initial_sleep_delay ||= 10; puts("done") }
bootstrap_for_node(device).run
puts "#{ui.color("Run List", :cyan)}: #{config[:run_list].join(', ')}"
puts "#{ui.color("Node Name", :cyan)}: #{config[:node_name] || 'd' + device['id']}"
puts "#{ui.color("Environment", :cyan)}: #{config[:environment] || '_default'}"
puts "#{ui.color("Device ID", :cyan)}: #{device['id']}"
puts "#{ui.color("Name", :cyan)}: #{device['label']}"
puts "#{ui.color("Image Id", :cyan)}: #{config[:image_id]}"
puts "#{ui.color("Facility", :cyan)}: #{device['location']['facility']['code']}"
puts "#{ui.color("Public IP Address", :cyan)}: #{device['ipassignments']['ipassignment'].select { |i| i['type'] == 'frontend' }.first['content']}"
puts "#{ui.color("Private IP Address", :cyan)}: #{device['ipassignments']['ipassignment'].select { |i| i['type'] == 'backend' }.first['content']}"
puts "#{ui.color("Root Password", :cyan)}: #{device['accessmethods']['accessmethod'].select { |a| a['type'] == 'admin' }.first['password']}"
end
end
else
ui.error( "knife voxel voxservers reimage DEVICE_ID (options)" )
end
end
|