blob: 55878decb74ea252fd94c504f672602bef064c0c (
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
110
111
112
113
|
#!/bin/bash
COMPUTE_USER=${COMPUTE_USER:-heat-admin}
ssh_opts_cpu="$ssh_opts -i instack_key"
function get_installer_ip {
is_set INSTALLER_IP && return
INSTALLER_IP=$(get_first_vnic_ip instack)
}
function installer_get_ssh_keys {
sudo scp $ssh_opts "root@$INSTALLER_IP:/home/stack/.ssh/id_rsa" instack_key
sudo chown $(whoami):$(whoami) instack_key
chmod 400 instack_key
}
function get_controller_ips {
is_set CONTROLLER_IPS && return
get_installer_ip
CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \
"source stackrc
nova list | grep ' overcloud-controller-[0-9] ' | \
sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'")
die_if_not_set $LINENO CONTROLLER_IPS "No controller IPs"
}
function installer_apply_patches {
# TODO(r-mibu): fix the followings in upstream (apex)
for node in $CONTROLLER_IPS;do
echo "check controller configuration for doctor ($node)"
ssh $ssh_opts_cpu "heat-admin@$node" '
set -x
date
echo "### apply patches (installer=apex)"
ep_conf=/etc/ceilometer/event_pipeline.yaml
ep_entry="- notifier://?topic=alarm.all"
if sudo grep -e "$ep_entry" $ep_conf; then
echo "NOTE: ceilometer is configured as we needed"
else
echo "modify the ceilometer config"
sudo sed -i -e "$ a \ \ \ \ \ \ \ \ \ \ $ep_entry # added by doctor script" $ep_conf
sudo systemctl restart openstack-ceilometer-notification.service
fi
co_conf=/etc/congress/congress.conf
co_entry="congress.datasources.doctor_driver.DoctorDriver"
if sudo grep -e "^drivers.*$co_entry" $co_conf; then
echo "NOTE: congress is configured as we needed"
else
echo "modify the congress config"
sudo sed -i -e "/^drivers/s/$/,$co_entry # added by doctor script/" \
$co_conf
sudo systemctl restart openstack-congress-server.service
fi
' > installer_apply_patches_$node.log 2>&1
done
}
function setup_installer {
get_installer_ip
installer_get_ssh_keys
get_controller_ips
installer_apply_patches
# NOTE: while executing command as doctor user,
# 'OS_PROJECT_ID' env parameter make openstack clients confused.
unset OS_PROJECT_ID
}
function get_compute_ip_from_hostname {
local compute_host=$1
compute_host_in_undercloud=${compute_host%%.*}
COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
"source stackrc;
nova show $compute_host_in_undercloud | \
awk '/ ctlplane network /{print \$5}'")
die_if_not_set $LINENO COMPUTE_IP "Could get IP address of $compute_host."
}
function installer_revert_patches {
# TODO(r-mibu): fix the followings in upstream (apex)
get_controller_ips
for node in $CONTROLLER_IPS;do
echo "restore controller configuration if touched ($node)"
ssh $ssh_opts_cpu "heat-admin@$node" '
set -x
echo "### revert patches (installer=apex)"
date
co_conf=/etc/congress/congress.conf
co_entry="congress.datasources.doctor_driver.DoctorDriver"
if sudo grep -q -e "# added by doctor script" $co_conf; then
echo "modify the congress config"
sudo sed -i -e "/^drivers/s/^\(.*\),$co_entry # added by doctor script/\1/" $co_conf
sudo systemctl restart openstack-congress-server.service
fi
ep_conf=/etc/ceilometer/event_pipeline.yaml
if sudo grep -q -e "# added by doctor script" $ep_conf; then
echo "modify the ceilometer config"
sudo sed -ie "/# added by doctor script/d" $ep_conf
sudo systemctl restart openstack-ceilometer-notification.service
fi
' >> installer_apply_patches_$node.log 2>&1
done
}
function cleanup_installer {
installer_revert_patches
return
}
|