Class: AcquiaToolbelt::CLI::Servers

Inherits:
Thor
  • Object
show all
Defined in:
lib/acquia_toolbelt/cli/server.rb

Constant Summary

Constants inherited from Thor

Thor::AmbiguousTaskError, Thor::DynamicTask, Thor::HELP_MAPPINGS, Thor::HiddenTask, Thor::THOR_RESERVED_WORDS, Thor::UndefinedTaskError, Thor::VERSION

Instance Attribute Summary

Attributes included from Thor::Base

#args, #options, #parent_options

Instance Method Summary collapse

Methods inherited from Thor

check_unknown_options!, check_unknown_options?, command_help, default_command, desc, #help, help, long_desc, map, method_option, method_options, package_name, printable_commands, register, stop_on_unknown_option!, stop_on_unknown_option?, subcommand, subcommands

Methods included from Thor::Base

included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses

Instance Method Details

#listObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/acquia_toolbelt/cli/server.rb', line 5

def list
  if options[:subscription]
    subscription = options[:subscription]
  else
    subscription = AcquiaToolbelt::CLI::API.default_subscription
  end

  environment = options[:environment]
  # Determine if we want just a single environment, or all of them at
  # once.
  if environment
    environments = [environment]
  else
    environments = AcquiaToolbelt::CLI::API.environments
  end

  # Loop over each environment and get all the associated server data.
  environments.each do |env|
    ui.say
    ui.say "Environment: #{env}"

    server_env = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{env}/servers"
    server_env.each do |server|
      ui.say
      ui.say "> Host: #{server['fqdn']}"
      ui.say "> Region: #{server['ec2_region']}"
      ui.say "> Instance type: #{server['ami_type']}"
      ui.say "> Availability zone: #{server['ec2_availability_zone']}"

      # Show how many PHP processes this node can have. Note, this is only
      # available on the web servers.
      if server['services'] && server['services']['php_max_procs']
        ui.say "> PHP max processes: #{server['services']['php_max_procs']}"
      end

      if server['services'] && server['services']['status']
        ui.say "> Status: #{server['services']['status']}"
      end

      if server['services'] && server['services']['web']
        ui.say "> Web status: #{server['services']['web']['status']}"
      end

      # The state of varnish.
      if server['services'] && server['services']['varnish']
        ui.say "> Varnish status: #{server['services']['varnish']['status']}"
      end

      # Only load balancers will have the 'external IP' property.
      if server['services'] && server['services']['external_ip']
        ui.say "> External IP: #{server['services']['external_ip']}"
      end

      # If running a dedicated load balancer, there will be a ELB domain
      # associated with the load balancing tier.
      if server['services'] && server['services']['elb_domain_name']
        ui.say "> ELB hostname: #{server['services']['elb_domain_name']}"
      end
    end
  end
end