Controller
#!/bin/bash
readonly GLANCE_DBPASS=openstack
readonly GLANCE_PASS=openstack
function get_range_start_line() {
grep -n $1 $2 | cut -d ":" -f 1
}
function get_range_end_line() {
grep -n "^\[" $1 | cut -d ":" -f 1 | grep $2 -A1 | tail -n1
}
function init_config_glance_api() {
filepath='/etc/glance/glance-api.conf'
cp $filepath ${filepath}.bak
sed -i '/^\[database\]/,/^\[/ {s#^connection = .*#connection = mysql+pymysql://glance:'$GLANCE_DBPASS'@controller/glance#g} ' $filepath
keystone_start=$(get_range_start_line "^\[keystone_authtoken\]" $filepath)
keystone_end=$(get_range_end_line $filepath $keystone_start)
sed -i "${keystone_start},$keystone_end {/^\w/d}" $filepath
sed -i $keystone_start"a\www_authenticate_uri = http://controller:5000" $filepath
sed -i