Hi,<div><br></div><div>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.</div>
<div><br></div><div>If you need to execute a preparation hook before the VM deployment, you'll have to modify the deploy script, located at</div><div>/var/lib/one/remotes/vmm/<hypervisor>/deploy</div><div><br></div>
<div>After that, execute 'onehost sync'. OpenNebula will copy the modified remotes in the next Host monitorization cycle.</div><div><br></div><div><br></div><div>Regards</div><div><br clear="all">--<br>Carlos Martín, MSc<br>
Project Engineer<br>OpenNebula - The Open-source Solution for Data Center Virtualization<div><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> | <a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="mailto:cmartin@opennebula.org" style="color:rgb(42,93,176)" target="_blank"></a></span></div>
<br>
<br><br><div class="gmail_quote">On Tue, Jun 19, 2012 at 10:44 AM, Akihiko Ota <span dir="ltr"><<a href="mailto:skywalker.37th@gmail.com" target="_blank">skywalker.37th@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Carlos,<br>
<br>
Hmm... It seems that the RUNNING hook executes the script<br>
simultaneously with starting of VM. I'd like to execute the script on<br>
remote host before VM begins to start because this script does some<br>
preparation for VM.<br>
<br>
Now, I am using the DONE hook to execute this script to clean up after<br>
VM shutdown. I expect this config works fine.<br>
<br>
Thanks,<br>
<br>
--<br>
Akihiko Ota<br>
<br>
From: Carlos Martín Sánchez <<a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a>><br>
Subject: Re: [one-users] VM_HOOK "on = CREATE" cannot work on remote hosts<br>
Date: Mon, 18 Jun 2012 18:19:16 +0200<br>
<div><br>
> Hi,<br>
><br>
> When a VM is created it is not assigned yet to any host, until the<br>
> scheduler decides to deploy it, thus the hook can't be remote.<br>
> You can use the RUNNING hook instead.<br>
><br>
> Regards<br>
> --<br>
> Carlos Martín, MSc<br>
> Project Engineer<br>
> OpenNebula - The Open-source Solution for Data Center Virtualization<br>
> <a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> |<br>
</div>> @OpenNebula<<a href="http://twitter.com/opennebula" target="_blank">http://twitter.com/opennebula</a>><<a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a>><br>
<div><div>><br>
><br>
><br>
> On Mon, Jun 18, 2012 at 8:34 AM, Akihiko Ota <<a href="mailto:skywalker.37th@gmail.com" target="_blank">skywalker.37th@gmail.com</a>>wrote:<br>
><br>
>> Hi,<br>
>><br>
>> I tryed to run a script on remote hosts by VM_HOOK. It works as<br>
>> intended if it is defined "on = DONE", but don't work if defined "on =<br>
>> CREATE".<br>
>> I have defined a hook in etc/oned.conf as follows:<br>
>><br>
>> VM_HOOK = [<br>
>> name = "clear_work",<br>
>> on = "CREATE",<br>
>> command = "ft/clear_work.sh",<br>
>> remote = "YES",<br>
>> arguments = "" ]<br>
>><br>
>> Then deployed the script to remote VM hosting machines by "onehost sync",<br>
>> and restart oned. But the HOOK had failed.<br>
>><br>
>> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: LOG I 166 Command<br>
>> execution fail: /var/tmp/one/hooks//ft/clear_work.sh ""<br>
>> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: LOG I 166 sh:<br>
>> /var/tmp/one/hooks//ft/clear_work.sh: No such file or directory<br>
>> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: LOG I 166 ExitCode:<br>
>> 127<br>
>> Mon Jun 18 14:30:08 2012 [HKM][D]: Message received: EXECUTE FAILURE<br>
>> 166 clear_work: -<br>
>><br>
>> "/var/tmp/one/hooks//ft/clear_work.sh" script exists on all VM hosting<br>
>> machines. So, I had a try deploy a dummy script onto the OpenNebula<br>
>> frontend machine:<br>
>><br>
>> [ascadm@frontend]% /bin/hostname<br>
>> frontend<br>
>> [ascadm@frontend]% mkdir -p /var/tmp/one/hooks//ft/<br>
>> [ascadm@frontend]% cat > /var/tmp/one/hooks//ft/clear_work.sh<br>
>> #!/bin/sh<br>
>> /bin/hostname<br>
>> ^D<br>
>> [ascadm@frontend]% chmod +x /var/tmp/one/hooks//ft/clear_work.sh<br>
>> [ascadm@frontend]% onevm create ~/work/vms/normal.one<br>
>> ID: 167<br>
>><br>
>> [ascadm@frontend]% less /srv/cloud/one/var/oned.log<br>
>> (snip)<br>
>> Mon Jun 18 14:40:58 2012 [HKM][D]: Message received: LOG I 167 ExitCode: 0<br>
>> Mon Jun 18 14:40:58 2012 [HKM][D]: Message received: EXECUTE SUCCESS<br>
>> 167 clear_work: frontend<br>
>> (snip)<br>
>><br>
>> It seems HOOK script runs on the frontend machine instead of the<br>
>> remote host. Is this correct behavior?<br>
>><br>
>> I am using OpenNebula 3.2.1 on CentOS 5.7(x86_64) now.<br>
>><br>
>> Thanks,<br>
>><br>
>> --<br>
>> Akihiko Ota<br>
>> _______________________________________________<br>
>> Users mailing list<br>
>> <a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
>> <a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
>><br>
</div></div></blockquote></div><br></div>