This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathonboard-cluster.sh
117 lines (102 loc) · 3.79 KB
/
onboard-cluster.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
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
110
111
112
113
114
115
116
117
#!/bin/bash
echo '******Starting Cluster Configuration******'
msg=""
stat="FAILURE"
deviceName="__host_name__"
wcNotifyOptions="__wc_notify_options__"
masterIp="__master_mgmt_ip__"
mgmtIp="__mgmt_ip__"
configSyncIp="__config_sync_ip__"
configSyncCidr="__config_sync_cidr__"
configSyncVlan="__config_sync_vlan__"
autoSync="__auto_sync__"
saveOnAutoSync="__save_on_auto_sync__"
if [ "$wcNotifyOptions" == "None" ]; then
wcNotifyOptions=""
else
wcNotifyOptions=" $wcNotifyOptions"
fi
if [[ "$autoSync" == "True" ]]; then
autoSync="--auto-sync"
if [[ "$saveOnAutoSync" == "True" ]]; then
saveOnAutoSync="--save-on-auto-sync"
else
saveOnAutoSync=""
fi
else
autoSync=""
fi
isMaster=false
if [[ "$mgmtIp" == "$masterIp" ]]; then
isMaster=true
fi
deviceCurr=$(tmsh list cm device | grep bigip1 -c)
if [[ "$deviceCurr" -gt 0 ]]; then
echo 'Warning: DeviceName is showing as default bigip1. Manually changing'
if [[ "$deviceName" == "" || "$deviceName" == "None" ]]; then
echo 'building hostname manually - no fqdn returned from neutron port assignment'
dnsSuffix=$(/bin/grep search /etc/resolv.conf |n awk '{print $2}')
hostName="host-$mgmtIp.$dnsSuffix"
else
deviceName=${deviceName%.}
fi
tmsh mv cm device bigip1 "$deviceName"
else
hostName=$(tmsh list cm device one-line | awk '{print $3}')
echo "Using hostName: $hostName"
deviceName="$hostName"
fi
echo 'Configuring config-sync ip'
if [[ $(tmsh list net self | grep "address $configSyncIp" -c) == 0 ]]; then
echo 'Configuring cluster self-ip'
tmsh create net self cluster_self address "$configSyncIp/$configSyncCidr" vlan "$configSyncVlan" allow-service add { tcp:4353 udp:1026 tcp:443 }
else
echo 'Ensuring correct port lockdown configured for cluster ip'
cluster_self=$(tmsh list net self | grep "address $configSyncIp" -C 1 | grep self | awk '{print $3}')
tmsh modify net self "$cluster_self" allow-service add { tcp:4353 udp:1026 tcp:443 }
fi
tmsh modify cm device "$deviceName" configsync-ip $configSyncIp unicast-address { { effective-ip $configSyncIp effective-port 1026 ip $configSyncIp } }
if [[ "$isMaster" == true ]] ; then
echo 'Config-Sync Master device'
f5-rest-node /config/cloud/openstack/node_modules/@f5devcentral/f5-cloud-libs/scripts/cluster.js \
-o /var/log/cloud/openstack/onboard-cluster.log \
--log-level debug \
--host __mgmt_ip__\
--user admin \
--password-url file:///config/cloud/openstack/.adminPwd \
--password-encrypted \
--port __mgmt_port__ \
--create-group \
--device-group __device_group__ \
--sync-type __sync_type__ \
--device "$deviceName" \
--network-failover \
"$autoSync" \
"$saveOnAutoSync"
else
echo 'Config-Sync Secondary device'
f5-rest-node /config/cloud/openstack/node_modules/@f5devcentral/f5-cloud-libs/scripts/cluster.js \
-o /var/log/cloud/openstack/onboard-cluster.log \
--log-level debug \
--host __mgmt_ip__\
--user admin \
--password-url file:///config/cloud/openstack/.adminPwd \
--password-encrypted \
--port __mgmt_port__ \
--join-group \
--device-group __device_group__ \
--sync \
--remote-host __master_mgmt_ip__ \
--remote-user admin \
--remote-password-url file:///config/cloud/openstack/.adminPwd
fi
onboardClusterErrorCount=$(tail /var/log/cloud/openstack/onboard-cluster.log -n 25 | grep "cluster failed" -i -c)
if [ "$onboardClusterErrorCount" -gt 0 ]; then
msg="Onboard-cluster command exited with error. See /var/log/cloud/openstack/onboard-cluster.log for details."
else
stat="SUCCESS"
msg="Onboard-cluster command exited without error."
fi
msg="$msg *** Instance: $deviceName"
echo "$msg"
wc_notify --data-binary '{"status": "'"$stat"'", "reason":"'"$msg"'"}' --retry 5 --retry-max-time 300 --retry-delay 30$wcNotifyOptions