Sha256: d15b95f07782e737877f058fedae24508115edcfd8b23222b0c642f7df3fa7eb

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'chef/knife/profitbricks_base'

class Chef
  class Knife
    class ProfitbricksLanDelete < Knife
      include Knife::ProfitbricksBase

      banner 'knife profitbricks lan delete LAN_ID [LAN_ID] (options)'

      option :datacenter_id,
             short: '-D DATACENTER_ID',
             long: '--datacenter-id DATACENTER_ID',
             description: 'Name of the data center',
             proc: proc { |datacenter_id| Chef::Config[:knife][:datacenter_id] = datacenter_id }

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knife-profitbricks-2.0.1 lib/chef/knife/profitbricks_lan_delete.rb
knife-profitbricks-1.2.1 lib/chef/knife/profitbricks_lan_delete.rb