1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Merge branch 'feature-1323'

This commit is contained in:
Ruben S. Montero 2012-07-02 00:00:22 +02:00
commit a801d4f220
2 changed files with 39 additions and 9 deletions

View File

@ -67,7 +67,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
}
CREAT_OPTIONS = [ IM, VMM, VNET, OneClusterHelper::CLUSTER ]
########################################################################
# Formatters for arguments
########################################################################
@ -100,7 +100,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
helper.create_resource(options) do |host|
host.allocate(args[0],
host.allocate(args[0],
options[:im],
options[:vmm],
options[:vnm],
@ -191,4 +191,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
:options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS do
helper.list_pool(options, true)
end
flush_desc = <<-EOT.unindent
Reschedules the VMS so the host is freed.
EOT
command :flush, top_desc, [:range,:hostid_list] do
helper.perform_actions(args[0],options,"flush") do |host|
host.flush
end
end
end

View File

@ -37,11 +37,11 @@ module OpenNebula
SHORT_HOST_STATES={
"INIT" => "init",
"MONITORING_MONITORED" => "update",
"MONITORING_MONITORED" => "update",
"MONITORED" => "on",
"ERROR" => "err",
"DISABLED" => "off",
"MONITORING_ERROR" => "retry",
"MONITORING_ERROR" => "retry",
}
# Creates a Host description with just its identifier
@ -72,7 +72,7 @@ module OpenNebula
#######################################################################
# XML-RPC Methods for the Host
#######################################################################
# Retrieves the information of the given Host.
def info()
super(HOST_METHODS[:info], 'HOST')
@ -107,6 +107,26 @@ module OpenNebula
set_enabled(false)
end
def flush()
self.disable
vm_pool = OpenNebula::VirtualMachinePool.new(@client,
VirtualMachinePool::INFO_ALL_VM)
rc = vm_pool.info
if OpenNebula.is_error?(rc)
puts rc.message
exit -1
end
vm_pool.each do |vm|
hid = vm['HISTORY_RECORDS/HISTORY[last()]/HID']
if hid == self['ID']
vm.resched
end
end
end
# Replaces the template contents
#
# +new_template+ New template contents
@ -125,12 +145,12 @@ module OpenNebula
# host.monitoring( ['HOST_SHARE/FREE_CPU', 'HOST_SHARE/RUNNING_VMS'] )
#
# { "HOST_SHARE/RUNNING_VMS" =>
# [["1337266000", "1"],
# ["1337266044", "1"],
# [["1337266000", "1"],
# ["1337266044", "1"],
# ["1337266088", "3"]],
# "HOST_SHARE/FREE_CPU" =>
# [["1337266000", "800"],
# ["1337266044", "800"],
# [["1337266000", "800"],
# ["1337266044", "800"],
# ["1337266088", "800"]]
# }
def monitoring(xpath_expressions)