[one-users] VM_HOOK "on = CREATE" cannot work on remote hosts

Carlos Martín Sánchez cmartin at opennebula.org
Thu Jun 21 03:13:09 PDT 2012


Hi,

Indeed, the hook on running is executed after the VM is up and running. You
should also take into account that all the hooks are asynchronous,
OpenNebula will not wait for them to move on to the next states.

If you need to execute a preparation hook before the VM deployment, you'll
have to modify the deploy script, located at
/var/lib/one/remotes/vmm/<hypervisor>/deploy

After that, execute 'onehost sync'. OpenNebula will copy the modified
remotes in the next Host monitorization cycle.


Regards

--
Carlos Martín, MSc
Project Engineer
OpenNebula - The Open-source Solution for Data Center Virtualization
www.OpenNebula.org | cmartin at opennebula.org |
@OpenNebula<http://twitter.com/opennebula><cmartin at opennebula.org>



On Tue, Jun 19, 2012 at 10:44 AM, Akihiko Ota <skywalker.37th at gmail.com>wrote:

> Hi Carlos,
>
> Hmm... It seems that the RUNNING hook executes the script
> simultaneously with starting of VM. I'd like to execute the script on
> remote host before VM begins to start because this script does some
> preparation for VM.
>
> Now, I am using the DONE hook to execute this script to clean up after
> VM shutdown. I expect this config works fine.
>
> Thanks,
>
> --
> Akihiko Ota
>
> From: Carlos Martín Sánchez <cmartin at opennebula.org>
> Subject: Re: [one-users] VM_HOOK "on = CREATE" cannot work on remote hosts
> Date: Mon, 18 Jun 2012 18:19:16 +0200
>
> > Hi,
> >
> > When a VM is created it is not assigned yet to any host, until the
> > scheduler decides to deploy it, thus the hook can't be remote.
> > You can use the RUNNING hook instead.
> >
> > Regards
> > --
> > Carlos Martín, MSc
> > Project Engineer
> > OpenNebula - The Open-source Solution for Data Center Virtualization
> > www.OpenNebula.org | cmartin at opennebula.org |
> > @OpenNebula<http://twitter.com/opennebula><cmartin at opennebula.org>
> >
> >
> >
> > On Mon, Jun 18, 2012 at 8:34 AM, Akihiko Ota <skywalker.37th at gmail.com
> >wrote:
> >
> >> Hi,
> >>
> >> I tryed to run a script on remote hosts by VM_HOOK. It works as
> >> intended if it is defined "on = DONE", but don't work if defined "on =
> >> CREATE".
> >> I have defined a hook in etc/oned.conf as follows:
> >>
> >> VM_HOOK = [
> >>   name      = "clear_work",
> >>   on        = "CREATE",
> >>   command   = "ft/clear_work.sh",
> >>   remote    = "YES",
> >>   arguments = "" ]
> >>
> >> Then deployed the script to remote VM hosting machines by "onehost
> sync",
> >> and restart oned. But the HOOK had failed.
> >>
> >> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: LOG I 166 Command
> >> execution fail: /var/tmp/one/hooks//ft/clear_work.sh ""
> >> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: LOG I 166 sh:
> >> /var/tmp/one/hooks//ft/clear_work.sh: No such file or directory
> >> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: LOG I 166 ExitCode:
> >> 127
> >> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: EXECUTE FAILURE
> >> 166 clear_work: -
> >>
> >> "/var/tmp/one/hooks//ft/clear_work.sh" script exists on all VM hosting
> >> machines. So, I had a try deploy a dummy script onto the OpenNebula
> >> frontend machine:
> >>
> >> [ascadm at frontend]% /bin/hostname
> >> frontend
> >> [ascadm at frontend]% mkdir -p /var/tmp/one/hooks//ft/
> >> [ascadm at frontend]% cat > /var/tmp/one/hooks//ft/clear_work.sh
> >> #!/bin/sh
> >> /bin/hostname
> >> ^D
> >> [ascadm at frontend]% chmod +x /var/tmp/one/hooks//ft/clear_work.sh
> >> [ascadm at frontend]% onevm create ~/work/vms/normal.one
> >> ID: 167
> >>
> >> [ascadm at frontend]% less /srv/cloud/one/var/oned.log
> >> (snip)
> >> Mon Jun 18 14:40:58 2012 [HKM][D]: Message received: LOG I 167
> ExitCode: 0
> >> Mon Jun 18 14:40:58 2012 [HKM][D]: Message received: EXECUTE SUCCESS
> >> 167 clear_work: frontend
> >> (snip)
> >>
> >> It seems HOOK script runs on the frontend machine instead of the
> >> remote host. Is this correct behavior?
> >>
> >> I am using OpenNebula 3.2.1 on CentOS 5.7(x86_64) now.
> >>
> >> Thanks,
> >>
> >> --
> >> Akihiko Ota
> >> _______________________________________________
> >> Users mailing list
> >> Users at lists.opennebula.org
> >> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20120621/84095a26/attachment-0003.htm>


More information about the Users mailing list