Class: KnifeCloudstack::CsServerStart
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- KnifeCloudstack::CsServerStart
- Defined in:
- lib/chef/knife/cs_server_start.rb
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/chef/knife/cs_server_start.rb', line 80 def connection unless @connection @connection = CloudstackClient::Connection.new( locate_config_value(:cloudstack_url), locate_config_value(:cloudstack_api_key), locate_config_value(:cloudstack_secret_key) ) end @connection end |
#locate_config_value(key) ⇒ Object
97 98 99 100 |
# File 'lib/chef/knife/cs_server_start.rb', line 97 def locate_config_value(key) key = key.to_sym Chef::Config[:knife][key] || config[key] end |
#msg(label, value) ⇒ Object
91 92 93 94 95 |
# File 'lib/chef/knife/cs_server_start.rb', line 91 def msg(label, value) if value && !value.empty? puts "#{ui.color(label, :cyan)}: #{value}" end end |
#run ⇒ Object
50 51 52 53 54 55 56 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/cs_server_start.rb', line 50 def run @name_args.each do |hostname| server = connection.get_server(hostname) if !server then ui.error("Server '#{hostname}' not found") next end puts "\n" msg("Name", server['name']) msg("Public IP", connection.get_server_public_ip(server) || '?') msg("Service", server['serviceofferingname']) msg("Template", server['templatename']) msg("Domain", server['domain']) msg("Zone", server['zonename']) msg("State", server['state']) puts "\n" ui.confirm("Do you really want to start this server") print "#{ui.color("Waiting for startup", :magenta)}" connection.start_server(hostname) puts "\n" ui.msg("Started server #{hostname}") end end |