Change role of doctor user to _member_
[doctor.git] / tests / lib / installers / fuel
index da0de34..0c56963 100644 (file)
@@ -74,6 +74,31 @@ 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
+                # TODO(tojuvone) policy.json might not exists in Ocata.
+                echo "$np_conf does not exist!!!"
+            fi
             ' > installer_apply_patches_$node.log 2>&1
     done
 }
@@ -83,6 +108,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 +165,17 @@ 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
+            entry="os_compute_api:servers:show:host_status"
+            if [ -e $np_conf ]; then
+                np_backup="${np_conf}-doctor-saved"
+                if [ -e $np_backup ]; then
+                    cp -f $np_backup $np_conf
+                    rm $np_backup
+                    service nova-api restart
+                fi
+            fi
             ' >> installer_apply_patches_$node.log 2>&1
     done
 }