122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/gaptool-client.rb', line 122
def execute
node = $api.getonenode(instance)
nodes = [node]
infohelper(nodes, false, false)
zone = node['zone'][0..-2]
if node['environment'] != environment || node['role'] != role
puts Rainbow("'#{node['role']}-#{node['environment']}' do not match provided value (#{role}-#{environment})").red
exit 1
end
if node['terminate'] == 'false'
puts Rainbow('"terminate" command is disabled for this instance').red
exit 2
end
print Rainbow("Terminate instance? [type yes to confirm]: ").green
res = $stdin.gets.chomp
if res.downcase == 'yes'
puts "Terminating instance #{node['role']}:#{node['environment']}:#{node['instance']} in region #{zone}"
begin
res = $api.terminatenode(instance, zone)
rescue
puts Rainbow('Cannot terminate instance').red
end
end
end
|