class Chef::Knife::ProfitbricksServerDelete

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/profitbricks_server_delete.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

    msg_pair('ID', server.id)
    msg_pair('Name', server.properties['name'])
    msg_pair('Cores', server.properties['cores'])
    msg_pair('RAM', server.properties['ram'])
    msg_pair('Availability Zone', server.properties['availabilityZone'])

    confirm('Do you really want to delete this server')

    server.delete
    ui.warn("Deleted server #{server.id}")
  end
end