Sha256: b6ae089856c7ef2e8a45bbe8830a6a39c306744da33ccdd54ee2db57cad52fdf
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/base') require 'chef/api_client' module KnifeJoyent class JoyentServerDelete < Chef::Knife include KnifeJoyent::Base banner 'knife joyent server delete <server_id>' def run unless name_args.size === 1 show_usage exit 1 end id = name_args.first server = self.connection.servers.get(id) msg("ID", server.id.to_s) msg("Name", server.name) msg("State", server.state) msg("Type", server.type) msg("Dataset", server.dataset) msg("IP's", server.ips) unless server puts ui.error("Unable to locate server: #{id}") exit 1 end puts "\n" confirm("Do you really want to delete this server") puts ui.color("Stopping server...", :cyan) if server.stopped? puts ui.color("Server #{id} is already stopped", :cyan) else if server.stop puts ui.color("Server stopped", :cyan) else puts ui.error("Failed to stop server") exit 1 end end server.destroy puts ui.color("Deleted server: #{id}", :cyan) puts "\n" confirm("Delete client and node for #{server.name}?") node = Chef::Node.load(server.name) puts "deleting node #{node.name}" node.destroy ui.warn("Deleted node named #{node.name}") client = Chef::ApiClient.load(server.name) puts "deleting client #{client.name}" client.destroy ui.warn("Deleted client named #{client.name}") end def msg(label, value) if value && !value.empty? puts "#{ui.color(label, :cyan)}: #{value}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
knife-joyent-0.0.10 | lib/chef/knife/joyent_server_delete.rb |
knife-joyent-0.0.9 | lib/chef/knife/joyent_server_delete.rb |