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

.flavor_name(server) ⇒ Object



28
29
30
# File 'lib/pec/command/status.rb', line 28

def self.flavor_name(server)
  Yao::Flavor.get(server.flavor['id']).name
end

.ip_addresses(server) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/pec/command/status.rb', line 32

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



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

def self.task(host_name, options, server, config)
  Thor.new.say("Current machine stasus:", :yellow)
  if server
    puts sprintf(
      " %-35s %-10s %-10s %-10s %-10s %-35s %-48s",
      config.name,
      server.status,
      tenant_name(server),
      flavor_name(server),
      server.availability_zone,
      server.ext_srv_attr_host,
      ip_addresses(server)
    )
  else
    puts sprintf(" %-35s %-10s",
      config.name,
      "uncreated"
    )
  end
end

.tenant_name(server) ⇒ Object



24
25
26
# File 'lib/pec/command/status.rb', line 24

def self.tenant_name(server)
  Yao::Tenant.list.find {|tenant| tenant.id == server.tenant_id}.name
end