Sha256: 52f7dd007068f6efc617fea1d48bcb67052cbb706052beacf40cde4f295e62a4
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
module Brightbox command [:groups] do |cmd| cmd.desc "Move servers from one server group to another" cmd.arg_name "srv-id ..." cmd.command [:move_servers] do |c| c.desc "Source Server Group" c.flag [:f, :from] c.desc "Target Server Group" c.flag [:t, :to] c.action do |global_options, options, args| unless args && !args.empty? raise "You must specify server ids to move" end source_id = options[:f] destination_id = options[:t] unless source_id && source_id[/^grp-/] && destination_id && destination_id[/^grp-/] raise "You must specify the source server group and destination server group" end source_group = ServerGroup.find source_id destination_group = ServerGroup.find destination_id servers = Server.find_or_call(args) do |id| raise "Couldn't find server #{id}" end info "Moving #{servers.size} servers from server group #{source_group} to server group #{destination_group}" source_group.move_servers servers, destination_group source_group.reload destination_group.reload render_table([source_group, destination_group], global_options) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems