Class: Chef::Knife::CloudstackNetworkDelete
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::CloudstackNetworkDelete
- Includes:
- CloudstackBase
- Defined in:
- lib/chef/knife/cloudstack_network_delete.rb
Instance Method Summary collapse
Methods included from CloudstackBase
#connection, included, #locate_config_value, #msg_pair, #validate!
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/chef/knife/cloudstack_network_delete.rb', line 30 def run if @name_args.nil? || @name_args.empty? puts "#{ui.color("Please provide a network ID.", :red)}" end @name_args.each do |network_id| response = connection.list_networks('id' => network_id) apiresponse = response['listnetworksresponse'] network = apiresponse['network'] Chef::Log.debug("Network: #{network}") network_name = network[0]['name'].to_s network_display = network[0]['displaytext'].to_s puts "#{ui.color("Name", :red)}: #{network_name}" puts "#{ui.color("Display Text", :red)}: #{network_display}" puts "\n" confirm("#{ui.color("Do you really want to delete this network?", :red)}") connection.delete_network(network_id) ui.warn("Deleted network #{network_name}") end end |