Sha256: 254dcdff252984b642fdcd73adabf0196149f3b0e601a18cc6613b6e7e12e2ea

Contents?: true

Size: 919 Bytes

Versions: 4

Compression:

Stored size: 919 Bytes

Contents

module Brightbox
  command [:cloudips] do |cmd|

    cmd.desc "unmap Cloud IPs"
    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 { |ip| ip.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-1.1.0 lib/brightbox-cli/commands/cloudips-unmap.rb
brightbox-cli-1.0.0 lib/brightbox-cli/commands/cloudips-unmap.rb
brightbox-cli-1.0.0.rc2 lib/brightbox-cli/commands/cloudips-unmap.rb
brightbox-cli-1.0.0.rc1 lib/brightbox-cli/commands/cloudips-unmap.rb