From 8ef200b6b26f5eee29f00b7abf193b6b3b71a306 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Mon, 10 Oct 2016 16:46:14 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20script=20onevm-all?= =?UTF-8?q?=20pour=20qu'il=20fonctionne=20avec=20one=205.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les actions ont changés sur cette version, "resume" résoud tout :) Le service doit également démarrer après libvirt et s'arrêter avant. --- init/onenode.service | 2 +- scripts/onevm-all | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/init/onenode.service b/init/onenode.service index 44e3964..c910a83 100644 --- a/init/onenode.service +++ b/init/onenode.service @@ -1,6 +1,6 @@ [Unit] Description=OpenNebula Node starter -After=opennebula.service opennebula-sunstone.service +After=opennebula.service opennebula-sunstone.service libvirt-bin.service [Service] Type=oneshot diff --git a/scripts/onevm-all b/scripts/onevm-all index 90fddab..b6a73f2 100755 --- a/scripts/onevm-all +++ b/scripts/onevm-all @@ -27,7 +27,7 @@ INTERVAL=1 def _wait(vm, st) wait = 0 - while vm.status != st + while vm.status != st vm.info if vm.status == 'unkn' break @@ -73,9 +73,14 @@ def _do_resume(vm, wait) if vm.status == "susp" puts("Resume on #{vm.name}") vm.resume +# elsif vm.status == 'save' +# puts("Recover on #{vm.name}") +# # Try to recover VM with retry action +# vm.recover(2) +# vm.resume elsif vm.status == 'unkn' - puts("Boot on #{vm.name}") - vm.boot + puts("Resume on #{vm.name}") + vm.resume else return -1 end @@ -134,7 +139,7 @@ SUPPORTED = ['status', 'boot', 'resume', 'shutdown', 'suspend'] if not SUPPORTED.include?(options[:action]) puts("Action : #{options[:action]}) is not supported") - exit -1 + exit(-1) end begin @@ -143,7 +148,7 @@ begin end rescue puts("#{options[:creds]}: Problem loading credentials, check if file exists.") - exit -1 + exit(-1) end begin @@ -154,7 +159,7 @@ begin rc = vm_pool.info if OpenNebula.is_error?(rc) puts rc.message - exit -1 + exit(-1) end vm_pool.each do |vm| @@ -162,6 +167,7 @@ begin when "status" puts("#{vm.name}\t#{vm.status}") when "boot" + puts("DEBUG #{vm.status}") if vm.status == "unkn" puts("Booting #{vm.name} ...") vm.boot @@ -176,6 +182,6 @@ begin end rescue Exception => e puts e.message - exit -1 + exit(-1) end exit 0