Skip to content

Commit 417fd99

Browse files
committed
Use Copy-on-write for VM drive if possible
1 parent 7e87c41 commit 417fd99

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

boot_cluster

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,25 @@ for (( i = 1 ; i <= $NB_INST ; i++ )); do
5656
kub_path="$POOL_PATH/kubernetes"
5757
machines="$(echo -n '192.168.10.1'; for (( i = 2 ; i <= $NB_INST ; i++ )); do echo -n ",192.168.10.$i"; done)"
5858
59-
virsh vol-clone coreos_production_qemu_image.img $name.img --pool $POOL
60-
sed -e "s|%N%|$i|; s|%NAME%|$name|; s|%IMAGE%|$image|; s|%CONFIG%|$config|; s|%KUB_PATH%|$kub_path|" < coreos.xml > .run/$name.xml
59+
if [ -w "$POOL_PATH" ]; then
60+
pushd "$POOL_PATH"
61+
qemu-img create -f qcow2 -b coreos_production_qemu_image.img $name.img
62+
popd
63+
else
64+
echo "You miss write access to $POOL_PATH to benefit from COW"
65+
virsh vol-clone coreos_production_qemu_image.img $name.img --pool $POOL
66+
fi
67+
sed -e "s|%N%|$i|; \
68+
s|%NAME%|$name|; \
69+
s|%IMAGE%|$image|; \
70+
s|%CONFIG%|$config|; \
71+
s|%KUB_PATH%|$kub_path|" < coreos.xml > .run/$name.xml
6172
mkdir -p "$config/openstack/latest"
62-
sed -e "s|%N%|$i|; s|%NAME%|$name|; s|%SSH_KEYS%|$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')|; s|%DISCOVERY%|$discovery|; s|%MACHINES%|$machines|" < user_data.yml | \
73+
sed -e "s|%N%|$i|; \
74+
s|%NAME%|$name|; \
75+
s|%SSH_KEYS%|$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')|; \
76+
s|%DISCOVERY%|$discovery|; \
77+
s|%MACHINES%|$machines|" < user_data.yml | \
6378
( if [ $i -eq 1 ]; then
6479
egrep -v "^%(END)?IF MASTER%$" ;
6580
else

destroy_cluster

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ while virsh destroy coreos$(printf "%02d" $i) 2> /dev/null; do
1010
((i++))
1111
done
1212

13+
virsh pool-refresh $POOL > /dev/null
1314
i=1
1415
while virsh vol-delete coreos$(printf "%02d" $i).img --pool $POOL 2> /dev/null; do
1516
((i++))

0 commit comments

Comments
 (0)