diff --git a/src/cli/onehost b/src/cli/onehost index 946fa2c311..b54fc4109b 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -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 diff --git a/src/oca/ruby/OpenNebula/Host.rb b/src/oca/ruby/OpenNebula/Host.rb index e56cd64fc4..1519351f80 100644 --- a/src/oca/ruby/OpenNebula/Host.rb +++ b/src/oca/ruby/OpenNebula/Host.rb @@ -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)