[Lxm-commits-diff] SF.net SVN: lxm: [4] trunk
Status: Beta
Brought to you by:
outchy
|
From: <ou...@us...> - 2007-11-09 20:07:51
|
Revision: 4
http://lxm.svn.sourceforge.net/lxm/?rev=4&view=rev
Author: outchy
Date: 2007-11-09 12:07:47 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
style cleaning of echo
clone now use dd to speed up copies of logical volumes
Modified Paths:
--------------
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/lxm
Modified: trunk/bash_scripts/lxmclone
===================================================================
--- trunk/bash_scripts/lxmclone 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/bash_scripts/lxmclone 2007-11-09 20:07:47 UTC (rev 4)
@@ -4,7 +4,7 @@
source /etc/lxm
if [ -z "$1" ]; then
- echo usage: $0 sourcename clonename
+ echo "usage: $0 sourcename clonename"
exit 1
fi
@@ -13,19 +13,19 @@
for CONFDIR in $XENCONFPATH; do
if [ -f "$CONFDIR/$SOURCENAME" ]; then
- echo found configuration file $CONFDIR/$SOURCENAME
+ echo "found configuration file $CONFDIR/$SOURCENAME"
echo probing disk list for virtual machine $SOURCENAME
- DISKLIST=`echo disk | python -i $CONFDIR/$SOURCENAME 2>/dev/null`
+ DISKLIST=`echo "disk" | python -i $CONFDIR/$SOURCENAME 2>/dev/null`
if [ ! "$?" == "0" ]; then
- echo error while probing disk list
+ echo "error while probing disk list"
exit 1
fi
- echo disk list is "$DISKLIST"
+ echo "disk list is $DISKLIST"
- FILECOPY=`echo $DISKLIST | awk "/\[/ {
+ FILECOPY=`echo "$DISKLIST" | awk "/\[/ {
sep1 = \"['\\\\\"]\"
sep2 = \",\"
sep3 = \":\"
@@ -47,7 +47,7 @@
}
}"`
- LVCOPY=`echo $DISKLIST | awk "/\[/ {
+ LVCOPY=`echo "$DISKLIST" | awk "/\[/ {
sep1 = \"['\\\\\"]\"
sep2 = \",\"
sep3 = \":\"
@@ -71,19 +71,19 @@
STATUS=0
if [ ! -z "$LVCOPY" ]; then
- echo checking logical volumes to be copied
+ echo "checking logical volumes to be copied"
for LV in $LVCOPY ; do
- echo checking logical volume: $LV
+ 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
+ echo "volume $LV is not a logical volume, unable to clone it"
fi
done
fi
- if [ $STATUS == "1" ]; then
- echo fatal error
+ if [ "$STATUS" == "1" ]; then
+ echo "fatal error"
exit 1
fi
@@ -109,16 +109,16 @@
print c
}"`
if [ ! "$?" == "0" ]; then
- echo failed to convert file name for file $FILE
+ 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...
+ 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
+ echo "file $FILE successfully cloned to $NEWFILE"
else
- echo failed to clone file $FILE to $NEWFILE
+ echo "failed to clone file $FILE to $NEWFILE"
exit 1
fi
STATUS=1
@@ -129,7 +129,7 @@
for LV in $LVCOPY ; do
LVDETAIL=`lvdisplay $LV`
if [ ! "$?" == "0" ]; then
- echo failed to get details about logical volume $LV
+ echo "failed to get details about logical volume $LV"
exit 1
fi
# extracting volume group name
@@ -138,7 +138,7 @@
print a[length(a)]
}"`
if [ -z "$VGNAME" -o ! "$?" == "0" ]; then
- echo failed to extract volume group name of logical volume $LV
+ echo "failed to extract volume group name of logical volume $LV"
exit 1
fi
# extracting logical volume size
@@ -149,7 +149,7 @@
print (a[b-1] c[1])
}"`
if [ -z "$LVSIZE" -o ! "$?" == "0" ]; then
- echo failed to extract size of logical volume $LV
+ echo "failed to extract size of logical volume $LV"
exit 1
fi
# converting logical volume name
@@ -165,7 +165,7 @@
print b
}"`
if [ -z "$NEWLV" -o ! "$?" == "0" ]; then
- echo failed to convert volume name of logical volume $LV
+ echo "failed to convert volume name of logical volume $LV"
exit 1
fi
# converting logical volume full name
@@ -187,30 +187,30 @@
print c
}"`
if [ -z "$FULLNAMENEWLV" -o ! "$?" == "0" ]; then
- echo failed to convert full name of logical volume $LV
+ 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
+ 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
+ echo "failed to create logical volume $NEWLV"
exit 1
fi
- echo copying logical volume content, this may take a while...
- cat $LV > $FULLNAMENEWLV
+ echo "copying logical volume content, this may take a while..."
+ dd bs=$DDBS if=$LV of=$FULLNAMENEWLV
if [ "$?" == "0" ]; then
- echo logical volume $LV successfully cloned to $NEWLV
+ echo "logical volume $LV successfully cloned to $NEWLV"
else
- echo failed to clone logical volume $LV to $NEWLV
+ echo "failed to clone logical volume $LV to $NEWLV"
exit 1
fi
STATUS=1
done
fi
- echo creating configuration file $CONFDIR/$CLONENAME
+ echo "creating configuration file $CONFDIR/$CLONENAME"
cat $CONFDIR/$SOURCENAME | awk " // {
a = index(\$0, \"name\")
b = index(\$0, \"disk\")
@@ -269,15 +269,15 @@
}
}" > $CONFDIR/$CLONENAME
if [ "$?" == "0" ]; then
- echo configuration file $CONFDIR/$CLONENAME successfully created
+ echo "configuration file $CONFDIR/$CLONENAME successfully created"
else
- echo failed to create configuration file $CONFDIR/$CLONENAME
+ echo "failed to create configuration file $CONFDIR/$CLONENAME"
fi
exit 0
fi
done
-echo failed to find a configuration file for virtual machine $SOURCENAME
+echo "failed to find a configuration file for virtual machine $SOURCENAME"
exit 1
Modified: trunk/bash_scripts/lxmdelete
===================================================================
--- trunk/bash_scripts/lxmdelete 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/bash_scripts/lxmdelete 2007-11-09 20:07:47 UTC (rev 4)
@@ -4,7 +4,7 @@
source /etc/lxm
if [ -z "$1" ]; then
- echo usage: $0 name [ FORCE ]
+ echo "usage: $0 name [ FORCE ]"
exit 1
fi
@@ -12,19 +12,19 @@
for CONFDIR in $XENCONFPATH; do
if [ -f "$CONFDIR/$VMNAME" ]; then
- echo found configuration file $CONFDIR/$VMNAME
+ echo "found configuration file $CONFDIR/$VMNAME"
- echo probing disk list for virtual machine $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
+ echo "error while probing disk list"
exit 1
fi
- echo disk list is "$DISKLIST"
+ echo "disk list is $DISKLIST"
- FILEREMOVE=`echo $DISKLIST | awk "/\[/ {
+ FILEREMOVE=`echo "$DISKLIST" | awk "/\[/ {
sep1 = \"['\\\\\"]\"
sep2 = \",\"
sep3 = \":\"
@@ -46,7 +46,7 @@
}
}"`
- LVREMOVE=`echo $DISKLIST | awk "/\[/ {
+ LVREMOVE=`echo "$DISKLIST" | awk "/\[/ {
sep1 = \"['\\\\\"]\"
sep2 = \",\"
sep3 = \":\"
@@ -72,16 +72,16 @@
if [ ! -z "$FILEREMOVE" ]; then
for FILE in $FILEREMOVE ; do
- echo the following volume file will be deleted: $FILE
+ 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
+ echo "file $FILE successfully deleted"
else
- echo failed to delete file $FILE
+ echo "failed to delete file $FILE"
exit 1
fi
STATUS=1
@@ -89,7 +89,7 @@
fi
if [ ! -z "$LVREMOVE" ]; then
for LV in $LVREMOVE ; do
- echo the following logical volume will be deleted: $LV
+ echo "the following logical volume will be deleted: $LV"
lvdisplay $LV > /dev/null
if [ "$?" == "0" ]; then
if [ "$2" == "FORCE" ]; then
@@ -98,31 +98,31 @@
lvremove $LV
fi
if [ "$?" == "0" ]; then
- echo logical volume $LV successfully removed
+ echo "logical volume $LV successfully removed"
else
- echo failed to remove logical volume $LV
+ echo "failed to remove logical volume $LV"
exit 1
fi
else
- echo $LV is not a virtual volume, skipped
+ echo "$LV is not a virtual volume, skipped"
fi
done
fi
- if [ STATUS == "0" ]; then
- echo nothing to do
+ if [ "$STATUS" == "0" ]; then
+ echo "nothing to do"
fi
- echo removing configuration file $CONFDIR/$VMNAME
+ 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
+ echo "configuration file $CONFDIR/$VMNAME successfully removed"
else
- echo failed to remove configuration file $CONFDIR/$VMNAME
+ echo "failed to remove configuration file $CONFDIR/$VMNAME"
exit 1
fi
@@ -130,6 +130,6 @@
fi
done
-echo failed to find a configuration file for virtual machine $VMNAME
+echo "failed to find a configuration file for virtual machine $VMNAME"
exit 1
Modified: trunk/bash_scripts/lxmdisplay
===================================================================
--- trunk/bash_scripts/lxmdisplay 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/bash_scripts/lxmdisplay 2007-11-09 20:07:47 UTC (rev 4)
@@ -4,7 +4,7 @@
source /etc/lxm
if [ -z "$1" ]; then
- echo Usage $0 vm-name
+ echo "Usage $0 vm-name"
exit 1
fi
@@ -16,9 +16,9 @@
while [ "$STATUS" == 0 ]; do
if [ ! -f "$XLOCKDIR/.X$DISPLAYID-lock" ]; then
- echo using display :$DISPLAYID
+ echo "using display :$DISPLAYID"
- echo probing vnc listen port number for virtual machine $VMNAME
+ echo "probing vnc listen port number for virtual machine $VMNAME"
PORTNUMBER=`xm list --long $VMNAME | awk "/location 0.0.0.0:/ {
colon=\":\"
rightpar=\")\"
@@ -28,37 +28,37 @@
}"`
if [ -z "$PORTNUMBER" -o ! "$?" == "0" ]; then
- echo error probing vnc listen port number, is virtual machine $VMNAME launched?
+ echo "error probing vnc listen port number, is virtual machine $VMNAME launched?"
exit 1
fi
- echo VNC server is listening on port $PORTNUMBER
+ echo "VNC server is listening on port $PORTNUMBER"
- echo launching X client
+ echo "launching X client"
X :$DISPLAYID &
if [ ! "$?" == "0" ]; then
- echo error launching X client on display :$DISPLAYID
+ echo "error launching X client on display :$DISPLAYID"
exit 1
fi
- echo sleeping 2 seconds...
+ echo "sleeping 2 seconds..."
sleep 2
- echo launching vnc viewer
+ 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
+ echo "error launching vncviewer"
fi
- echo killing X client
+ echo "killing X client"
XPID=`cat $XLOCKDIR/.X$DISPLAYID-lock`
- echo X client PID is $XPID
+ echo "X client PID is $XPID"
kill -s SIGTERM $XPID
if [ "$?" == "0" ]; then
- echo X client successfully killed
+ echo "X client successfully killed"
else
- echo failed to kill X client
+ echo "failed to kill X client"
fi
STATUS=1
Modified: trunk/bash_scripts/lxmsetboot
===================================================================
--- trunk/bash_scripts/lxmsetboot 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/bash_scripts/lxmsetboot 2007-11-09 20:07:47 UTC (rev 4)
@@ -4,7 +4,7 @@
source /etc/lxm
if [ -z "$1" -o -z "$2" ]; then
- echo Usage $0 vm-name [a|c|d]
+ echo "Usage $0 vm-name [a|c|d]"
exit 1
fi
@@ -13,7 +13,7 @@
for CONFDIR in $XENCONFPATH; do
if [ -f "$CONFDIR/$VMNAME" ]; then
- echo modifying virtual machine $CONFDIR/$VMNAME
+ echo "modifying virtual machine $CONFDIR/$VMNAME"
cat $CONFDIR/$VMNAME | awk " // {
a = index(\$0, \"boot\")
@@ -35,15 +35,15 @@
if [ "$?" == "0" ]; then
mv $CONFDIR/$VMNAME.new $CONFDIR/$VMNAME
- echo success
+ echo "success"
exit 0
else
- echo failed to modify virtual machine script $CONFDIR/$VMNAME
+ echo "failed to modify virtual machine script $CONFDIR/$VMNAME"
exit 1
fi
fi
done
-echo virtual machine $VMNAME not found in $XENCONFPATH
+echo "virtual machine $VMNAME not found in $XENCONFPATH"
exit 1
Modified: trunk/bash_scripts/lxmsnapshot
===================================================================
--- trunk/bash_scripts/lxmsnapshot 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/bash_scripts/lxmsnapshot 2007-11-09 20:07:47 UTC (rev 4)
@@ -6,7 +6,7 @@
source /etc/lxm
if [ -z "$1" ]; then
- echo usage: $0 sourcename snapshotname
+ echo "usage: $0 sourcename snapshotname"
exit 1
fi
@@ -15,19 +15,19 @@
for CONFDIR in $XENCONFPATH; do
if [ -f "$CONFDIR/$SOURCENAME" ]; then
- echo found configuration file $CONFDIR/$SOURCENAME
+ echo "found configuration file $CONFDIR/$SOURCENAME"
- echo probing disk list for virtual machine $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
+ echo "error while probing disk list"
exit 1
fi
- echo disk list is "$DISKLIST"
+ echo "disk list is $DISKLIST"
- FILECOPY=`echo $DISKLIST | awk "/\[/ {
+ FILECOPY=`echo "$DISKLIST" | awk "/\[/ {
sep1 = \"['\\\\\"]\"
sep2 = \",\"
sep3 = \":\"
@@ -49,7 +49,7 @@
}
}"`
- LVSNAPSHOT=`echo $DISKLIST | awk "/\[/ {
+ LVSNAPSHOT=`echo "$DISKLIST" | awk "/\[/ {
sep1 = \"['\\\\\"]\"
sep2 = \",\"
sep3 = \":\"
@@ -73,9 +73,9 @@
STATUS=0
if [ ! -z "$LVSNAPSHOT" ]; then
- echo checking logical volumes to be created
+ echo "checking logical volumes to be created"
for LV in $LVSNAPSHOT ; do
- echo checking logical volume: $LV
+ echo "checking logical volume: $LV"
LVDETAIL=`lvdisplay $LV`
if [ "$?" == "0" ]; then
ISSNAPSHOT=`echo "$LVDETAIL" | awk " /LV snapshot status/ {
@@ -85,22 +85,22 @@
}
}"`
if [ ! "$?" == "0" ]; then
- echo failed to check if volume $LV is a snapshot
+ 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
+ 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
+ echo "volume $LV is not a logical volume, unable to take a snapshot"
fi
done
fi
if [ $STATUS == "1" ]; then
- echo fatal error
+ echo "fatal error"
exit 1
fi
@@ -126,16 +126,16 @@
print c
}"`
if [ ! "$?" == "0" ]; then
- echo failed to convert file name for file $FILE
+ echo "failed to convert file name for file $FILE"
exit 1
fi
- echo file $FILE will be cloned to $NEWFILE
+ echo "file $FILE will be cloned to $NEWFILE"
- cp $FILE $NEWFILE
+ cp "$FILE" "$NEWFILE"
if [ "$?" == "0" ]; then
- echo file $FILE successfully cloned to $NEWFILE
+ echo "file $FILE successfully cloned to $NEWFILE"
else
- echo failed to clone file $FILE to $NEWFILE
+ echo "failed to clone file $FILE to $NEWFILE"
exit 1
fi
STATUS=1
@@ -146,7 +146,7 @@
for LV in $LVSNAPSHOT ; do
LVDETAIL=`lvdisplay $LV`
if [ ! "$?" == "0" ]; then
- echo failed to get details about logical volume $LV
+ echo "failed to get details about logical volume $LV"
exit 1
fi
# extracting volume group name
@@ -155,7 +155,7 @@
print a[length(a)]
}"`
if [ -z "$VGNAME" -o ! "$?" == "0" ]; then
- echo failed to extract volume group name of logical volume $LV
+ echo "failed to extract volume group name of logical volume $LV"
exit 1
fi
# extracting logical volume size
@@ -166,7 +166,7 @@
print (a[b-1] c[1])
}"`
if [ -z "$LVSIZE" -o ! "$?" == "0" ]; then
- echo failed to extract size of logical volume $LV
+ echo "failed to extract size of logical volume $LV"
exit 1
fi
# converting logical volume name
@@ -182,23 +182,23 @@
print b
}"`
if [ -z "$NEWLV" -o ! "$?" == "0" ]; then
- echo failed to convert volume name of logical volume $LV
+ 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
+ echo "logical volume $LV will source a snapshot named $NEWLV in volume group $VGNAME with size $LVSIZE"
- lvcreate --size $LVSIZE --snapshot --name $NEWLV $LV
+ lvcreate --size "$LVSIZE" --snapshot --name "$NEWLV" "$LV"
if [ "$?" == "0" ]; then
- echo logical volume $NEWLV successfully created
+ echo "logical volume $NEWLV successfully created"
else
- echo failed to create logical volume $NEWLV
+ echo "failed to create logical volume $NEWLV"
exit 1
fi
STATUS=1
done
fi
- echo creating configuration file $CONFDIR/$SNAPSHOTNAME
+ echo "creating configuration file $CONFDIR/$SNAPSHOTNAME"
cat $CONFDIR/$SOURCENAME | awk " // {
a = index(\$0, \"name\")
b = index(\$0, \"disk\")
@@ -257,15 +257,15 @@
}
}" > $CONFDIR/$SNAPSHOTNAME
if [ "$?" == "0" ]; then
- echo configuration file $CONFDIR/$SNAPSHOTNAME successfully created
+ echo "configuration file $CONFDIR/$SNAPSHOTNAME successfully created"
else
- echo failed to create configuration file $CONFDIR/$SNAPSHOTNAME
+ echo "failed to create configuration file $CONFDIR/$SNAPSHOTNAME"
fi
exit 0
fi
done
-echo failed to find a configuration file for virtual machine $SOURCENAME
+echo "failed to find a configuration file for virtual machine $SOURCENAME"
exit 1
Modified: trunk/bash_scripts/lxmstart
===================================================================
--- trunk/bash_scripts/lxmstart 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/bash_scripts/lxmstart 2007-11-09 20:07:47 UTC (rev 4)
@@ -4,7 +4,7 @@
source /etc/lxm
if [ -z "$1" ]; then
- echo Usage $0 vm-name
+ echo "Usage $0 vm-name"
exit 1
fi
@@ -12,15 +12,15 @@
for CONFDIR in $XENCONFPATH; do
if [ -f "$CONFDIR/$VMNAME" ]; then
- echo launching virtual machine $CONFDIR/$VMNAME
+ echo "launching virtual machine $CONFDIR/$VMNAME"
xm create $CONFDIR/$VMNAME
if [ ! "$?" = "0" ]; then
- echo error while launching virtual machine $VMNAME
+ echo "error while launching virtual machine $VMNAME"
exit 1
fi
# auto execute viewer
- if [ ! $2 = "NODISPLAY" ]; then
+ if [ ! "$2" = "NODISPLAY" ]; then
lxmdisplay $VMNAME
fi
@@ -28,6 +28,6 @@
fi
done
-echo virtual machine $VMNAME not found in $XENCONFPATH
+echo "virtual machine $VMNAME not found in $XENCONFPATH"
exit 1
Modified: trunk/settings/lxm
===================================================================
--- trunk/settings/lxm 2007-11-06 20:59:52 UTC (rev 3)
+++ trunk/settings/lxm 2007-11-09 20:07:47 UTC (rev 4)
@@ -8,3 +8,8 @@
# X lock dir
XLOCKDIR="/tmp"
+
+# buffer size for disk copies (bigger is faster)
+# DD block size (bs= parameter)
+DDBS="30M"
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|