1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-04-01 06:50:25 +03:00

feature #3087: add cluster name to onevm show

This commit is contained in:
Javi Fontan 2014-07-23 15:48:40 +02:00
parent 736c64dff3
commit 9bebffe6a6

View File

@ -236,6 +236,28 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
str_h1="%-80s"
str="%-20s: %-20s"
cluster = nil
if %w{ACTIVE SUSPENDED POWEROFF}.include? vm.state_str
cluster_id = vm['/VM/HISTORY_RECORDS/HISTORY[last()]/CID']
else
cluster_id = nil
end
if cluster_id
if cluster_id == "-1"
cluster = "default"
else
clu = OpenNebula::Cluster.new(OpenNebula::Cluster.build_xml(cluster_id), @client)
rc = clu.info
if OpenNebula.is_error?(rc)
cluster = "ERROR"
else
cluster = clu["NAME"]
end
end
end
CLIHelper.print_header(
str_h1 % "VIRTUAL MACHINE #{vm['ID']} INFORMATION")
puts str % ["ID", vm.id.to_s]
@ -248,9 +270,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
puts str % ["HOST",
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME']] if
%w{ACTIVE SUSPENDED POWEROFF}.include? vm.state_str
puts str % ["CLUSTER ID",
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/CID'] ] if
%w{ACTIVE SUSPENDED POWEROFF}.include? vm.state_str
puts str % ["CLUSTER ID", cluster_id ] if cluster_id
puts str % ["CLUSTER", cluster ] if cluster
puts str % ["START TIME",
OpenNebulaHelper.time_to_str(vm['/VM/STIME'])]
puts str % ["END TIME",