Class: Chef::Knife::ProfitbricksNicDelete

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

Instance Method Summary collapse

Methods included from ProfitbricksBase

#connection, included, #msg_pair

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chef/knife/profitbricks_nic_delete.rb', line 23

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

    msg_pair('ID', nic.id)
    msg_pair('Name', nic.properties['name'])
    msg_pair('IPs', nic.properties['cores'])
    msg_pair('DHCP', nic.properties['ram'])
    msg_pair('LAN', nic.properties['availabilityZone'])

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

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