Sha256: 1fbbc7975f5a3955d72aa85d390e0ffc6af808bdf5be9843bfdde470b43425e3

Contents?: true

Size: 861 Bytes

Versions: 6

Compression:

Stored size: 861 Bytes

Contents

require 'chef/knife/profitbricks_base'

class Chef
  class Knife
    class ProfitbricksIpblockDelete < Knife
      include Knife::ProfitbricksBase

      banner 'knife profitbricks ipblock delete IPBLOCK_ID [IPBLOCK_ID]'

      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
knife-profitbricks-2.0.1 lib/chef/knife/profitbricks_ipblock_delete.rb
knife-profitbricks-1.2.1 lib/chef/knife/profitbricks_ipblock_delete.rb
knife-profitbricks-1.2.0 lib/chef/knife/profitbricks_ipblock_delete.rb
knife-profitbricks-1.1.2 lib/chef/knife/profitbricks_ipblock_delete.rb
knife-profitbricks-1.1.1 lib/chef/knife/profitbricks_ipblock_delete.rb
knife-profitbricks-1.0.0 lib/chef/knife/profitbricks_ipblock_delete.rb