-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestingRundek.sh
61 lines (53 loc) · 2.25 KB
/
testingRundek.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
#!/bin/bash
OK=0
KO=0
# source the openrc
source $RD_OPTION_OPENRC
#only execute this once since it takes really long
NEUTRON_AGENT_LIST="$(neutron agent-list)"
if [[ ${RD_OPTION_REFERENCE} == "" ]]; then
REASON_MESSAGE="${RD_OPTION_STATUS^}d by $RD_JOB_USER_NAME using Rundeck ($RD_JOB_EXECID)"
else
REASON_MESSAGE="[$RD_OPTION_REFERENCE] ${RD_OPTION_STATUS^}d by $RD_JOB_USER_NAME using Rundeck ($RD_JOB_EXECID)"
fi
if [ ! -z "$NEUTRON_AGENT_LIST" ]; then
for HOST in $RD_OPTION_HOSTS
do
# Gettting cell info
#HOST_LOWER=${HOST,,} #lower case hostname
#HOST_INFO=$(echo "$NEUTRON_AGENT_LIST" | awk "/$HOST_LOWER/ && /neutron-dhcp-agent/" | awk '{print $1}')
HOST_INFO=$(echo "$NEUTRON_AGENT_LIST" | grep neutron-dhcp-agent | awk -F" |" '{print $2}')
if [ ! -z "$HOST_INFO" ]; then
echo "[INFO] Trying to $RD_OPTION_STATUS neutron-dhcp-agent on $HOST_INFO..."
if [ ${RD_OPTION_BEHAVIOUR} == 'perform' ]; then
if [ ${RD_OPTION_STATUS} == 'down' ]; then
#nova service-$RD_OPTION_STATUS $HOST_INFO nova-compute --reason "$REASON_MESSAGE"
#neutron agent-update 73124323-e555-4d98-b365-0854fc28a2f5 --admin-state-down
neutron agent-update $HOST_INFO --admin-state-$RD_OPTION_STATUS
fi
if [ $? -eq 0 ]; then
echo "[INFO] neutron-dhcp-agent sucessfully "$RD_OPTION_STATUS"d on $HOST."
((OK++))
else
sleep 1 # output messages order
echo "[ERROR] Failed to "$RD_OPTION_STATUS"d neutron-dhcp-agent on $HOST."
((KO++))
fi
else
#echo "[DRYRUN][INFO] nova service-$RD_OPTION_STATUS $HOST_INFO neutron-dhcp-agent --reason \""$REASON_MESSAGE"\""
echo "[DRYRUN][INFO] neutron agent-$RD_OPTION_STATUS $HOST_INFO neutron-dhcp-agent"
((OK++))
fi
else
echo "[ERROR] Not found. Has $HOST been deleted already?"
((KO++))
fi
echo ""
done
else
echo "[ERROR] Something went wrong executing neutron agent-list. Please check with the OpenStack admins."
exit 2
fi
#Summary
printf "\n:TOTAL HOSTS:SUCCESS:ERROR\n[${RD_OPTION_BEHAVIOUR^^}] SUMMARY NEUTRON ${RD_OPTION_STATUS^^}: $((OK + KO)): $OK: $KO" | column -t -s ':'
echo ""