Sha256: e29c5bef22c55fa0af59effd805816eb50b092d9be72c4c2a816038011e8cab0
Contents?: true
Size: 1.43 KB
Versions: 43
Compression:
Stored size: 1.43 KB
Contents
module Brightbox command [:cloudips] do |cmd| cmd.desc I18n.t("cloudips.map.desc") cmd.arg_name "cloudip-id destination" cmd.command [:map] do |c| c.desc "Unmap mapped IPs before remapping them" c.switch [:u, "unmap"], :negatable => false c.action do |global_options, options, args| if args.size > 2 raise "Too many arguments" end if args.size < 2 raise "You must specify the cloud ip id and the destination" end ip_id = args.first ip = CloudIP.find ip_id destination_id = args.last case destination_id when /^srv\-/ server = Server.find destination_id destination_id = server.interfaces.first["id"] info "Mapping #{ip} to interface #{destination_id} on #{server}" else info "Mapping #{ip} to destination #{destination_id}" end if ip.mapped? if options[:u] ip.unmap 3.times do break unless ip.mapped? sleep 1 ip.reload end else raise "Refusing to map already mapped IP #{ip}" end end ip.map destination_id # Wait up to 3 seconds for mapping to complete 3.times do ip.reload break if ip.mapped? sleep 1 end render_table([ip], global_options) end end end end
Version data entries
43 entries across 43 versions & 1 rubygems