diff options
author | Vincent S. Cojot <vcojot@redhat.com> | 2017-02-08 18:00:14 -0500 |
---|---|---|
committer | Vincent S. Cojot <vcojot@redhat.com> | 2017-02-08 18:00:14 -0500 |
commit | f2df9df1f864a00127daca517afa7330c7d31f15 (patch) | |
tree | c7ed44af71ed19d55c60a5b084ab8d109bc09c20 | |
parent | 76707f93fc6e67c6905b0f79c47130eb32d7ee14 (diff) | |
download | openstack-access-policy-f2df9df1f864a00127daca517afa7330c7d31f15.tar.gz openstack-access-policy-f2df9df1f864a00127daca517afa7330c7d31f15.tar.xz openstack-access-policy-f2df9df1f864a00127daca517afa7330c7d31f15.zip |
Working on script...
-rwxr-xr-x | files/push_sevone_policies_to_overcloud.sh | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/files/push_sevone_policies_to_overcloud.sh b/files/push_sevone_policies_to_overcloud.sh index e43efd0..c4c6695 100755 --- a/files/push_sevone_policies_to_overcloud.sh +++ b/files/push_sevone_policies_to_overcloud.sh @@ -1,6 +1,10 @@ #!/bin/bash # $Id$ set -euf -o pipefail +CTLR_LIST="" +declare -A IP_LIST +src_config="" +dst_config="" # This tool is used to push policies on the overcloud [ "$BASH" ] && function whence @@ -14,7 +18,7 @@ TOP_DIR="$(cd $(/usr/bin/dirname $(whence -- $0 || echo $0));cd ..;pwd)" # Sanity checks if [ "x$(id -n -u)" = "xstack" ]; then if [ -f ${HOME}/stackrc ]; then - ####. ${HOME}/stackrc + stack_installed=OK else echo "(**) No ${HOME}/stackrc, exit!" ; exit 127 fi @@ -22,7 +26,7 @@ else echo "(**) Not stack, exit!" ; exit 127 fi -if [ -e ${HOME}/overcloudrc ]; then +if [ -r ${HOME}/overcloudrc ]; then . ${HOME}/overcloudrc else echo "(**) No ${HOME}/overcloudrc, exit!" ; exit 127 @@ -37,4 +41,45 @@ do fi done -CTLR_LIST=$(nova host-list | awk '/consoleauth/ {split($2,a,".")Íž print a[1]}') +# Obtain list of Controllers from nova (they will be running consoleauth) +CTLR_LIST=$(nova host-list| awk '/consoleauth/ {split($2,a,".") ; print a[1]}'|xargs) +if [ "x${CTLR_LIST}" != "x" ]; then + echo "(II) Found these controllers: ${CTLR_LIST}" +else + echo "(**) Unable to find controllers running consoleauth!"; exit 127 +fi + + +# Obtain IP addresses from Controllers +. ${HOME}/stackrc +for myctrl in ${CTLR_LIST} +do + res=$(openstack server show -c addresses -f value ${myctrl}|sed -e 's/ctlplane=//g') + if [ "x${res}" != "x" ]; then + IP_LIST["${myctrl}"]="${res}" + fi +done +if [ ${#IP_LIST[@]} -gt 0 ]; then + echo "(II) Found these IPs for controllers: ${IP_LIST[@]}" +else + echo "(**) Unable to find controllers IP Addresses!"; exit 127 +fi + + +# Inject Services... +for myctrl in "${!IP_LIST[@]}" +do + myip=${IP_LIST[${myctrl}]} + echo "(II) Processing controller: ${myctrl} (${myip})..." + for mysvc in aodh ceilometer cinder glance gnocchi heat ironic keystone manila mistral neutron nova sahara zaqar + do + src_config="${TOP_DIR}/etc/${mysvc}/policy.json" + dst_config="/etc/${mysvc}/policy.json" + # Start by backing up config files.. + if [ -f ${src_config} ]; then + echo " (II) Uploading ${src_config} to ${myip}:${dst_config}..." + else + echo "(**) Unable to find new policy file at ${src_config}! Exit!"; exit 127 + fi + done +done |