#!/bin/bash if [[ "congress " == "$INSPECTOR_TYPE" ]]; then die $LINENO "fuel does not support congress yet..." fi function get_installer_ip { ssh_opts_cpu="$ssh_opts -i instack_key" is_set INSTALLER_IP && return local instack_mac instack_mac=$(sudo virsh domiflist fuel-master | awk '/fuel1/{print $5}') INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk '{print $1}') die_if_not_set $LINENO INSTALLER_IP "No installer IP" } function get_controller_ips { is_set CONTROLLER_IPS && return get_installer_ip CONTROLLER_IPS=$(ssh $ssh_opts_cpu root@$INSTALLER_IP \ "fuel node | grep controller | cut -d '|' -f 5|xargs") die_if_not_set $LINENO CONTROLLER_IPS "No controller IPs" } function installer_get_ssh_keys { if [[ -e instack_key ]]; then echo "test existing instack_key..." ssh $ssh_opts_cpu root@${INSTALLER_IP} "hostname" && return fi echo "getting instack_key from fuel node..." sshpass -p r00tme scp $ssh_opts root@${INSTALLER_IP}:.ssh/id_rsa instack_key sudo chown $(whoami):$(whoami) instack_key chmod 400 instack_key } function installer_apply_patches { if ! openstack flavor show $VM_FLAVOR ; then openstack flavor create --ram 512 --disk 1 $VM_FLAVOR \ && touch created_doctor_flavor fi # TODO(r-mibu): fix the followings in upstream (fuel) get_controller_ips for node in $CONTROLLER_IPS;do echo "check controller configuration for doctor ($node)" ssh $ssh_opts_cpu "root@$node" ' set -x date echo "### apply patches (installer=fuel)" ep_conf=/etc/ceilometer/event_pipeline.yaml entry="- notifier://?topic=alarm.all" if ! grep -q -e "$entry" $ep_conf; then echo "modify the ceilometer config" echo " $entry # added by doctor script" >> $ep_conf service ceilometer-agent-notification restart fi # TODO(r-mibu): enable this section once congress 4.0.0 is available if false; then co_conf=/etc/congress/congress.conf entry="congress.datasources.doctor_driver.DoctorDriver" if ! grep -q -e "^drivers.*$entry" $co_conf; then echo "modify the congress config" sed -i -e "/^drivers/s/$/,$entry # added by doctor script/" \ $co_conf service congress-server restart fi rule="-m multiport -p tcp --dports 1789" rule+=" -m comment --comment doctor-congress" rule+=" -j ACCEPT" if ! iptables -C INPUT $rule; then iptables -I INPUT $rule fi ha_conf=/etc/haproxy/conf.d/180-congress.cfg if [[ ! -e $ha_conf ]]; then sed -e "1i# generated by doctor script" \ -e "s/9696/1789/" \ -e "s/neutron/congress/" \ /etc/haproxy/conf.d/085-neutron.cfg > $ha_conf ip netns exec haproxy /usr/lib/ocf/resource.d/fuel/ns_haproxy restart fi fi ' > installer_apply_patches_$node.log 2>&1 done } function cleanup_installer_fuel { if [[ -e created_doctor_flavor ]] && openstack flavor show $VM_FLAVOR ; then openstack flavor delete $VM_FLAVOR && rm -f created_doctor_flavor fi # TODO(r-mibu): fix the followings in upstream (fuel) get_controller_ips for node in $CONTROLLER_IPS;do echo "restore controller configuration if touched ($node)" ssh $ssh_opts_cpu "root@$node" ' set -x echo "### revert patches (installer=fuel)" date # TODO(r-mibu): enable this section once congress 4.0.0 is available if false; then ha_conf=/etc/haproxy/conf.d/180-congress.cfg if grep -q "# generated by doctor script" $ha_conf; then rm -f $ha_conf ip netns exec haproxy /usr/lib/ocf/resource.d/fuel/ns_haproxy restart fi rule="-m multiport -p tcp --dports 1789" rule+=" -m comment --comment doctor-congress" rule+=" -j ACCEPT" if iptables -C INPUT $rule; then iptables -D INPUT $rule fi co_conf=/etc/congress/congress.conf entry="congress.datasources.doctor_driver.DoctorDriver" if grep -q -e "^drivers.*$entry # added by doctor script" $co_conf; then echo "modify the congress config" sed -i -e "/^drivers/s/^\(.*\),$entry/\1/" $co_conf service congress-server restart fi fi ep_conf=/etc/ceilometer/event_pipeline.yaml if grep -q "# added by doctor script" $ep_conf; then sed -ie "/# added by doctor script/d" $ep_conf service ceilometer-agent-notification restart fi ' >> installer_apply_patches_$node.log 2>&1 done }