3 COMPUTE_USER=${COMPUTE_USER:-heat-admin}
4 ssh_opts_cpu="$ssh_opts -i instack_key"
6 function get_installer_ip {
7 is_set INSTALLER_IP && return
8 INSTALLER_IP=$(get_first_vnic_ip undercloud)
11 function installer_get_ssh_keys {
12 sudo scp $ssh_opts "root@$INSTALLER_IP:/home/stack/.ssh/id_rsa" instack_key
13 sudo chown $(whoami):$(whoami) instack_key
17 function get_controller_ips {
18 is_set CONTROLLER_IPS && return
20 CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \
22 nova list | grep ' overcloud-controller-[0-9] ' | \
23 sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'")
24 die_if_not_set $LINENO CONTROLLER_IPS "No controller IPs"
27 function installer_apply_patches {
28 # TODO(r-mibu): fix the followings in upstream (apex)
29 for node in $CONTROLLER_IPS;do
30 echo "check controller configuration for doctor ($node)"
31 ssh $ssh_opts_cpu "heat-admin@$node" '
34 echo "### apply patches (installer=apex)"
36 ep_conf=/etc/ceilometer/event_pipeline.yaml
37 ep_entry="- notifier://?topic=alarm.all"
38 if sudo grep -e "$ep_entry" $ep_conf; then
39 echo "NOTE: ceilometer is configured as we needed"
41 echo "modify the ceilometer config"
42 sudo sed -i -e "$ a \ \ \ \ \ \ \ \ \ \ $ep_entry # added by doctor script" $ep_conf
43 sudo systemctl restart openstack-ceilometer-notification.service
46 co_conf=/etc/congress/congress.conf
47 co_conf_bak=/etc/congress/congress.conf.bak
48 co_entry="congress.datasources.doctor_driver.DoctorDriver"
49 if sudo grep -e "^drivers.*$co_entry" $co_conf; then
50 echo "NOTE: congress is configured as we needed"
52 echo "modify the congress config"
53 sudo cp $co_conf $co_conf_bak
54 sudo sed -i -e "/^drivers/s/$/,$co_entry/" $co_conf
55 sudo systemctl restart openstack-congress-server.service
57 ' > installer_apply_patches_$node.log 2>&1
61 function setup_installer {
63 installer_get_ssh_keys
65 installer_apply_patches
67 # NOTE: while executing command as doctor user,
68 # 'OS_PROJECT_ID' env parameter make openstack clients confused.
72 function get_compute_ip_from_hostname {
75 compute_host_in_undercloud=${compute_host%%.*}
76 COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
78 nova show $compute_host_in_undercloud | \
79 awk '/ ctlplane network /{print \$5}'")
80 die_if_not_set $LINENO COMPUTE_IP "Could get IP address of $compute_host."
83 function installer_revert_patches {
84 # TODO(r-mibu): fix the followings in upstream (apex)
86 for node in $CONTROLLER_IPS;do
87 echo "restore controller configuration if touched ($node)"
88 ssh $ssh_opts_cpu "heat-admin@$node" '
90 echo "### revert patches (installer=apex)"
93 co_conf=/etc/congress/congress.conf
94 co_conf_bak=/etc/congress/congress.conf.bak
95 if [ -e $co_conf_bak ]; then
96 echo "restore the congress config"
97 sudo mv $co_conf_bak $co_conf
98 sudo systemctl restart openstack-congress-server.service
101 ep_conf=/etc/ceilometer/event_pipeline.yaml
102 if sudo grep -q -e "# added by doctor script" $ep_conf; then
103 echo "modify the ceilometer config"
104 sudo sed -ie "/# added by doctor script/d" $ep_conf
105 sudo systemctl restart openstack-ceilometer-notification.service
107 ' >> installer_apply_patches_$node.log 2>&1
111 function cleanup_installer {
112 installer_revert_patches