Class: Chef::Knife::StormServerReboot

Inherits:
Chef::Knife show all
Includes:
StormBase
Defined in:
lib/chef/knife/storm_server_reboot.rb

Instance Method Summary collapse

Methods included from StormBase

#connection, included, #locate_config_value, #msg_pair, #validate!

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef/knife/storm_server_reboot.rb', line 21

def run

	validate!
	ui.warn("Nothing to do because no server id or fqdn is specified") if @name_args.empty?

	@name_args.each do |storm_id|

		begin
			server = connection.servers.detect do |s|
				s.uniq_id == storm_id || s.domain == storm_id
			end

			msg_pair("Storm ID", server.uniq_id)
			msg_pair("FQDN", server.domain)
			msg_pair("IP", server.ip)
			msg_pair("Status", server.status['status'])

			puts "\n"
			confirm("Do you really want to reboot this server")

			server.reboot :force => config[:force] ? 1 : 0
			ui.warn("Rebooted server #{storm_id}")
		rescue Fog::Compute::StormOnDemand::NotFound
			ui.error("Could note locate server #{storm_id}")
		end

	end
 
end