Class: Chef::Knife::ProfitbricksLanDelete

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

Instance Method Summary collapse

Methods included from ProfitbricksBase

#connection, #error_and_exit, #get_image, included, #msg_pair, #validate_required_params

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/chef/knife/profitbricks_lan_delete.rb', line 16

def run
  connection
  @name_args.each do |lan_id|
    begin
      lan = ProfitBricks::LAN.get(config[:datacenter_id], lan_id)
    rescue Excon::Errors::NotFound
      ui.error("Lan ID #{lan_id} not found. Skipping.")
      next
    end

    msg_pair('ID', lan.id)
    msg_pair('Name', lan.properties['name'])
    msg_pair('Public', lan.properties['public'].to_s)

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

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