Class: Wakame::Command::Status

Inherits:
Object
  • Object
show all
Includes:
Wakame::Command, Service
Defined in:
lib/wakame/command/status.rb

Constant Summary

Constants included from Service

Service::Property, Service::STATUS_ENTERING, Service::STATUS_FAIL, Service::STATUS_INIT, Service::STATUS_MIGRATING, Service::STATUS_OFFLINE, Service::STATUS_ONLINE, Service::STATUS_QUITTING, Service::STATUS_RELOADING, Service::STATUS_RUNNING, Service::STATUS_STARTING, Service::STATUS_STOPPING, Service::STATUS_TERMINATE, Service::STATUS_UNKNOWN

Instance Method Summary collapse

Methods included from Wakame::Command

included, #options=, #params

Instance Method Details

#runObject



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
# File 'lib/wakame/command/status.rb', line 6

def run
  Wakame::StatusDB.barrier {
    res = {
      :cluster=>nil, 
      :agent_pool=>nil, 
      :agents=>{}, 
      :services=>{}, 
      :resources=>{},
      :cloud_hosts=>{}
    }

    res[:agent_pool] = {
      :group_active => Wakame::Models::AgentPool.instance.group_active,
      :group_observed => Wakame::Models::AgentPool.instance.group_observed
    }
    Wakame::Models::AgentPool.instance.dataset.all.each { |row|
      res[:agents][row[:agent_id]] = Agent.find(row[:agent_id]).dump_attrs
    }

    cluster_id = master.cluster_manager.clusters.first
    if cluster_id
      cluster = ServiceCluster.find(cluster_id)
      res[:cluster] = cluster.dump_attrs
      cluster.services.keys.each { |id|
        res[:services][id]=ServiceInstance.find(id).dump_attrs
      }
      
      cluster.resources.keys.each { |id|
        res[:resources][id]=Resource.find(id).dump_attrs
      }
      
      cluster.cloud_hosts.keys.each { |id|
        res[:cloud_hosts][id]=CloudHost.find(id).dump_attrs
      }
    end
    res
  }

end