[one-users] customizing tm_*.sh scripts for OpenVZ hypervisor [was "$SCRIPTS_REMOTE_DIR in tm_*.sh scripts"]

knawnd at gmail.com knawnd at gmail.com
Sat Jun 11 07:30:15 PDT 2011


Tino Vazquez wrote on 09/06/11 13:52:
> Hi Nikolai,
Hi Tino,

I am not sure any longer that functionality I was going to implement can 
be done in tm_clone.sh script. Apart from possibility to be aware of 
$SCRIPT_REMOTE_DIR value the tm_clone.sh script needs to "know" the name 
of OS image to be used for VM deployment and that is a problem.
Let me briefly explain what I mean.
To create new VM on OpenVZ host there are two options:
1) one can specify using 'ostemplate' option the name of already 
existing so called OS template which has to be available in predefined 
dir set in TEMPLATE variable of OpenVZ global config file (by default it 
is /etc/vz/vz.conf). Normally TEMPLATE=/vz/template and OS template has 
to be available in $TEMPLATE/cache. There is no way to specify the 
absolute path to OS template (like 
--ostemplate=$VM_DIR/<$VMID>/images/disk.0 replacing the variables 
$VM_DIR and $VMID by their values e.g. 
--ostemplate=/vz/one/vm/55/images/disk.0). One of the example of a 
proper command could be as
$ vzctl create 101 --ostemplate centos-5-x86
and OpenVZ expects the existence of the 
/vz/template/cache/centos-5-x86.tar.gz file with corresponding name.
2) one can skip --ostemplate option. Then OpenVZ will use the default OS 
template name defined in $DEF_OSTEMPLATE variable in /etc/vz/vz.conf. 
But that way is not  very flexible (althrough it can be followed if all 
VMs are going to be deployed using only single OS template and thus its 
name can be redefined ones during initial OpenVZ host configuration).
To follow the first option I would implement the logic as described below:
1) get the name of OS template specified in config file for given VM;
2) check if OS template with same name already exists in $TEMPLATE/cache 
dir. If it does then rename it, create a symlink (or one can copy it) 
from $VM_DIR/$VMID/images/disk.0 to $TEMPLATE/cache;
3) create VM;
4) remove symlinked OS template images from $TEMPLATE/cache dir.

But tm_clone.sh script is executed before 
$SCRIPT_REMOTE_DIR/vmm/ovz/deploy script and hense the VM config file is 
not yet available to retrieve OS template name. Moreover the fourth 
step (OS template deletion from $TEMPLATE/cach dir) needs to be executed 
after VM creation. So all the steps described above needs to be 
implemented in $SCRIPT_REMOTE_DIR/vmm/ovz/deploy script although such 
approach in some sense mixes functionality which each script was 
initially intended for (as far as I understand it).

Regards,
Nikolay.



More information about the Users mailing list