Class: Chef::Knife::RackspaceNetworkDelete

Inherits:
Chef::Knife
  • Object
show all
Includes:
RackspaceBase
Defined in:
lib/chef/knife/rackspace_network_delete.rb

Instance Method Summary collapse

Methods included from RackspaceBase

#auth_endpoint, #connection, #connection_params, included, #ip_address, #locate_config_value, #msg_pair, #public_dns_name, #region_warning_for_v1

Methods inherited from Chef::Knife

#get_networks, #get_node_name

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chef/knife/rackspace_network_delete.rb', line 11

def run
  if version_one?
    ui.error "Networks are not supported in v1"
    exit 1
  else
    @name_args.each do |net_id|
      network = connection.networks.get(net_id)
      unless network
        ui.error "Could not locate network: #{net_id}"
        exit 1
      end
      msg_pair("Network ID", network.id)
      msg_pair("Label", network.label)
      msg_pair("CIDR", network.cidr)

      puts "\n"
      confirm("Do you really want to delete this network")

      network.destroy

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