summaryrefslogtreecommitdiffstats
path: root/tests/lib/installers/local
diff options
context:
space:
mode:
authorRyota Mibu <r-mibu@cq.jp.nec.com>2017-07-05 08:21:12 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-05 08:21:12 +0000
commit04d5d98e117e77c172d6bc3244c59d7e829051f4 (patch)
treea64b77f2a949d617d7925540bfca21032d138fe1 /tests/lib/installers/local
parent1bc6eb0e8f1ed1e20edcdd7362c23c8948ed3d77 (diff)
parent76dadb96e17e4d066facf0a185a1032e40b980f7 (diff)
Merge "Create policy.json file in Ocata for non-admin user"
Diffstat (limited to 'tests/lib/installers/local')
-rw-r--r--tests/lib/installers/local55
1 files changed, 53 insertions, 2 deletions
diff --git a/tests/lib/installers/local b/tests/lib/installers/local
index 50c3686f..d628867a 100644
--- a/tests/lib/installers/local
+++ b/tests/lib/installers/local
@@ -9,7 +9,42 @@ function installer_get_ssh_keys {
}
function installer_apply_patches {
- # Noop
+ set -x
+ date
+ echo "### apply patches (installer=local)"
+ 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
+ # TODO(umar): Update to systemd when screen is no more used for devstack
+ screen -S stack -p n-api -X stuff "^C^M^[[A^M" # restart n-api service
+ else
+ echo "add nova policy"
+ cp $np_conf $np_backup
+ sed -i "/{/a \ \"${entry}\": \"$new\"" $np_conf
+ screen -S stack -p n-api -X stuff "^C^M^[[A^M"
+ fi
+ else
+ # policy.json does not exist in Ocata.
+ echo "$np_conf does not exist. Creating a 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
+ screen -S stack -p n-api -X stuff "^C^M^[[A^M"
+ fi
+
return
}
@@ -31,6 +66,22 @@ function get_compute_ip_from_hostname {
}
function cleanup_installer {
- # Noop
+ set -x
+ echo "### revert patches (installer=local)"
+ date
+
+ 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
+ screen -S stack -p n-api -X stuff "^C^M^[[A^M"
+ elif [ -e $np_rm ]; then
+ rm $np_conf
+ rm $np_rm
+ screen -S stack -p n-api -X stuff "^C^M^[[A^M"
+ fi
+
return
}