1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

F#2153 Do Command flush requires one parameter to run (#2154)

## USAGE
flush <range|hostid_list>
        Disables the host and reschedules all the running VMs in it.

## OPTIONS
     -h, --help                Show this message
     -V, --version             Show version and copyright information
     --user name               User name used to connect to OpenNebula
     --password password       Password to authenticate with OpenNebula
     --endpoint endpoint       URL of OpenNebula xmlrpc frontend command more configurable
This commit is contained in:
Christian González 2018-06-06 15:58:54 +02:00 committed by Ruben S. Montero
parent d58b7cd742
commit dce8615260
2 changed files with 18 additions and 1 deletions

View File

@ -74,3 +74,6 @@
- :ALLOCATED_CPU
- :ALLOCATED_MEM
- :STAT
:default_actions:
- :flush: resched

View File

@ -17,6 +17,7 @@
require 'opennebula/pool_element'
require 'base64'
require 'yaml'
module OpenNebula
class Host < PoolElement
@ -127,6 +128,12 @@ module OpenNebula
def flush()
self.disable
begin
action = YAML.load_file("/etc/one/cli/onehost.yaml")[:default_actions][0][:flush]
rescue Exception => e
STDERR.puts e
end
vm_pool = OpenNebula::VirtualMachinePool.new(@client,
VirtualMachinePool::INFO_ALL_VM)
@ -139,7 +146,14 @@ module OpenNebula
vm_pool.each do |vm|
hid = vm['HISTORY_RECORDS/HISTORY[last()]/HID']
if hid == self['ID']
vm.resched
case action
when "resched"
vm.resched
when "delete-recreate"
vm.recover(4)
else
vm.resched
end
end
end
end