-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenstacksetup_createEndpoint.sh
More file actions
54 lines (52 loc) · 1.59 KB
/
openstacksetup_createEndpoint.sh
File metadata and controls
54 lines (52 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#######################################
# Create OpenStack Endpoint (if not exist)
#
# Arguments:
# type Type of endpoint (e.g. "compute")
# url_public Url to the service of the endpoint (public)
# url_internal Url to the service of the endpoint (internal)
# url_admin Url to the service of the endpoint (admin)
#
# Returns:
# -
#
# Author: Christopher Hauser <post@c-ha.de>
#######################################
function openstacksetup_createEndpoint(){
type=$1
url_public=$2
url_internal=$3
url_admin=$4
endpoints=$(openstack endpoint list)
if [[ $? != 0 ]]; then
echo "failed querying endpoint list." >&2
return 1
fi
if [[ $(echo "$endpoints" | grep "$type") ]]; then
echo "Endpoint $type exists already"
else
echo "Create endpoint $type with url ${url}"
openstack endpoint create --region $REGION $type public ${url_public}
if [[ $? != 0 ]]; then
echo "cannot create endpoint public" >&2
return 1
fi
openstack endpoint create --region $REGION $type internal ${url_internal}
if [[ $? != 0 ]]; then
echo "cannot create endpoint internal" >&2
return 1
fi
openstack endpoint create --region $REGION $type admin ${url_admin}
if [[ $? != 0 ]]; then
echo "cannot create endpoint admin" >&2
return 1
fi
fi
return 0
}
if [[ ${BASH_SOURCE[0]} != $0 ]]; then
export -f openstacksetup_createEndpoint
else
openstacksetup_createEndpoint "${@}"
exit $?
fi