Sha256: d25dad0e86c65142b732043cd5603d0eb5ef1a2c8679d2933cdf4c11a6a051fb

Contents?: true

Size: 1.09 KB

Versions: 43

Compression:

Stored size: 1.09 KB

Contents

module Brightbox
  command [:groups] do |cmd|

    cmd.desc I18n.t("groups.remove_servers.desc")
    cmd.arg_name "grp-id [srv-id...]"
    cmd.command [:remove_servers] do |c|

      c.desc "Remove all servers from group"
      c.switch [:a, :all], :negatable => false

      c.action do |global_options, options, args|
        grp_id = args.shift
        raise "You must specify the server group and the server ids to remove" unless grp_id && grp_id[/^grp-/] && (!args.empty? || options[:a])

        sg = ServerGroup.find grp_id

        servers = if options[:a]
                    sg.server_ids
                  else
                    Server.find_or_call(args) do |id|
                      raise "Couldn't find server #{id}"
                    end
                  end

        if servers.empty?
          info "Server group #{sg} already contains zero servers"
        else
          info "Removing#{" all" if options[:a]} #{servers.size} servers from server group #{sg}"
          sg.remove_servers servers
        end

        sg.reload
        render_table([sg], global_options)
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-3.2.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-3.1.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-3.0.1 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-3.0.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.12.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.11.2 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.11.1 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.11.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.10.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.9.3 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.9.2 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.9.1 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.9.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.8.2 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.8.1 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.8.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.7.1 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.7.0 lib/brightbox-cli/commands/groups/remove-servers.rb
brightbox-cli-2.6.0 lib/brightbox-cli/commands/groups/remove-servers.rb