class Chef::Knife::ProfitbricksServerStop

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/profitbricks_server_stop.rb, line 16
def run
  connection
  @name_args.each do |server_id|
    begin
      server = ProfitBricks::Server.get(Chef::Config[:knife][:datacenter_id], server_id)
    rescue Excon::Errors::NotFound
      ui.error("Server ID #{server_id} not found. Skipping.")
      next
    end

    server.stop
    ui.warn("Server #{server.id} is stopping")
  end
end