die $LINENO "fuel does not support congress yet..."
fi
+COMPUTE_USER=${COMPUTE_USER:-root}
+ssh_opts_cpu="$ssh_opts -i instack_key"
+
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"
+ INSTALLER_IP=$(get_first_vnic_ip fuel-master)
}
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_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" '
ip netns exec haproxy /usr/lib/ocf/resource.d/fuel/ns_haproxy restart
fi
fi
+
+ np_conf=/etc/nova/policy.json
+ if [ -e $np_conf ]; then
+ entry="os_compute_api:servers:show:host_status"
+ new="rule:admin_or_owner"
+ np_backup="${np_conf}-doctor-saved"
+ if grep -q "${entry}.*${new}" $np_conf; then
+ echo "Not modifying nova policy"
+ elif grep -q "${entry}" $np_conf; then
+ echo "modify nova policy"
+ cp $np_conf $np_backup
+ oldline=$(grep "$entry" $np_conf)
+ newline=$(echo "$oldline" | sed "s/rule.*\"/$new\"/")
+ sed -i "s/$oldline/$newline/" $np_conf
+ service nova-api restart
+ else
+ echo "add nova policy"
+ cp $np_conf $np_backup
+ sed -i "/{/a \ \"${entry}\": \"$new\"" $np_conf
+ service nova-api restart
+ fi
+ else
+ # policy.json does not exist in Ocata.
+ echo "$np_conf does not exist. Creating new one."
+ echo -e "{\n \"context_is_admin\": \"role:admin\"," > $np_conf
+ echo -e " \"owner\" : \"user_id:%(user_id)s\"," >> $np_conf
+ echo -e " \"admin_or_owner\": \"rule:context_is_admin or rule:owner\"," >> $np_conf
+ echo -e " \"os_compute_api:servers:show:host_status\": \"rule:admin_or_owner\" \n}" >> $np_conf
+ np_rm="${np_conf}-doctor-rm"
+ cp $np_conf $np_rm
+ service nova-api restart
+ 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
+function setup_installer {
+ get_installer_ip
+ installer_get_ssh_keys
+ get_controller_ips
+ installer_apply_patches
+ #Might take a moment for nova-api to restart
+ sleep 20
+ if ! openstack flavor show $VM_FLAVOR ; then
+ openstack flavor create --ram 512 --disk 1 $VM_FLAVOR \
+ && touch created_doctor_flavor
fi
+}
+
+function get_compute_ip_from_hostname {
+ local compute_host=$1
+
+ compute_host_in_undercloud=${compute_host%%.*}
+ node_id=$(echo $compute_host_in_undercloud | cut -d "-" -f 2)
+ COMPUTE_IP=$(sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \
+ "fuel node|awk -F '|' -v id=$node_id '{if (\$1 == id) print \$5}' |xargs")
+ 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 (fuel)
get_controller_ips
for node in $CONTROLLER_IPS;do
sed -ie "/# added by doctor script/d" $ep_conf
service ceilometer-agent-notification restart
fi
+
+ np_conf=/etc/nova/policy.json
+ np_backup="${np_conf}-doctor-saved"
+ np_rm="${np_conf}-doctor-rm"
+ if [ -e $np_backup ]; then
+ cp -f $np_backup $np_conf
+ rm $np_backup
+ service nova-api restart
+ elif [ -e $np_rm ]; then
+ rm $np_conf
+ rm $np_rm
+ service nova-api restart
+ fi
' >> installer_apply_patches_$node.log 2>&1
done
}
+
+function cleanup_installer {
+ if [[ -e created_doctor_flavor ]] && openstack flavor show $VM_FLAVOR ; then
+ openstack flavor delete $VM_FLAVOR && rm -f created_doctor_flavor
+ fi
+ installer_revert_patches
+}