[Lxm-commits-diff] SF.net SVN: lxm: [3] trunk
Status: Beta
Brought to you by:
outchy
From: <ou...@us...> - 2007-11-06 20:59:54
|
Revision: 3 http://lxm.svn.sourceforge.net/lxm/?rev=3&view=rev Author: outchy Date: 2007-11-06 12:59:52 -0800 (Tue, 06 Nov 2007) Log Message: ----------- project introduction Added Paths: ----------- trunk/INSTALLING trunk/README trunk/bash_scripts/ trunk/bash_scripts/lxmclone trunk/bash_scripts/lxmdelete trunk/bash_scripts/lxmdisplay trunk/bash_scripts/lxmsetboot trunk/bash_scripts/lxmsnapshot trunk/bash_scripts/lxmstart trunk/settings/ trunk/settings/lxm Added: trunk/INSTALLING =================================================================== --- trunk/INSTALLING (rev 0) +++ trunk/INSTALLING 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,40 @@ +****************************************************************************** +* Lightweight Xen Manager (lxm) http://lxm.sourceforge.net * +****************************************************************************** + +Content: + I. Prerequisites + II. Installation guide + + + I. Prerequisites + + The library is based on Xen tools version 3.1 and specialy the "xm" tool, +also knwon as "Xen Manager". + + The low level scripts require recent version of the following standard tools: + - bash shell + - grep + - awk + - dd + - lvm + - cp, mv, cat... + + The console user interface requires the following software: + - python + - ncurses with support for python + + + II. Installation guide + + Note that this software is beta software, make sure you know what you're +doing before executing the following operation. The lxm developpers cannot be +taken for reponsable for any problems happening when installing or executing +lxm. Any bug report is welcome. + + Copy the content of ./bash_scripts to /sbin + Copy the content of ./settings to /etc + Copy the content of ./console_interface to /sbin if you want to install the +console user interface. + + Property changes on: trunk/INSTALLING ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/README =================================================================== --- trunk/README (rev 0) +++ trunk/README 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,61 @@ +****************************************************************************** +* Lighweight Xen Manager (lxm) http://lxm.sourceforge.net/ * +****************************************************************************** + +Content: + +I. Introduction +II. Product details +III. License and installation notes +IV. About + + + I. Introduction + + The lightweight Xen Manager project is an aggregate of low-level bash scripts +to manage DomU execution and a minimalist console interface written in python. +The application is perfectly designed to run on DomO with few dependencies (cf +installation notes below). + + + II. Product details + + This project consists of several bash scripts requiring few dependencies +designed to handle most commonly encountered operations: + - lxmclone: clone resources associated to an existing virtual machine + (virtual disks stored as files, virtual disks stored as + logical volumes) and create a configuration file for this new + virtual machine. + - lxmdelete: delete an existing virtual machine and its associated + resources (virtual disks stored as files, virtual disks stored + as logical volumes). + - lxmdisplay: start a new X server and a vncviewer attached to the specified + virtual machine (which has to previously be launched). + - lxmsetboot: change the boot device of a shutdowned virtual machine. + - lxmsnapshot: take a snapshot of the resources of an existing virtual + machine (virtual disks stored as files are cloned, virtual + disks stored as logical volumes become snapshots - faster) and + create a configuration file for this new machine. + - lxmstart: start a virtual machine designed by its name and launch a vnc + viewer attached to its screen. + + + III. License and installation notes. + + Refers to LICENSE and INSTALLING files in the root of this project archive. + + + IV. About + + This software is being actively developped by me. It's still unstable and +actively developped; you may use it at your own risks. Do not assume that any +feature present will be continued in the future. + + This project was founded on October 2007 by +Florent Ouchet <ou...@us...>; all portions of code are +copyrighted by their respective authors. + + Volunteers are welcome to develop the projects, provides bug fixes and report +issues against lxm. You may contact me at ou...@us... for +further assistance. + Property changes on: trunk/README ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/bash_scripts/lxmclone =================================================================== --- trunk/bash_scripts/lxmclone (rev 0) +++ trunk/bash_scripts/lxmclone 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,283 @@ +#!/bin/bash +# clone an existing virtual machine and all its associated disks + +source /etc/lxm + +if [ -z "$1" ]; then + echo usage: $0 sourcename clonename + exit 1 +fi + +SOURCENAME=$1 +CLONENAME=$2 + +for CONFDIR in $XENCONFPATH; do + if [ -f "$CONFDIR/$SOURCENAME" ]; then + echo found configuration file $CONFDIR/$SOURCENAME + + echo probing disk list for virtual machine $SOURCENAME + DISKLIST=`echo disk | python -i $CONFDIR/$SOURCENAME 2>/dev/null` + + if [ ! "$?" == "0" ]; then + echo error while probing disk list + exit 1 + fi + + echo disk list is "$DISKLIST" + + FILECOPY=`echo $DISKLIST | awk "/\[/ { + sep1 = \"['\\\\\"]\" + sep2 = \",\" + sep3 = \":\" + split (\\\$0, a, sep1) + i = 2 + while (i <= length(a)) { + split (a[i], b, sep2) + if ( b[3] == \"w\" ) { + c = index(b[2], \":cdrom\") + if (c == 0) { + split (b[1], d, sep3) + if ( d[1] == \"file\" ) { + print d[2] + } + } + } + i++ + i++ + } + }"` + + LVCOPY=`echo $DISKLIST | awk "/\[/ { + sep1 = \"['\\\\\"]\" + sep2 = \",\" + sep3 = \":\" + split(\\\$0, a, sep1) + i = 2 + while (i <= length(a)) { + split (a[i], b, sep2) + if ( b[3] == \"w\" ) { + c = index(b[2], \":cdrom\") + if (c == 0) { + split (b[1], d, sep3) + if ( d[1] == \"phy\" ) { + print d[2] + } + } + } + i++ + i++ + } + }"` + + STATUS=0 + if [ ! -z "$LVCOPY" ]; then + echo checking logical volumes to be copied + for LV in $LVCOPY ; do + echo checking logical volume: $LV + lvdisplay $LV > /dev/null + if [ ! "$?" == "0" ]; then + STATUS=1 + echo volume $LV is not a logical volume, unable to clone it + fi + done + fi + + if [ $STATUS == "1" ]; then + echo fatal error + exit 1 + fi + + STATUS=0 + if [ ! -z "$FILECOPY" ]; then + for FILE in $FILECOPY ; do + # converting file name + NEWFILE=`echo "$FILE" | awk " // { + sep1 = \"/\" + split (\\\$0, a, sep1) + b = length(a) + c = a[b] + if ( c == \"$SOURCENAME\" ) { + c = \"$CLONENAME\" + } else { + c = (c \"_$CLONENAME\") + } + b-- + while ( b >= 1 ) { + c = (a[b] \"/\" c) + b-- + } + print c + }"` + if [ ! "$?" == "0" ]; then + echo failed to convert file name for file $FILE + exit 1 + fi + echo file $FILE will be cloned to $NEWFILE, this may take a while... + + cp $FILE $NEWFILE + if [ "$?" == "0" ]; then + echo file $FILE successfully cloned to $NEWFILE + else + echo failed to clone file $FILE to $NEWFILE + exit 1 + fi + STATUS=1 + done + fi + + if [ ! -z "$LVCOPY" ]; then + for LV in $LVCOPY ; do + LVDETAIL=`lvdisplay $LV` + if [ ! "$?" == "0" ]; then + echo failed to get details about logical volume $LV + exit 1 + fi + # extracting volume group name + VGNAME=`echo "$LVDETAIL" | awk " /VG Name/ { + split (\\\$0, a) + print a[length(a)] + }"` + if [ -z "$VGNAME" -o ! "$?" == "0" ]; then + echo failed to extract volume group name of logical volume $LV + exit 1 + fi + # extracting logical volume size + LVSIZE=`echo "$LVDETAIL" | awk " /LV Size/ { + split (\\\$0, a) + b = length(a) + split (a[b], c, \"\") + print (a[b-1] c[1]) + }"` + if [ -z "$LVSIZE" -o ! "$?" == "0" ]; then + echo failed to extract size of logical volume $LV + exit 1 + fi + # converting logical volume name + NEWLV=`echo "$LV" | awk " // { + sep1 = \"/\" + split (\\\$0, a, sep1) + b = a[length(a)] + if ( b == \"$SOURCENAME\" ) { + b = \"$CLONENAME\" + } else { + b = ( b \"_$CLONENAME\" ) + } + print b + }"` + if [ -z "$NEWLV" -o ! "$?" == "0" ]; then + echo failed to convert volume name of logical volume $LV + exit 1 + fi + # converting logical volume full name + FULLNAMENEWLV=`echo "$LV" | awk " // { + sep1 = \"/\" + split (\\\$0, a, sep1) + b = length(a) + c = a[b] + if ( c == \"$SOURCENAME\" ) { + c = \"$CLONENAME\" + } else { + c = ( c \"_$CLONENAME\" ) + } + b-- + while ( b >= 1) { + c = (a[b] sep1 c) + b-- + } + print c + }"` + if [ -z "$FULLNAMENEWLV" -o ! "$?" == "0" ]; then + echo failed to convert full name of logical volume $LV + exit 1 + fi + echo logical volume $LV will be cloned to $NEWLV in volume group $VGNAME with size $LVSIZE, full name is $FULLNAMENEWLV + + lvcreate --size $LVSIZE --name $NEWLV $VGNAME + if [ ! "$?" == "0" ]; then + echo failed to create logical volume $NEWLV + exit 1 + fi + + echo copying logical volume content, this may take a while... + cat $LV > $FULLNAMENEWLV + if [ "$?" == "0" ]; then + echo logical volume $LV successfully cloned to $NEWLV + else + echo failed to clone logical volume $LV to $NEWLV + exit 1 + fi + STATUS=1 + done + fi + + echo creating configuration file $CONFDIR/$CLONENAME + cat $CONFDIR/$SOURCENAME | awk " // { + a = index(\$0, \"name\") + b = index(\$0, \"disk\") + sep1 = \"['\\\"]\" + sep2 = \",\" + sep3 = \"/\" + if ( a == 1 ) { + split(\$0, c, sep1) + d = length(c) + e = (c[1] \"\\\"\" \"$CLONENAME\" ) + f = 3 + while ( f <= d ) { + e = ( e \"\\\"\" c[f] ) + f++ + } + print e + } else if ( b == 1 ) { + split(\$0, g, sep1) + h = length(g) + i = g[1] + j = 2 + k = 0 + while ( j <= h ) { + if (k == 0) { + k = index(g[j], \"]\") + } + if ((k == 0) && ((j % 2) == 0)) { + split(g[j], l, sep2) + m = index(l[2], \":cdrom\") + if ((m == 0) && (l[3] == \"w\")) { + split (l[1], n, sep3) + o = length(n) + p = n[o] + if ( p == \"$SOURCENAME\" ) { + p = \"$CLONENAME\" + } else { + p = ( p \"_$CLONENAME\" ) + } + o-- + while ( o >= 1) { + p = ( n[o] sep3 p ) + o-- + } + i = ( i \"'\" p sep2 l[2] sep2 l[3] ) + } else { + i = ( i \"'\" g[j] ) + } + } else { + i = ( i \"'\" g[j] ) + } + j++ + } + print i + } else { + print \$0 + } + }" > $CONFDIR/$CLONENAME + if [ "$?" == "0" ]; then + echo configuration file $CONFDIR/$CLONENAME successfully created + else + echo failed to create configuration file $CONFDIR/$CLONENAME + fi + + exit 0 + fi +done + +echo failed to find a configuration file for virtual machine $SOURCENAME +exit 1 + Property changes on: trunk/bash_scripts/lxmclone ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: trunk/bash_scripts/lxmdelete =================================================================== --- trunk/bash_scripts/lxmdelete (rev 0) +++ trunk/bash_scripts/lxmdelete 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,135 @@ +#!/bin/bash +# delete an existing virtual machine and all its associated disks + +source /etc/lxm + +if [ -z "$1" ]; then + echo usage: $0 name [ FORCE ] + exit 1 +fi + +VMNAME=$1 + +for CONFDIR in $XENCONFPATH; do + if [ -f "$CONFDIR/$VMNAME" ]; then + echo found configuration file $CONFDIR/$VMNAME + + echo probing disk list for virtual machine $VMNAME + DISKLIST=`echo disk | python -i $CONFDIR/$VMNAME 2>/dev/null` + + if [ ! "$?" == "0" ]; then + echo error while probing disk list + exit 1 + fi + + echo disk list is "$DISKLIST" + + FILEREMOVE=`echo $DISKLIST | awk "/\[/ { + sep1 = \"['\\\\\"]\" + sep2 = \",\" + sep3 = \":\" + split (\\\$0, a, sep1) + i = 2 + while (i <= length(a)) { + split (a[i], b, sep2) + if ( b[3] == \"w\" ) { + c = index(b[2], \":cdrom\") + if (c == 0) { + split (b[1], d, sep3) + if ( d[1] == \"file\" ) { + print d[2] + } + } + } + i++ + i++ + } + }"` + + LVREMOVE=`echo $DISKLIST | awk "/\[/ { + sep1 = \"['\\\\\"]\" + sep2 = \",\" + sep3 = \":\" + split(\\\$0, a, sep1) + i = 2 + while (i <= length(a)) { + split (a[i], b, sep2) + if ( b[3] == \"w\" ) { + c = index(b[2], \":cdrom\") + if (c == 0) { + split (b[1], d, sep3) + if ( d[1] == \"phy\" ) { + print d[2] + } + } + } + i++ + i++ + } + }"` + + STATUS=0 + + if [ ! -z "$FILEREMOVE" ]; then + for FILE in $FILEREMOVE ; do + echo the following volume file will be deleted: $FILE + if [ "$2" == "FORCE" ]; then + rm -f $FILE + else + rm -i $FILE + fi + if [ "$?" == "0" ]; then + echo file $FILE successfully deleted + else + echo failed to delete file $FILE + exit 1 + fi + STATUS=1 + done + fi + if [ ! -z "$LVREMOVE" ]; then + for LV in $LVREMOVE ; do + echo the following logical volume will be deleted: $LV + lvdisplay $LV > /dev/null + if [ "$?" == "0" ]; then + if [ "$2" == "FORCE" ]; then + lvremove -f $LV + else + lvremove $LV + fi + if [ "$?" == "0" ]; then + echo logical volume $LV successfully removed + else + echo failed to remove logical volume $LV + exit 1 + fi + else + echo $LV is not a virtual volume, skipped + fi + done + fi + + if [ STATUS == "0" ]; then + echo nothing to do + fi + + echo removing configuration file $CONFDIR/$VMNAME + if [ "$2" == "FORCE" ]; then + rm -f $CONFDIR/$VMNAME + else + rm -i $CONFDIR/$VMNAME + fi + if [ "$?" == "0" ]; then + echo configuration file $CONFDIR/$VMNAME successfully removed + else + echo failed to remove configuration file $CONFDIR/$VMNAME + exit 1 + fi + + exit 0 + fi +done + +echo failed to find a configuration file for virtual machine $VMNAME +exit 1 + Property changes on: trunk/bash_scripts/lxmdelete ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: trunk/bash_scripts/lxmdisplay =================================================================== --- trunk/bash_scripts/lxmdisplay (rev 0) +++ trunk/bash_scripts/lxmdisplay 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,72 @@ +#!/bin/bash +# launch a virtual machine and its associated VNC client on a new X client + +source /etc/lxm + +if [ -z "$1" ]; then + echo Usage $0 vm-name + exit 1 +fi + +VMNAME=$1 + +STATUS=0 +MAXLOOP=10 +DISPLAYID=0 + +while [ "$STATUS" == 0 ]; do + if [ ! -f "$XLOCKDIR/.X$DISPLAYID-lock" ]; then + echo using display :$DISPLAYID + + echo probing vnc listen port number for virtual machine $VMNAME + PORTNUMBER=`xm list --long $VMNAME | awk "/location 0.0.0.0:/ { + colon=\":\" + rightpar=\")\" + split (\\\$0, a, colon) + split (a[2], b, rightpar) + print b[1] + }"` + + if [ -z "$PORTNUMBER" -o ! "$?" == "0" ]; then + echo error probing vnc listen port number, is virtual machine $VMNAME launched? + exit 1 + fi + + echo VNC server is listening on port $PORTNUMBER + + echo launching X client + X :$DISPLAYID & + if [ ! "$?" == "0" ]; then + echo error launching X client on display :$DISPLAYID + exit 1 + fi + + echo sleeping 2 seconds... + sleep 2 + + echo launching vnc viewer + env DISPLAY=":$DISPLAYID" vncviewer -MenuKey=F12 -Shared=1 -FullScreen=1 -SendClipboard=0 -AcceptClipboard=0 -FullColor=1 -DotWhenNoCursor=0 -UseLocalCursor=0 127.0.0.1:$PORTNUMBER + + if [ ! "$?" == "0" ]; then + echo error launching vncviewer + fi + + echo killing X client + XPID=`cat $XLOCKDIR/.X$DISPLAYID-lock` + echo X client PID is $XPID + kill -s SIGTERM $XPID + if [ "$?" == "0" ]; then + echo X client successfully killed + else + echo failed to kill X client + fi + + STATUS=1 + fi + + DISPLAYID=`expr $DISPLAYID + 1` + if [ "$DISPLAYID" == "$MAXLOOP" ]; then + STATUS=1 + fi +done + Property changes on: trunk/bash_scripts/lxmdisplay ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: trunk/bash_scripts/lxmsetboot =================================================================== --- trunk/bash_scripts/lxmsetboot (rev 0) +++ trunk/bash_scripts/lxmsetboot 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,49 @@ +#!/bin/bash +# set boot device for a virtual machine + +source /etc/lxm + +if [ -z "$1" -o -z "$2" ]; then + echo Usage $0 vm-name [a|c|d] + exit 1 +fi + +VMNAME=$1 +BOOTDEVICE=$2 + +for CONFDIR in $XENCONFPATH; do + if [ -f "$CONFDIR/$VMNAME" ]; then + echo modifying virtual machine $CONFDIR/$VMNAME + + cat $CONFDIR/$VMNAME | awk " // { + a = index(\$0, \"boot\") + sep1 = \"['\\\"]\" + if ( a == 1 ) { + split (\$0, b, sep1) + c = length(b) + d = ( b[1] \"\\\"\" \"$BOOTDEVICE\" ) + e = 3 + while ( e <= c) { + d = ( d \"\\\"\" b[e] ) + e++ + } + print d + } else { + print \$0 + } + }" > $CONFDIR/$VMNAME.new + + if [ "$?" == "0" ]; then + mv $CONFDIR/$VMNAME.new $CONFDIR/$VMNAME + echo success + exit 0 + else + echo failed to modify virtual machine script $CONFDIR/$VMNAME + exit 1 + fi + fi +done + +echo virtual machine $VMNAME not found in $XENCONFPATH +exit 1 + Property changes on: trunk/bash_scripts/lxmsetboot ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: trunk/bash_scripts/lxmsnapshot =================================================================== --- trunk/bash_scripts/lxmsnapshot (rev 0) +++ trunk/bash_scripts/lxmsnapshot 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,271 @@ +#!/bin/bash +# take a snapshot of an existing virtual machine and all its associated disks +# taking snapshot of logical volumes over LVM is handled +# vdb as files are copied + +source /etc/lxm + +if [ -z "$1" ]; then + echo usage: $0 sourcename snapshotname + exit 1 +fi + +SOURCENAME=$1 +SNAPSHOTNAME=$2 + +for CONFDIR in $XENCONFPATH; do + if [ -f "$CONFDIR/$SOURCENAME" ]; then + echo found configuration file $CONFDIR/$SOURCENAME + + echo probing disk list for virtual machine $SOURCENAME + DISKLIST=`echo disk | python -i $CONFDIR/$SOURCENAME 2>/dev/null` + + if [ ! "$?" == "0" ]; then + echo error while probing disk list + exit 1 + fi + + echo disk list is "$DISKLIST" + + FILECOPY=`echo $DISKLIST | awk "/\[/ { + sep1 = \"['\\\\\"]\" + sep2 = \",\" + sep3 = \":\" + split (\\\$0, a, sep1) + i = 2 + while (i <= length(a)) { + split (a[i], b, sep2) + if ( b[3] == \"w\" ) { + c = index(b[2], \":cdrom\") + if (c == 0) { + split (b[1], d, sep3) + if ( d[1] == \"file\" ) { + print d[2] + } + } + } + i++ + i++ + } + }"` + + LVSNAPSHOT=`echo $DISKLIST | awk "/\[/ { + sep1 = \"['\\\\\"]\" + sep2 = \",\" + sep3 = \":\" + split(\\\$0, a, sep1) + i = 2 + while (i <= length(a)) { + split (a[i], b, sep2) + if ( b[3] == \"w\" ) { + c = index(b[2], \":cdrom\") + if (c == 0) { + split (b[1], d, sep3) + if ( d[1] == \"phy\" ) { + print d[2] + } + } + } + i++ + i++ + } + }"` + + STATUS=0 + if [ ! -z "$LVSNAPSHOT" ]; then + echo checking logical volumes to be created + for LV in $LVSNAPSHOT ; do + echo checking logical volume: $LV + LVDETAIL=`lvdisplay $LV` + if [ "$?" == "0" ]; then + ISSNAPSHOT=`echo "$LVDETAIL" | awk " /LV snapshot status/ { + a = index(\\\$0, \"destination\") + if (a > 0) { + print \"1\" + } + }"` + if [ ! "$?" == "0" ]; then + echo failed to check if volume $LV is a snapshot + exit 1 + fi + if [ ! -z "$ISSNAPSHOT" ]; then + STATUS=1 + echo volume $LV is already a snapshot of an other volume + fi + else + STATUS=1 + echo volume $LV is not a logical volume, unable to take a snapshot + fi + done + fi + + if [ $STATUS == "1" ]; then + echo fatal error + exit 1 + fi + + STATUS=0 + if [ ! -z "$FILECOPY" ]; then + for FILE in $FILECOPY ; do + # converting file name + NEWFILE=`echo "$FILE" | awk " // { + sep1 = \"/\" + split (\\\$0, a, sep1) + b = length(a) + c = a[b] + if ( c == \"$SOURCENAME\" ) { + c = \"$SNAPSHOTNAME\" + } else { + c = (c \"_$SNAPSHOTNAME\") + } + b-- + while ( b >= 1 ) { + c = (a[b] \"/\" c) + b-- + } + print c + }"` + if [ ! "$?" == "0" ]; then + echo failed to convert file name for file $FILE + exit 1 + fi + echo file $FILE will be cloned to $NEWFILE + + cp $FILE $NEWFILE + if [ "$?" == "0" ]; then + echo file $FILE successfully cloned to $NEWFILE + else + echo failed to clone file $FILE to $NEWFILE + exit 1 + fi + STATUS=1 + done + fi + + if [ ! -z "$LVSNAPSHOT" ]; then + for LV in $LVSNAPSHOT ; do + LVDETAIL=`lvdisplay $LV` + if [ ! "$?" == "0" ]; then + echo failed to get details about logical volume $LV + exit 1 + fi + # extracting volume group name + VGNAME=`echo "$LVDETAIL" | awk " /VG Name/ { + split (\\\$0, a) + print a[length(a)] + }"` + if [ -z "$VGNAME" -o ! "$?" == "0" ]; then + echo failed to extract volume group name of logical volume $LV + exit 1 + fi + # extracting logical volume size + LVSIZE=`echo "$LVDETAIL" | awk " /LV Size/ { + split (\\\$0, a) + b = length(a) + split (a[b], c, \"\") + print (a[b-1] c[1]) + }"` + if [ -z "$LVSIZE" -o ! "$?" == "0" ]; then + echo failed to extract size of logical volume $LV + exit 1 + fi + # converting logical volume name + NEWLV=`echo "$LV" | awk " // { + sep1 = \"/\" + split (\\\$0, a, sep1) + b = a[length(a)] + if ( b == \"$SOURCENAME\" ) { + b = \"$SNAPSHOTNAME\" + } else { + b = ( b \"_$SNAPSHOTNAME\" ) + } + print b + }"` + if [ -z "$NEWLV" -o ! "$?" == "0" ]; then + echo failed to convert volume name of logical volume $LV + exit 1 + fi + echo logical volume $LV will source a snapshot named $NEWLV in volume group $VGNAME with size $LVSIZE + + lvcreate --size $LVSIZE --snapshot --name $NEWLV $LV + if [ "$?" == "0" ]; then + echo logical volume $NEWLV successfully created + else + echo failed to create logical volume $NEWLV + exit 1 + fi + STATUS=1 + done + fi + + echo creating configuration file $CONFDIR/$SNAPSHOTNAME + cat $CONFDIR/$SOURCENAME | awk " // { + a = index(\$0, \"name\") + b = index(\$0, \"disk\") + sep1 = \"['\\\"]\" + sep2 = \",\" + sep3 = \"/\" + if ( a == 1 ) { + split(\$0, c, sep1) + d = length(c) + e = (c[1] \"\\\"\" \"$SNAPSHOTNAME\" ) + f = 3 + while ( f <= d ) { + e = ( e \"\\\"\" c[f] ) + f++ + } + print e + } else if ( b == 1 ) { + split(\$0, g, sep1) + h = length(g) + i = g[1] + j = 2 + k = 0 + while ( j <= h ) { + if (k == 0) { + k = index(g[j], \"]\") + } + if ((k == 0) && ((j % 2) == 0)) { + split(g[j], l, sep2) + m = index(l[2], \":cdrom\") + if ((m == 0) && (l[3] == \"w\")) { + split (l[1], n, sep3) + o = length(n) + p = n[o] + if ( p == \"$SOURCENAME\" ) { + p = \"$SNAPSHOTNAME\" + } else { + p = ( p \"_$SNAPSHOTNAME\" ) + } + o-- + while ( o >= 1) { + p = ( n[o] sep3 p ) + o-- + } + i = ( i \"'\" p sep2 l[2] sep2 l[3] ) + } else { + i = ( i \"'\" g[j] ) + } + } else { + i = ( i \"'\" g[j] ) + } + j++ + } + print i + } else { + print \$0 + } + }" > $CONFDIR/$SNAPSHOTNAME + if [ "$?" == "0" ]; then + echo configuration file $CONFDIR/$SNAPSHOTNAME successfully created + else + echo failed to create configuration file $CONFDIR/$SNAPSHOTNAME + fi + + exit 0 + fi +done + +echo failed to find a configuration file for virtual machine $SOURCENAME +exit 1 + Property changes on: trunk/bash_scripts/lxmsnapshot ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: trunk/bash_scripts/lxmstart =================================================================== --- trunk/bash_scripts/lxmstart (rev 0) +++ trunk/bash_scripts/lxmstart 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,33 @@ +#!/bin/bash +# launch a virtual machine and call lxmdisplay + +source /etc/lxm + +if [ -z "$1" ]; then + echo Usage $0 vm-name + exit 1 +fi + +VMNAME=$1 + +for CONFDIR in $XENCONFPATH; do + if [ -f "$CONFDIR/$VMNAME" ]; then + echo launching virtual machine $CONFDIR/$VMNAME + xm create $CONFDIR/$VMNAME + if [ ! "$?" = "0" ]; then + echo error while launching virtual machine $VMNAME + exit 1 + fi + + # auto execute viewer + if [ ! $2 = "NODISPLAY" ]; then + lxmdisplay $VMNAME + fi + + exit 0 + fi +done + +echo virtual machine $VMNAME not found in $XENCONFPATH +exit 1 + Property changes on: trunk/bash_scripts/lxmstart ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: trunk/settings/lxm =================================================================== --- trunk/settings/lxm (rev 0) +++ trunk/settings/lxm 2007-11-06 20:59:52 UTC (rev 3) @@ -0,0 +1,10 @@ +# +# configuration file for light xen manager +# + +# virtual machine configuration paths + +XENCONFPATH="/etc/xen/conf" + +# X lock dir +XLOCKDIR="/tmp" Property changes on: trunk/settings/lxm ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |