From 070b7a98f44fdba4dc4780f5bff397d2ef8431c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Wed, 6 Jun 2018 15:58:54 +0200 Subject: [PATCH] F#2153 Do Command flush requires one parameter to run (#2154) ## USAGE flush 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 --- src/cli/etc/onehost.yaml | 3 +++ src/oca/ruby/opennebula/host.rb | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cli/etc/onehost.yaml b/src/cli/etc/onehost.yaml index b12d09e202..d4ed08fecb 100644 --- a/src/cli/etc/onehost.yaml +++ b/src/cli/etc/onehost.yaml @@ -74,3 +74,6 @@ - :ALLOCATED_CPU - :ALLOCATED_MEM - :STAT + +:default_actions: + - :flush: resched diff --git a/src/oca/ruby/opennebula/host.rb b/src/oca/ruby/opennebula/host.rb index e75afe1343..0bfa236b6d 100644 --- a/src/oca/ruby/opennebula/host.rb +++ b/src/oca/ruby/opennebula/host.rb @@ -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