mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
Feature #3532: Add purty table for Wild VMs in CLI
This commit is contained in:
parent
4d151b1745
commit
90b0c49195
@ -406,8 +406,39 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
CLIHelper.print_header(str_h1 % "MONITORING INFORMATION", false)
|
||||
|
||||
wilds = host.to_hash['HOST']['TEMPLATE']['VM']
|
||||
|
||||
host.delete_element("TEMPLATE/VM")
|
||||
host.delete_element("TEMPLATE_WILDS")
|
||||
|
||||
puts host.template_str
|
||||
|
||||
puts
|
||||
CLIHelper.print_header("WILD VIRTUAL MACHINES", false)
|
||||
puts
|
||||
|
||||
format = "%30s %36s %4s %10s"
|
||||
CLIHelper.print_header(format % ["NAME", "UUID", "CPU", "MEMORY"],
|
||||
false)
|
||||
|
||||
wilds.each do |wild|
|
||||
wild_tmplt = Base64::decode64(wild['IMPORT_TEMPLATE']).split("\n")
|
||||
name = wild_tmplt.select { |line|
|
||||
line[/^NAME/]
|
||||
}[0].split("=")[1].gsub("\"", " ").strip
|
||||
uuid = wild_tmplt.select { |line|
|
||||
line[/^IMPORT_VM_ID/]
|
||||
}[0].split("=")[1].gsub("\"", " ").strip
|
||||
memory = wild_tmplt.select { |line|
|
||||
line[/^MEMORY/]
|
||||
}[0].split("=")[1].gsub("\"", " ").strip
|
||||
cpu = wild_tmplt.select { |line|
|
||||
line[/^MEMORY/]
|
||||
}[0].split("=")[1].gsub("\"", " ").strip
|
||||
|
||||
puts format % [name, uuid, memory, cpu]
|
||||
end
|
||||
|
||||
puts
|
||||
CLIHelper.print_header("VIRTUAL MACHINES", false)
|
||||
puts
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
require 'opennebula/pool_element'
|
||||
require 'base64'
|
||||
|
||||
module OpenNebula
|
||||
class Host < PoolElement
|
||||
@ -206,6 +207,12 @@ module OpenNebula
|
||||
SHORT_HOST_STATES[state_str]
|
||||
end
|
||||
|
||||
# Returns the <TEMPLATE> element in text form
|
||||
# indent:: _Boolean_ indents the resulting string, default true
|
||||
def template_str(indent=true)
|
||||
template_like_str('TEMPLATE', indent)
|
||||
end
|
||||
|
||||
private
|
||||
def set_enabled(enabled)
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
@ -139,7 +139,7 @@ module OpenNebula
|
||||
}
|
||||
end
|
||||
|
||||
# Gets an array of text from elemenets extracted
|
||||
# Gets an array of text from elements extracted
|
||||
# using the XPATH expression passed as filter
|
||||
def retrieve_elements(filter)
|
||||
elements_array = Array.new
|
||||
@ -162,7 +162,7 @@ module OpenNebula
|
||||
|
||||
end
|
||||
|
||||
# Gets an attribute from an elemenT
|
||||
# Gets an attribute from an element
|
||||
# key:: _String_ xpath for the element
|
||||
# name:: _String_ name of the attribute
|
||||
def attr(key,name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user