Class: Pec::Command::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/pec/command/status.rb

Class Method Summary collapse

Methods inherited from Base

print_exception, run

Class Method Details

.before_do ⇒ Object



33
34
35
# File 'lib/pec/command/status.rb', line 33

def self.before_do
  Thor.new.say("Current machine status:", :yellow)
end

.ip_addresses(server) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/pec/command/status.rb', line 25

def self.ip_addresses(server)
  server.addresses.map do |ethers|
    ethers[1].map do |ether|
      ether["addr"]
    end
  end.flatten.join(",")
end

.task(host_name, options, server, config) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pec/command/status.rb', line 4

def self.task(host_name, options, server, config)
  if server
    puts sprintf(
      " %-35s %-10s %-10s %-10s %-10s %-10s %-35s %-48s",
      config.name,
      server.status,
      Pec.fetch_tenant_by_id(server).name,
      Pec.fetch_flavor(server).name,
      server.availability_zone,
      server.key_name,
      server.ext_srv_attr_host,
      ip_addresses(server)
    )
  else
    puts sprintf(" %-35s %-10s",
      config.name,
      "uncreated"
    )
  end
end