X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Flib%2Finstallers%2Ffuel;h=85865720453ee0d6118f25ccaf62842c510be469;hb=c9fb5207df1a3aa579d86f413587ec47c41063af;hp=da0de34bc1e07c6a3883178dd9da5217890450ad;hpb=4ca434ef8df820f0eb3a8f12931352838ed25ed3;p=doctor.git diff --git a/tests/lib/installers/fuel b/tests/lib/installers/fuel index da0de34b..85865720 100644 --- a/tests/lib/installers/fuel +++ b/tests/lib/installers/fuel @@ -74,6 +74,38 @@ function installer_apply_patches { 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 } @@ -83,6 +115,8 @@ function setup_installer { 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 @@ -138,6 +172,19 @@ function installer_revert_patches { 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 }