blob: f6cceb43f5ad9e7aa05421b0e9ae45e4acd4e1b0 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# stefan.k.berg@ericsson.com
# jonas.bjurel@ericsson.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
# Common functions
error_exit () {
echo "Error: $@" >&2
exit 1
}
ssh() {
SSHPASS="r00tme" sshpass -e ssh -o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no -o ConnectTimeout=15 "$@"
}
scp() {
SSHPASS="r00tme" sshpass -e scp -o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no -o ConnectTimeout=15 "$@"
}
noNodesUp () {
fuel node | grep True | wc -l
}
fuel () {
ssh root@10.20.0.2 "fuel $@"
}
# Return MAC id for virsh node
getNodeId() {
virsh dumpxml $1 | grep "mac address" | head -1 | sed "s/.*'..:..:..:..:\(.*\)'.*/\1/"
}
# Wait for node with virtid name to come up
waitForHost() {
mac=`getNodeId $1`
while true
do
fuel node --node-id $mac 2>/dev/null | grep -q True && break
sleep 3
echo -n "."
done
echo -e "\n"
}
# Currently not used!
# Wait for node count to increase
waitForNode() {
local cnt
local initCnt
local expectCnt
initCnt=`noNodesUp`
expectCnt=$[initCnt+1]
while true
do
cnt=`noNodesUp`
if [ $cnt -eq $expectCnt ]; then
break
elif [ $cnt -lt $initCnt ]; then
error_exit "Node count decreased while waiting, $initCnt -> $cnt"
elif [ $cnt -gt $expectCnt ]; then
error_exit "Node count exceeded expect count, $cnt > $expectCnt"
fi
sleep 3
echo -n "."
done
echo -e "\n"
}
bootorder_dvdhd() {
virsh dumpxml $1 | grep -v "<boot.*>" | \
sed "/<\/os>/i\
<boot dev='cdrom'/\>\n\
<boot dev='hd'/\>\n\
<bootmenu enable='no'/\>" > $tmpdir/vm.xml || error_exit "Could not set bootorder"
virsh define $tmpdir/vm.xml || error_exit "Could not set bootorder"
}
bootorder_hddvd() {
virsh dumpxml $1 | grep -v "<boot.*>" | \
sed "/<\/os>/i\
<boot dev='hd'/\>\n\
<boot dev='cdrom'/\>\n\
<bootmenu enable='no'/\>" > $tmpdir/vm.xml || error_exit "Could not set bootorder"
virsh define $tmpdir/vm.xml || error_exit "Could not set bootorder"
}
addisofile() {
virsh dumpxml $1 | grep -v '\.iso' | sed "s/<.*device='cdrom'.*/<disk type='file' device='cdrom'>/" | \
sed "/<.*device='cdrom'.*/a <source file='$2'/>" > $tmpdir/vm.xml \
|| error_exit "Could not add isofile"
virsh define $tmpdir/vm.xml || error_exit "Could not add isofile"
}
removeisofile() {
virsh dumpxml $1 | grep -v '\.iso' | sed "s/<.*device='cdrom'.*/<disk type='block' device='cdrom'>/" \
> $tmpdir/vm.xml \
|| error_exit "Could not remove isofile"
virsh define $tmpdir/vm.xml || error_exit "Could not remove isofile"
}
|