#!/bin/bash if [[ -z $OS_AUTH_URL ]]; then echo "This script must have proper environment variables exported." echo "Please check if you have sourced bileanrc file or openrc file if " echo "you are using devstack." exit -1 fi if [ $OS_USERNAME != 'admin' ]; then echo "This script has to be executed as an 'admin' user." echo "Please set environment variable OS_USERNAME to 'admin'." exit -1 fi if [ $# -ne 2 ]; then echo "Usage: `basename $0` " exit -1 fi PORT=8770 HOST=$1 # Put your host IP here SVC_PASSWD=$2 SERVICE_ID=$(openstack service show bilean -f value -cid 2>/dev/null) if [[ -z $SERVICE_ID ]]; then SERVICE_ID=$(openstack service create \ --name bilean \ --description 'Billing Service V1' \ -f value -cid \ billing) fi if [[ -z $SERVICE_ID ]]; then exit fi openstack endpoint create \ --adminurl "http://$HOST:$PORT/v1" \ --publicurl "http://$HOST:$PORT/v1" \ --internalurl "http://$HOST:$PORT/v1" \ --region RegionOne \ bilean openstack user create \ --password "$SVC_PASSWD" \ --project service \ bilean openstack role add \ admin \ --user bilean \ --project service # make sure 'bilean' has 'service' role in 'demo' project openstack role add \ service \ --user bilean \ --project demo