summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2012-11-17 08:49:12 +0100
committerDominique Martinet <asmadeus@codewreck.org>2012-11-20 13:39:25 +0100
commita8d962bad074b703745272b8297de29a767ffef5 (patch)
tree1cdcb80d70145030185dbb5b3db2808301f27b81
parent25c55c77752d5026d990b491c1bd829d4c863f7f (diff)
Do not fail if no VM yet (random_mac (always used, maybe fix that instead...), list, status)
-rwxr-xr-xkvm-wrapper.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index c31bdc7..29eee42 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -161,7 +161,7 @@ function random_mac ()
BASE_MAC=${BASE_MAC:-"52:54:00:ff"}
local MACADDR=`printf "$BASE_MAC:%02x:%02x" $((RANDOM % 256)) $((RANDOM % 256))`
# check if it's not already used..
- grep -qe "KVM_MACADDR.*=\"$MACADDR\"" $VM_DIR/*-vm \
+ grep -qre "KVM_MACADDR.*=\"$MACADDR\"" $VM_DIR \
&& random_mac \
|| echo -n $MACADDR
}
@@ -402,6 +402,9 @@ function kvm_status ()
then
kvm_status_vm "$1"
else
+ # Check that there actually are VMs first.
+ ls "$PID_DIR"/*-vm.pid >&/dev/null || fail_exit "No VM yet"
+
for KVM_CLUSTER_NODE in `ls -1 $PID_DIR/*-vm.pid|cut -d: -f1|sed -e 's:.*/::'|uniq`
do
echo "servers on $KVM_CLUSTER_NODE:"
@@ -633,6 +636,9 @@ function kvm_serial ()
function kvm_list ()
{
+ # Check that there actually are VMs first.
+ ls "$VM_DIR"/*-vm >&/dev/null || fail_exit "No VM to list yet"
+
echo "Available VM descriptors :"
for file in "$VM_DIR"/*-vm
do