Sha256: 10c321f6440e7582863c1a5f7776d1bf5a7542b863ed2352f567c7ce1c546df5

Contents?: true

Size: 921 Bytes

Versions: 4

Compression:

Stored size: 921 Bytes

Contents

module Brightbox
  command [:cloudips] do |cmd|
    cmd.desc I18n.t("cloudips.unmap.desc")
    cmd.arg_name "cloudip-id..."
    cmd.command [:unmap] do |c|
      c.action do |global_options, _options, args|
        if args.empty?
          raise "You must specify the Cloud IPs you want to unmap"
        end

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

        ips.each do |ip|
          if ip.mapped?
            info "Unmapping Cloud IP #{ip}"
            ip.unmap
            ip.reload
          else
            warn "Cloud IP #{ip} already unmapped"
          end
        end

        # Wait up to 3 seconds for unmapping to complete
        3.times do
          break unless ips.find(&:mapped?)

          sleep 1
          ips.each { |ip| ip.reload if ip.mapped? }
        end

        render_table(ips, global_options)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0 lib/brightbox-cli/commands/cloudips/unmap.rb
brightbox-cli-5.0.0.rc2 lib/brightbox-cli/commands/cloudips/unmap.rb
brightbox-cli-5.0.0.rc1 lib/brightbox-cli/commands/cloudips/unmap.rb
brightbox-cli-5.0.0.alpha lib/brightbox-cli/commands/cloudips/unmap.rb