From 7a286e5bc6282175057c4eca51eb16c4c88c3178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Cuissinat?= Date: Wed, 19 Oct 2016 11:47:52 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Cosm=C3=A9tique=20diagnose=20Virtualisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: #17590 @20m --- diagnose/04-virtualisation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diagnose/04-virtualisation b/diagnose/04-virtualisation index 87c2eb0..58fbb0d 100755 --- a/diagnose/04-virtualisation +++ b/diagnose/04-virtualisation @@ -76,7 +76,7 @@ EchoGras "*** Machines Virtuelles" VMs=$( one 'onevm list -l ID,NAME,STAT' | tail -n +2 | grep -ve '\-TEST ' | awk '{print $1}' ) if [[ -z ${VMs} ]] then - printf ". %${len_pf}s " "Pas de machines virtuelles instanciées" + printf ". %${len_pf}s " "Aucune machine virtuelle instanciée" echo "" else for VM in $VMs ; do From e7f8684c0c50024610cc297569ec8847444e0bcf Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Tue, 22 Nov 2016 10:53:50 +0100 Subject: [PATCH 2/3] =?UTF-8?q?onenode.service=20n=C3=A9cessite=20un=20ser?= =?UTF-8?q?veur=20instanci=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le service « onenode.service » reste en erreur après instance : - Le script « onevm-all » ne peut pas se connecter à « oned » avant l’intance - Le service « onenode.service » n’est pas redémarrer pendant l’instance Il faut donc éviter que le service ne démarre avant que la machine soit instanciée. * init/onenode.service (ConditionPathExists): Ajout d’un test sur le template /etc/eole/release. Ref: #17589 --- init/onenode.service | 1 + 1 file changed, 1 insertion(+) diff --git a/init/onenode.service b/init/onenode.service index c910a83..abe0518 100644 --- a/init/onenode.service +++ b/init/onenode.service @@ -1,6 +1,7 @@ [Unit] Description=OpenNebula Node starter After=opennebula.service opennebula-sunstone.service libvirt-bin.service +ConditionPathExists=/etc/eole/release [Service] Type=oneshot From e9ff4ad34cf648d686ed75674809b737e4be91c0 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 3 May 2017 11:40:08 +0200 Subject: [PATCH 3/3] Correction du lancement du service onenode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le service onenode ne se lance pas a cause d'une boucle dans les dépendances de services. Pour régler le problème on le lance après la multi-user.target De plus au moment ou le service se lance opennebula n'est pas complètement lancé alors le script essaye d'ouvrir des connections pendant 20 secondes avant de remonter un problème. Enfin on garde une liste des machines qui sont "running" avant l'arrêt du serveur pour pouvoir les relance proprement. Contribution de Cadoles (htts://www.cadoles.com) ref #20338 @6h --- init/onenode.service | 5 +-- scripts/onevm-all | 79 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 20 deletions(-) diff --git a/init/onenode.service b/init/onenode.service index abe0518..ceb5fb8 100644 --- a/init/onenode.service +++ b/init/onenode.service @@ -2,6 +2,7 @@ Description=OpenNebula Node starter After=opennebula.service opennebula-sunstone.service libvirt-bin.service ConditionPathExists=/etc/eole/release +After=multi-user.target [Service] Type=oneshot @@ -10,8 +11,8 @@ Environment=ENDPOINT=http://127.0.0.1:2633/RPC2 TimeoutSec=1min RemainAfterExit=yes Restart=no -ExecStart=/usr/share/eole/sbin/onevm-all -w -c ${CREDS} -e ${ENDPOINT} -a "resume" -ExecStop=/usr/share/eole/sbin/onevm-all -w -c ${CREDS} -e ${ENDPOINT} -a "suspend" +ExecStart=/usr/share/eole/sbin/onevm-all -t 20 -w -c ${CREDS} -e ${ENDPOINT} -a "resume" +ExecStop=/usr/share/eole/sbin/onevm-all -t 20 -w -c ${CREDS} -e ${ENDPOINT} -a "suspend" [Install] WantedBy=multi-user.target diff --git a/scripts/onevm-all b/scripts/onevm-all index b6a73f2..8d43ce4 100755 --- a/scripts/onevm-all +++ b/scripts/onevm-all @@ -5,6 +5,11 @@ ############################################################################## ONE_LOCATION=ENV["ONE_LOCATION"] USER=ENV["user"] +RUNVMFILE="/var/lib/one/running.bck" +TIMEOUT=20 + +# oneadmin user flag value +USERFLAG=-2 if !ONE_LOCATION RUBY_LIB_LOCATION="/usr/lib/one/ruby" @@ -55,13 +60,16 @@ end # AIM: Suspend a virtual machine # def _do_suspend(vm, wait) + fd = File.open(RUNVMFILE,'a') if vm.status == "runn" puts("Suspending #{vm.name} ...") + fd.write("#{vm.id}\n") vm.suspend if wait _wait(vm, "susp") end end + fd.close end # @@ -69,28 +77,34 @@ end # PARAM: OpenNebula::VirtualMachine object # AIM: Resum a suspended virtual machines # -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("Resume on #{vm.name}") +def _do_resume(vm, wait, force=FALSE) + if force vm.resume else - return -1 + 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("Resume on #{vm.name}") + vm.resume + else + return -1 + end end + if wait _wait(vm, "runn") end end -options = {:creds => nil, :action => nil, :endpoint => nil} +options = {:creds => nil, :action => nil, :endpoint => nil, + :timeout => nil} parser = OptionParser.new do|opts| opts.banner = "Usage: #{File.basename(__FILE__)} [options]" @@ -106,6 +120,10 @@ parser = OptionParser.new do|opts| options[:endpoint] = value; end + opts.on('-t', '--timeout timeout', 'Timeout for opennebula connection') do |value| + options[:timeout] = value.to_i; + end + opts.on('-w', '--wait', 'Wait for action ends') do |w| options[:wait] = w end @@ -114,6 +132,8 @@ parser = OptionParser.new do|opts| puts opts exit end + + end parser.parse! @@ -133,6 +153,10 @@ if not options[:endpoint] options[:endpoint] = "http://#{ip}:2633/RPC2" end +if not options[:timeout] + options[:timeout] = TIMEOUT +end + # Actions SUPPORTED = ['status', 'boot', 'resume', 'shutdown', 'suspend'] @@ -154,12 +178,24 @@ end begin client = Client.new(CREDENTIALS, options[:endpoint]) - vm_pool = VirtualMachinePool.new(client, -1) + vm_pool = VirtualMachinePool.new(client, USERFLAG) + + if File.exist?(RUNVMFILE) + running_vms = File.open(RUNVMFILE,'r') + else + running_vms = [] + end rc = vm_pool.info - if OpenNebula.is_error?(rc) - puts rc.message - exit(-1) + cnt = 0 + while OpenNebula.is_error?(rc) + if cnt == options[:timeout] + puts rc.message + exit(-1) + end + rc = vm_pool.info + sleep(1) + cnt += 1 end vm_pool.each do |vm| @@ -175,11 +211,18 @@ begin when "suspend" _do_suspend(vm, options[:wait]) when "resume" - _do_resume(vm, options[:wait]) + force = FALSE + if running_vms.include?('vm.id') + force = TRUE + end + _do_resume(vm, options[:wait], force) else puts("#{vm.name}\t#{vm.status}") end end + if options[:action] == "resume" + File.truncate(RUNVMFILE, 0) + end rescue Exception => e puts e.message exit(-1)