Sha256: eed09c43a8d52cf3bd158e22900979670b635a88a8934b2c9e781a992929c1d4

Contents?: true

Size: 794 Bytes

Versions: 7

Compression:

Stored size: 794 Bytes

Contents

desc 'destroy Cloud IPs'
arg_name '[cloudip-id...]'
command [:destroy] do |c|
  c.desc "Unmap mapped ips before destroying them"
  c.switch [:u, "unmap"]

  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?
        if options[:u]
          info "Unmapping cloud ip #{ip}"
          ip.unmap
          3.times do
            break unless ip.mapped?
            sleep 1
            ip.reload
          end
        else
          raise "Cannot destroy mapped cloud ip #{ip}"
        end
      end
      info "Destroying cloud ip #{ip}"
      ip.destroy
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bbcloud-0.11.2 lib/bbcloud/commands/cloudips-destroy.rb
bbcloud-0.11.1 lib/bbcloud/commands/cloudips-destroy.rb
bbcloud-0.11.0 lib/bbcloud/commands/cloudips-destroy.rb
bbcloud-0.10.1 lib/bbcloud/commands/cloudips-destroy.rb
bbcloud-0.9.2 lib/bbcloud/commands/cloudips-destroy.rb
bbcloud-0.9.1 lib/bbcloud/commands/cloudips-destroy.rb
bbcloud-0.9 lib/bbcloud/commands/cloudips-destroy.rb