Class: Chef::Knife::ProfitbricksIpblockDelete

Inherits:
Chef::Knife
  • Object
show all
Includes:
ProfitbricksBase
Defined in:
lib/chef/knife/profitbricks_ipblock_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



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/chef/knife/profitbricks_ipblock_delete.rb', line 10

def run
  connection
  @name_args.each do |ipblock_id|
    begin
      ipblock = ProfitBricks::IPBlock.get(ipblock_id)
    rescue Excon::Errors::NotFound
      ui.error("IP block ID #{ipblock_id} not found. Skipping.")
      next
    end

    msg_pair('ID', ipblock.id)
    msg_pair('Location', ipblock.properties['location'])
    msg_pair('IP Addresses', ipblock.properties['ips'])

    confirm('Do you really want to delete this IP block')

    ipblock.delete
    ui.warn("Released IP block #{ipblock.id}")
  end
end