This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-cloud-kvm-deploy.sh
executable file
·75 lines (61 loc) · 2.22 KB
/
create-cloud-kvm-deploy.sh
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
#!/bin/bash
exec 1>/var/log/cloud-install.log 2>&1 # send stdout and stderr from rc.local to a log file
source /tmp/vm_functions.sh
source /tmp/vm-configurations.sh
exec 1> >(logger --priority user.notice --tag "$(basename "$0")") \
2> >(logger --priority user.error --tag "$(basename "$0")")
IFS=
telegram_notify "Building cloud install data structures...."
######### Openstack VM types
######### VM Counts
control_count=$(getVMCount "control")
network_count=$(getVMCount "network")
compute_count=$(getVMCount "compute")
monitoring_count=$(getVMCount "monitoring")
storage_count=$(getVMCount "storage")
### add vm's to array
vms=()
while [ "$control_count" -gt 0 ]; do
printf -v control_count_format "%02d" "$control_count"
echo "add vm to create string -> control$control_count_format"
vms+=("control$control_count_format")
control_count=$((control_count - 1))
done
while [ "$network_count" -gt 0 ]; do
printf -v network_count_format "%02d" "$network_count"
echo "add vm to create string -> network$network_count_format"
vms+=("network$network_count_format")
network_count=$((network_count - 1))
done
while [ "$compute_count" -gt 0 ]; do
printf -v compute_count_format "%02d" "$compute_count"
echo "add vm to create string -> compute$compute_count_format"
vms+=("compute$compute_count_format")
compute_count=$((compute_count - 1))
done
while [ "$monitoring_count" -gt 0 ]; do
printf -v monitoring_count_format "%02d" "$monitoring_count"
echo "add vm to create string -> monitoring$monitoring_count_format"
vms+=("monitoring$monitoring_count_format")
monitoring_count=$((monitoring_count - 1))
done
while [ "$storage_count" -gt 0 ]; do
printf -v storage_count_format "%02d" "$storage_count"
echo "add vm to create string -> storage$storage_count_format"
vms+=("storage$storage_count_format")
storage_count=$((storage_count - 1))
done
echo "VM's to be created"
echo "${vms[@]}"
########### create vm's
index=0
for d in "${vms[@]}"; do
printf -v vm_type_n '%s\n' "${d//[[:digit:]]/}"
vm_type=$(tr -dc '[:print:]' <<< "$vm_type_n")
echo "creating vm of type -> $vm_type"
telegram_notify "Creating cloud vm: $d"
create_vm_kvm "$vm_type" "$d"
sleep 30
((index++))
done
rm -rf /tmp/create-cloud-kvm-deploy.sh