<div>Hi Steven,</div><div><br></div><div>This is an interesting use-case. When we designed the image repository, we had to make a compromise between "expectable behaviour" and "advanced customization usage". I guess this falls into the advanced usage, but OpenNebula is flexible enough to take this challenge.</div>
<div><br></div><div><br></div><div>To automatically save all VM disks that use a certain Image, you can use hooks.</div><div><br></div><div>I would add a new flag to all the relevant images in your system, either having them in the image template, or adding them afterwards [1]:</div>
<div><font face="'courier new', monospace">oneimage addattr <image_id> AUTO_SAVE YES</font></div><div><br></div><div>This will add the flag to the template:</div><div><div><br></div>
<div><font face="'courier new', monospace">$ oneimage show 1</font></div><div><font face="'courier new', monospace">IMAGE INFORMATION </font></div>
<div><font face="'courier new', monospace">[...] </font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">IMAGE TEMPLATE </font></div>
<div><font face="'courier new', monospace"><b>AUTO_SAVE=YES</b></font></div><div><font face="'courier new', monospace">DEV_PREFIX=hd</font></div><div><font face="'courier new', monospace">NAME=test_image</font></div>
<div><font face="'courier new', monospace">PATH=/home/cmartin/trabajo/scratch/steven/disk.img</font></div><div><font face="'courier new', monospace">TYPE=OS</font></div>
</div><div><br></div><div>To add a new hook to the system, edit $ONE_LOCATION/etc/oned.conf [2] and add something similar to the following:</div><div><div><br></div><div><font face="'courier new', monospace">VM_HOOK = [</font></div>
<div><font face="'courier new', monospace"> name = "auto_save",</font></div><div><font face="'courier new', monospace"> on = "CREATE",</font></div>
<div><font face="'courier new', monospace"> command = "auto_save.rb",</font></div><div><font face="'courier new', monospace"> arguments = "$VMID" ]</font></div>
</div><div><br></div><div>This will execute a new script, placed in $ONE_LOCATION/share/hooks/auto_save.rb, every time a new VM is created.</div><div>I suggest you to use ruby, because the ruby OCA API [3] will make it easier.</div>
<div><br></div><div>This script will have to:</div><div>1) Get the complete information for VM <vm_id> from OpenNebula.</div><div>2) For each disk, check if it is using an Image.</div><div>2.1) Get that image's information, and look for the AUTO_SAVE=YES attribute.</div>
<div>If it's present, then issue a onevm saveas operation over that <vm-id> and <disk-id>.</div><div><br></div><div>To be able to identify the disks later, you could include in the new image name the <vm-id>_<disk-id> string.</div>
<div><br></div><div><br></div><div>This way, files will be all managed by OpenNebula in the repository. If you are doing this for back-up purposes, and you won't actually instantiate a VM using this saved images, you can always move that files away from the repository and then delete the images.</div>
<div><br></div><div><br></div><div>This is the easiest and "elegant" way I see to do this, but any other opinions are welcome.</div><div><br></div><div>I'd also like to ask the community if more people feel this should be supported out of the box by OpenNebula. If so, we could start a discussion to determine the specific features or requirements this would imply.</div>
<div><br></div><div><br></div><div>Best regards,</div><div>Carlos.</div><div><br></div>[1] <a href="http://opennebula.org/doc/2.0/cli/oneimage.html" target="_blank">http://opennebula.org/doc/2.0/cli/oneimage.html</a><div>
[2] <a href="http://opennebula.org/documentation:rel2.0:oned_conf#hook_system" target="_blank">http://opennebula.org/documentation:rel2.0:oned_conf#hook_system</a></div><div>[3] <a href="http://opennebula.org/documentation:rel2.0:ruby" target="_blank">http://opennebula.org/documentation:rel2.0:ruby</a></div>
<div><br clear="all">Carlos Martín, Cloud Technology Engineer/Researcher<br>DSA Research Group: web <a href="http://dsa-research.org" target="_blank">http://dsa-research.org</a> and blog <a href="http://blog.dsa-research.org" target="_blank">http://blog.dsa-research.org</a><br>
OpenNebula Open Source Toolkit for Cloud Computing: <a href="http://www.OpenNebula.org" target="_blank">http://www.OpenNebula.org</a><br>
<br><br><div class="gmail_quote">On 30 November 2010 21:56, Steven Timm <span dir="ltr"><<a href="mailto:timm@fnal.gov" target="_blank">timm@fnal.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In<br>
<a href="http://www.opennebula.org/documentation:rel2.0:img_guide" target="_blank">http://www.opennebula.org/documentation:rel2.0:img_guide</a><br>
<br>
it says<br>
<br>
"When images are published they are always cloned, and persistent images are never cloned. Therefore, an image cannot be public and persistent at the same time. To manage a public image that won't be cloned, unpublish it first and make it persistent. "<br>
<br>
I have stored a 10GB OS image in the repository<br>
and made it public<br>
<br>
-bash-3.2$ oneimage show 8<br>
IMAGE INFORMATION<br>
ID : 8<br>
NAME : new-2.6.18-194.26.1.img<br>
TYPE : OS<br>
REGISTER TIME : 11/29 14:15:13<br>
PUBLIC : Yes<br>
PERSISTENT : No<br>
SOURCE : /var/lib/one/image-repo/920301ec2fcc29f9c621c3ebe2a8f5ac6b27fca6<br>
STATE : used<br>
RUNNING_VMS : 2<br>
<br>
IMAGE TEMPLATE<br>
DEV_PREFIX=vd<br>
NAME=new-2.6.18-194.26.1.img<br>
-bash-3.2$<br>
<br>
<br>
I would like to have this available as a template image for<br>
many users to be able to use.<br>
I have successfully been able to have 2 users<br>
use it as part of a VM with the following syntax<br>
<br>
DISK = [ image = "new-2.6.18-194.26.1.img" ]<br>
<br>
<br>
However, I find that this automatically implies a<br>
SAVE=NO once the VM is launched, with no way to override it.<br>
>From output of onevm show:<br>
<br>
DISK=[<br>
CLONE=YES,<br>
DISK_ID=0,<br>
IMAGE=new-2.6.18-194.26.1.img,<br>
IMAGE_ID=8,<br>
READONLY=NO,<br>
SAVE=NO,<br>
SOURCE=/var/lib/one/image-repo/920301ec2fcc29f9c621c3ebe2a8f5ac6b27fca6,<br>
TARGET=vda,<br>
TYPE=DISK ]<br>
<br>
<br>
-----------------------------------------<br>
<br>
So is there any way to do the following:<br>
<br>
1) have the VM registered in the repository for all to see<br>
2) be launched public and cloned on launch so it can be used<br>
in multiple VM's at once<br>
3) have the result be saved in an image-specific file when<br>
each VM is shut down, and not back to the repository?<br>
<br>
***I know that if I execute the onevm saveas command I can<br>
get this done on a machine-by-machine basis but would<br>
prefer a way to make it automatic.<br>
---------------------------------------------------------<br>
<br>
The second question is closely related, namely:<br>
Once a public image is declared in the database, is there any way<br>
to actually update the content of that image, such that for instance<br>
Name = "latest kernel template image"<br>
<br>
could be periodically updated with the latest kernel<br>
and all new VM's would pick it up?<br>
<br>
<br>
Thanks<br>
<br>
Steve Timm<br>
<br>
------------------------------------------------------------------<br>
Steven C. Timm, Ph.D (630) 840-8525<br>
<a href="mailto:timm@fnal.gov" target="_blank">timm@fnal.gov</a> <a href="http://home.fnal.gov/~timm/" target="_blank">http://home.fnal.gov/~timm/</a><br>
Fermilab Computing Division, Scientific Computing Facilities,<br>
Grid Facilities Department, FermiGrid Services Group, Assistant Group Leader.<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>
</blockquote></div><br></div>