[one-users] locking plugin

Carlos Martín Sánchez cmartin at opennebula.org
Wed Feb 1 02:59:17 PST 2012


Hi,

Thank you for sharing!

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


On Mon, Jan 30, 2012 at 8:34 AM, Upendra Moturi <upendra.m at hexagrid.com>wrote:

>
> Hello
> I tried to implement locking plugin for opennebula
>
> Here are the scripts i used to implement locking.This plug-in makes sure
> that no two vms use same hard disk.
>
> My assumes
> primary hard disks are present under */images/ folder and name of primary
> hard disk ends with 0 (zero)
> *
> locking.sh*:
> This is where all logic goes in.
> This script is called when vm is created to check for lock.
> If it finds lock,vm goes to failed state else creates a lock with
> metadata about the vm.
> when a vm is deleted or shutdown ,the lock is deleted.
>
> Used tm_ln.sh for verifying and creating lock
> Used hooks to delete the lock.
>
> Here are the changes need to be made for existing code.
>
> Add the following code to *tm_ln.sh*
> *
> *
>
> DST_DIR=`dirname $DST_PATH`
> exec_and_log "/usr/lib/one/tm_commands/nfs/locking.sh checkAndCreate $SRC_PATH $DST_HOST $DST_DIR"
>
>
>
> Add the following code for *oned.conf * to configure hooks
>
> *VM_HOOK = [
>     name      = "hook_running",
>     on        = "running",
>     command   = "/opt/hexaGrid/oneScripts/process_hook.sh",
>     arguments = "$VMID RUNNING $DISK[SOURCE] $NAME",
>     remote    = "no" ]
>
> VM_HOOK = [
>     name      = "hook_finalized",
>     on        = "done",
>     command   = "/opt/hexaGrid/oneScripts/process_hook.sh",
>     arguments = "$VMID DONE $DISK[SOURCE] $NAME",
>     remote    = "no" ]
>
>
> VM_HOOK = [
>     name      = "hook_failed",
>     on        = "failed",
>     command   = "/opt/hexaGrid/oneScripts/process_hook.sh",
>     arguments = "$VMID FAILED $DISK[SOURCE] $NAME",
>     remote    = "no" ]*
>
>
> *process_hook.sh*
>
> *#!/bin/bash
> vmId=$1
> state=$2
> SRC_PATH=$3
> vmName=$4
> echo $state>/tmp/process_hook.log
> if [ "$state" = "DONE" ]; then
>         DST_HOST=`onehost list | grep  on | head -1 | awk '{print $2}'`
>         echo "/usr/lib/one/tm_commands/nfs/locking.sh delete $SRC_PATH
> $DST_HOST $vmId">>/tmp/process_hook.log
>         /usr/lib/one/tm_commands/nfs/locking.sh delete $SRC_PATH $DST_HOST
> $vmId
> fi
>
>
> if [ "$state" = "RUNNING" ]; then
>         DST_HOST=`onevm list | grep $vmName | awk '{print $7}'`
>         echo "/usr/lib/one/tm_commands/nfs/locking.sh modify $SRC_PATH
> $DST_HOST">>/tmp/process_hook.log
>         /usr/lib/one/tm_commands/nfs/locking.sh modify $SRC_PATH $DST_HOST
> fi*
>
> Attaching locking.sh.
>
> --
> Thanks and Regards,
> Upendra.M
>
> *As a leading developer of IT infrastructure software solutions, Hexagrid
> developed the first cloud computing<http://www.hexagrid.com/d/vxdatacenter.html>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. Our Software, Your Cloud.  For more information, visit
> www.hexagrid.com and follow @Hexagrid on Twitter*
>
>
> _______________________________________________
> 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/20120201/c70ee2a3/attachment-0002.htm>


More information about the Users mailing list