<br>Hello<br>I tried to implement locking plugin for opennebula<br><br>Here are the scripts i used to implement locking.This plug-in makes sure that no two vms use same hard disk.<br>
<br>My assumes<br>primary hard disks are present under */images/ folder and name of primary hard disk ends with 0 (zero)<br><b><br>locking.sh</b>: <br>This is where all logic goes in.<br>This script is called when vm is created to check for lock.<br>
If it finds lock,vm goes to failed state else creates a lock with metadata about the vm.<br>when a vm is deleted or shutdown ,the lock is deleted.<br><br>Used tm_ln.sh for verifying and creating lock<br>Used hooks to delete the lock.<br>
<br>Here are the changes need to be made for existing code.<br><br>Add the following code to <b>tm_ln.sh</b><br><font size="1"><i><br></i></font><pre>DST_DIR=`dirname $DST_PATH`<br>exec_and_log "/usr/lib/one/tm_commands/nfs/locking.sh checkAndCreate $SRC_PATH $DST_HOST $DST_DIR"<br>
</pre><br><br>Add the following code for <b>oned.conf </b> to configure hooks<br>
<br><font size="1"><i>VM_HOOK = [<br> name = "hook_running",<br> on = "running",<br> command = "/opt/hexaGrid/oneScripts/process_hook.sh",<br> arguments = "$VMID RUNNING $DISK[SOURCE] $NAME",<br>
remote = "no" ]<br><br>VM_HOOK = [<br> name = "hook_finalized",<br> on = "done",<br> command = "/opt/hexaGrid/oneScripts/process_hook.sh",<br> arguments = "$VMID DONE $DISK[SOURCE] $NAME",<br>
remote = "no" ]<br><br><br>VM_HOOK = [<br> name = "hook_failed",<br> on = "failed",<br> command = "/opt/hexaGrid/oneScripts/process_hook.sh",<br> arguments = "$VMID FAILED $DISK[SOURCE] $NAME",<br>
remote = "no" ]</i></font><br><br><br><u><b>process_hook.sh</b></u><br><br><font size="1"><i>#!/bin/bash<br>vmId=$1<br>state=$2<br>SRC_PATH=$3<br>vmName=$4<br>echo $state>/tmp/process_hook.log<br>if [ "$state" = "DONE" ]; then<br>
DST_HOST=`onehost list | grep on | head -1 | awk '{print $2}'`<br> echo "/usr/lib/one/tm_commands/nfs/locking.sh delete $SRC_PATH $DST_HOST $vmId">>/tmp/process_hook.log<br> /usr/lib/one/tm_commands/nfs/locking.sh delete $SRC_PATH $DST_HOST $vmId<br>
fi<br><br><br>if [ "$state" = "RUNNING" ]; then<br> DST_HOST=`onevm list | grep $vmName | awk '{print $7}'`<br> echo "/usr/lib/one/tm_commands/nfs/locking.sh modify $SRC_PATH $DST_HOST">>/tmp/process_hook.log<br>
/usr/lib/one/tm_commands/nfs/locking.sh modify $SRC_PATH $DST_HOST<br>fi</i></font><br><br>Attaching locking.sh.<br clear="all"><br>-- <br>Thanks and Regards,<br>Upendra.M<br><br><font><i><span style="line-height:115%;font-style:normal;color:black"><span style="line-height:115%;font-style:normal;color:black"><font face="arial,helvetica,sans-serif"><font color="#666666"><i><span style="line-height:115%">As a leading developer of IT infrastructure software solutions, Hexagrid developed the first </span><span style="line-height:115%"><a href="http://www.hexagrid.com/d/vxdatacenter.html" target="_blank"><span>cloud computing</span></a></span><span style="line-height:115%">
platform that directly aligns with the real-world IT delivery models of
both solution providers and enterprises. Hexagrid provides all the
software and support that IT organizations need to successfully build
public, private, or hybrid clouds that fit their specific business and
end-user requirements. Hexagrid cloud solutions truly simplify and
expedite virtual IT management, empowering successful cloud computing
strategies that quickly increase profits by pooling resources,
delivering control, and building value. <b>Our Software, Your Cloud.</b><span> </span>For more information, visit </span><span style="line-height:115%"><a href="http://www.hexagrid.com/" target="_blank"><span>www.hexagrid.com</span></a></span><span style="line-height:115%"> and follow @Hexagrid on Twitter</span></i></font></font></span></span></i></font><br>
<br>