Class: Chef::Knife::RaxClusterDelete
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::RaxClusterDelete
- Includes:
- RaxClusterBase
- Defined in:
- lib/chef/knife/rax_cluster_delete.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#lb_name ⇒ Object
Returns the value of attribute lb_name.
-
#rax_endpoint ⇒ Object
Returns the value of attribute rax_endpoint.
Instance Method Summary collapse
Methods included from RaxClusterBase
#authenticate, included, #make_web_call, #msg_pair, #populate_environment
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
7 8 9 |
# File 'lib/chef/knife/rax_cluster_delete.rb', line 7 def headers @headers end |
#lb_name ⇒ Object
Returns the value of attribute lb_name.
7 8 9 |
# File 'lib/chef/knife/rax_cluster_delete.rb', line 7 def lb_name @lb_name end |
#rax_endpoint ⇒ Object
Returns the value of attribute rax_endpoint.
7 8 9 |
# File 'lib/chef/knife/rax_cluster_delete.rb', line 7 def rax_endpoint @rax_endpoint end |
Instance Method Details
#delete_cluster ⇒ Object
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 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/chef/knife/rax_cluster_delete.rb', line 25 def delete_cluster lb_authenticate = authenticate() lb_url = "" puts config[:lb_region] headers = {"x-auth-token" => lb_authenticate['auth_token'], "content-type" => "application/json"} lb_authenticate['lb_urls'].each {|lb| if config[:lb_region].to_s.downcase == lb['region'].to_s.downcase lb_url = lb['publicURL'] break end lb_url = lb['publicURL'] } @name_args.each {|arg| server_uuids = [] lb_url = lb_url + "/loadbalancers/#{arg}" get_uuids = make_web_call("get", lb_url, headers ) if get_uuids.code == '404' ui.msg "Make sure you specify the -r flag to specify what region the LB is located" exit(1) end lb_data = JSON.parse(get_uuids.body) lb_data['loadBalancer']['metadata'].each{|| server_uuids << {'uuid' => ['value'], 'server_name' => ['key'] } } server_uuids.each { |uuid| rs_delete = RackspaceServerDelete.new rs_delete.config[:yes] = 'yes' rs_delete.name_args = [ uuid['uuid'] ] rs_delete.config[:purge] = true rs_delete.config[:chef_node_name] = uuid['server_name'] rs_delete.run } delete_lb_call = make_web_call("delete", lb_url, headers) puts "Deleted loadbalancer id #{arg}" } end |
#run ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/chef/knife/rax_cluster_delete.rb', line 64 def run if @name_args.empty? ui.fatal "Please specify a Load balancer ID to delete" end ui.confirm("Are you sure you want to delete this Load balancer and ALL nodes associated with it?") delete_cluster end |