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_entry="congress.datasources.doctor_driver.DoctorDriver"
48 if sudo grep -e "^drivers.*$co_entry" $co_conf; then
49 echo "NOTE: congress is configured as we needed"
51 echo "modify the congress config"
52 sudo sed -i -e "/^drivers/s/$/,$co_entry # added by doctor script/" \
54 sudo systemctl restart openstack-congress-server.service
56 ' > installer_apply_patches_$node.log 2>&1
60 function setup_installer {
62 installer_get_ssh_keys
64 installer_apply_patches
66 # NOTE: while executing command as doctor user,
67 # 'OS_PROJECT_ID' env parameter make openstack clients confused.
71 function get_compute_ip_from_hostname {
74 compute_host_in_undercloud=${compute_host%%.*}
75 COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
77 nova show $compute_host_in_undercloud | \
78 awk '/ ctlplane network /{print \$5}'")
79 die_if_not_set $LINENO COMPUTE_IP "Could get IP address of $compute_host."
82 function installer_revert_patches {
83 # TODO(r-mibu): fix the followings in upstream (apex)
85 for node in $CONTROLLER_IPS;do
86 echo "restore controller configuration if touched ($node)"
87 ssh $ssh_opts_cpu "heat-admin@$node" '
89 echo "### revert patches (installer=apex)"
92 co_conf=/etc/congress/congress.conf
93 co_entry="congress.datasources.doctor_driver.DoctorDriver"
94 if sudo grep -q -e "# added by doctor script" $co_conf; then
95 echo "modify the congress config"
96 sudo sed -i -e "/^drivers/s/^\(.*\),$co_entry # added by doctor script/\1/" $co_conf
97 sudo systemctl restart openstack-congress-server.service
100 ep_conf=/etc/ceilometer/event_pipeline.yaml
101 if sudo grep -q -e "# added by doctor script" $ep_conf; then
102 echo "modify the ceilometer config"
103 sudo sed -ie "/# added by doctor script/d" $ep_conf
104 sudo systemctl restart openstack-ceilometer-notification.service
106 ' >> installer_apply_patches_$node.log 2>&1
110 function cleanup_installer {
111 installer_revert_patches