-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgnt-growonline
More file actions
executable file
·37 lines (31 loc) · 824 Bytes
/
gnt-growonline
File metadata and controls
executable file
·37 lines (31 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
set -e
name=$1
if [ -z "$name" ]; then
echo $0 vmname
exit 1
fi
monitorpath=/var/run/ganeti/kvm-hypervisor/ctrl/${name}.monitor
if [ ! -S $monitorpath ]; then
echo $monitorpath dont exists
exit 1
fi
tmpfile=`mktemp /tmp/vm-${name}.XXXXXX`
echo info block |socat - unix:$monitorpath |grep -E '^(disk|hotdisk)' > $tmpfile
echo disks:
cat $tmpfile
kvmnames=$(cut -f 1 -d ' ' <$tmpfile)
for kvmname in $kvmnames; do
blockname=$(grep $kvmname $tmpfile | grep -Eo '/var/run/ganeti/instance-disks/[a-z0-9:-]+')
if [ ! -h "$blockname" ]; then
echo there is no file $blockname
exit 1
fi
size=$(blockdev --getsize64 "$blockname")
if [ ! $size -gt 0 ]; then
echo incorrect size
exit 1
fi
echo size of $blockname: $size
echo block_resize $kvmname ${size}B |socat - unix:$monitorpath |xargs echo
done