Class: Wakame::Cli::Subcommand::Status
- Inherits:
-
Object
- Object
- Wakame::Cli::Subcommand::Status
- Includes:
- Wakame::Cli::Subcommand
- Defined in:
- lib/wakame/runner/administrator_command.rb
Constant Summary collapse
- STATUS_TMPL =
<<__E__ <%- if cluster -%> Cluster : <%= cluster["name"].to_s %> (<%= cluster_status_msg(cluster["status"]) %>) <%- cluster["resources"].keys.each { |res_id| resource = body["resources"][res_id] -%> <%= resource["class_type"] %> : <current=<%= resource["instance_count"] %> min=<%= resource["min_instances"] %>, max=<%= resource["max_instances"] %><%= resource["require_agent"] ? "" : ", AgentLess" %>> <%- resource["services_ref"].each { |svc_inst| -%> <%= svc_inst["id"] %> (<%= svc_status_msg(svc_inst["status"]) %>) <%- } -%> <%- } -%> <%- if cluster["services"].size > 0 -%> Instances (<%= cluster["services"].size %>): <%- cluster["services"].keys.each { |svc_id| svc = body["services"][svc_id] -%> <%= svc_id %> : <%= svc["resource_ref"]["class_type"] %> (<%= svc_status_msg(svc["status"]) %>) <%- if svc["agent_ref"] -%> On VM: <%= svc["agent_ref"]["id"] %> <%- end -%> <%- } -%> <%- end -%> <%- if cluster["cloud_hosts"].size > 0 -%> Cloud Host (<%= cluster["cloud_hosts"].size %>): <%- cluster["cloud_hosts"].keys.each { |host_id| cloud_host = body["cloud_hosts"][host_id] -%> <%= host_id %> : <% if cloud_host["agent_id"] %>bind to <%= cloud_host["agent_id"] %><% end %> <%- } -%> <%- end -%> <%- else # if cluster -%> Cluster: No cluster data is loaded in master. (Run import_cluster_config first) <%- end # if cluster -%> <%- if agent_pool && agent_pool["group_active"].size > 0 -%> Agents (<%= agent_pool["group_active"].size %>): <%- agent_pool["group_active"].keys.each { |agent_id| a = body["agents"][agent_id] -%> <%= a["id"] %> : <%= a["vm_attr"]["local_ipv4"] %>, <%= a["vm_attr"]["public_ipv4"] %>, <%= (Time.now - Time.parse(a["last_ping_at"])).to_i %> sec(s), placement=<%= a["vm_attr"]["availability_zone"] %> (<%= svc_status_msg(a["status"]) %>) <%- if a["reported_services"].size > 0 && !cluster["services"].empty? -%> Services (<%= a["reported_services"].size %>): <%= a["reported_services"].keys.collect{ |svc_id| body["services"][svc_id]["resource_ref"]["class_type"] }.join(', ') %> <%- end -%> <%- } -%> <%- else -%> Agents (0): None of agents are observed. <%- end -%> __E__
- SVC_STATUS_MSG =
{ Wakame::Service::STATUS_TERMINATE=>'Terminated', Wakame::Service::STATUS_INIT=>'Initialized', Wakame::Service::STATUS_OFFLINE=>'Offline', Wakame::Service::STATUS_ONLINE=>'Online', Wakame::Service::STATUS_UNKNOWN=>'Unknown', Wakame::Service::STATUS_FAIL=>'Fail', Wakame::Service::STATUS_STARTING=>'Starting...', Wakame::Service::STATUS_STOPPING=>'Stopping...', Wakame::Service::STATUS_RELOADING=>'Reloading...', Wakame::Service::STATUS_MIGRATING=>'Migrating...', Wakame::Service::STATUS_ENTERING=>'Entering...', Wakame::Service::STATUS_QUITTING=>'Quitting...' }
- CLUSTER_STATUS_MSG =
{ Wakame::Service::ServiceCluster::STATUS_OFFLINE=>'Offline', Wakame::Service::ServiceCluster::STATUS_ONLINE=>'Online', Wakame::Service::ServiceCluster::STATUS_PARTIAL_ONLINE=>'Partial Online' }
Instance Method Summary collapse
Methods included from Wakame::Cli::Subcommand
Instance Method Details
#parse(args) ⇒ Object
359 360 361 362 363 364 365 366 |
# File 'lib/wakame/runner/administrator_command.rb', line 359 def parse(args) @params = {} create_parser(args){|opts| opts. = "Usage: status" #opts.separator "" #opts.separator "options:" } end |
#print_result ⇒ Object
372 373 374 375 376 377 378 379 380 |
# File 'lib/wakame/runner/administrator_command.rb', line 372 def print_result() require 'time' body = @res[1]["data"] map_ref_data(body) cluster = body["cluster"] agent_pool = body["agent_pool"] puts ERB.new(STATUS_TMPL, nil, '-').result(binding) end |
#run(requester) ⇒ Object
368 369 370 |
# File 'lib/wakame/runner/administrator_command.rb', line 368 def run(requester) @res = requester.request(@params) end |