forked from Telmate/proxmox-api-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testsetups_configlxc
95 lines (74 loc) · 2.68 KB
/
testsetups_configlxc
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
#!/bin/bash
testsetup_configlxc_newconfiglxcfromjson() {
local runcount=$1 ; shift
local target=${FUNCNAME##*${setup_prefix}} ; debugMessage "SETUP TARGET: $target"
debugMessage 'Generating new CT configuration'
selectedid_ct=$selectedid
vms[$selectedid_ct]='ct'
vmnames[$selectedid_ct]="test-createct${runcount}"
vmconfigs[$selectedid_ct]=$(ctCreateJson ${vmnames[$selectedid_ct]})
runAction $target <<< ${vmconfigs[$selectedid_ct]}
setActionResult $target $?
}
testsetup_configlxc_createvm() {
local runcount=$1 ; shift
local target=${FUNCNAME##*${setup_prefix}} ; debugMessage "SETUP TARGET: $target"
debugMessage 'Manual intervention needed'
cat<<EOF
These are the nodes I got from the previous node_getnodelist test: ${nodes[@]}
At which node should I attempt to create the CTs?
EOF
promptNode "Enter node name (${nodes[0]}) " "${nodes[0]}" 1
selectednode_ct=$selectednode
local flags="-vmid $selectedid_ct"
runAction $flags $target $selectednode_ct <<< ${vmconfigs[$selectedid_ct]}
setActionResult $target $?
}
testsetup_configlxc_updateconfig() {
local target=${FUNCNAME##*${setup_prefix}} ; debugMessage "SETUP TARGET: $target"
echo "Altering configuration of all created CTs"
local flags result
for vmid in "${!vms[@]}"; do
[[ "${vms[$vmid]}" == "vm" ]] && continue
flags="-vmid ${vmid}"
runAction $flags $target $arguments< <(ctUpdateConfigJson "${vmnames[$vmid]}-updated")
result=$?
setActionResult $target $result
(( result )) && break
done
return $result
}
testsetup_configlxc_newconfiglxcfromapi() {
local target=${FUNCNAME##*${setup_prefix}} ; debugMessage "SETUP TARGET: $target"
local flags="-vmid $selectedid_ct"
runAction $flags $target
setActionResult $target $?
}
testsetup_configlxc_createnetparams() {
testsetup_simple <<EOF
{
"model": "virtio",
"bridge": "vmbr0",
"hwaddr": "$(randomMacAddress)"
}
EOF
}
testsetup_configlxc_creatempparams() {
testsetup_stub
# local target=${FUNCNAME##*${setup_prefix}}
# testsetup_simple $target < <(diskJson test-createqemudisksparams 2)
}
testsetup_configlxc_updateconfig() {
local target=${FUNCNAME##*${setup_prefix}} ; debugMessage "SETUP TARGET: $target"
echo "Altering configuration of all created CTs"
local flags result
for vmid in "${!vms[@]}"; do
[[ "${vms[$vmid]}" == "vm" ]] && continue
flags="-vmid ${vmid}"
runAction $flags $target $arguments< <(ctUpdateConfigJson "${vmnames[$vmid]}-updated" | tee /dev/tty)
result=$?
setActionResult $target $result
(( result )) && break
done
return $result
}