Sha256: d7769d1d473502ebd7503201249b3efd4a1a4490ab8f8d978bd480fc2fd287c8

Contents?: true

Size: 967 Bytes

Versions: 14

Compression:

Stored size: 967 Bytes

Contents

module Brightbox
  command [:cloudips] do |cmd|
    cmd.desc I18n.t("cloudips.destroy.desc")
    cmd.arg_name "[cloudip-id...]"
    cmd.command [:destroy] do |c|
      c.desc "Unmap mapped IPs before destroying them"
      c.switch [:u, "unmap"], :negatable => false

      c.action do |_global_options, options, args|
        if args.empty?
          raise "You must specify the Cloud IPs you want to destroy"
        end

        ips = CloudIP.find_or_call(args) do |id|
          raise "Couldn't find Cloud IP #{id}"
        end

        ips.each do |ip|
          if ip.mapped?
            raise "Cannot destroy mapped Cloud IP #{ip}" unless options[:u]

            info "Unmapping Cloud IP #{ip}"
            ip.unmap
            3.times do
              break unless ip.mapped?

              sleep 1
              ip.reload
            end
          end

          info "Destroying Cloud IP #{ip}"
          ip.destroy
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
brightbox-cli-4.8.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.7.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.6.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.5.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.4.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.3.2 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.3.1 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.3.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.2.1 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.2.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.1.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.0.0 lib/brightbox-cli/commands/cloudips/destroy.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/commands/cloudips/destroy.rb