summaryrefslogtreecommitdiffstats
path: root/tools/keystone/region.sh
blob: c42401decbf351ed2e0b5343828d29e65305e566 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# Author: Dimitri Mazmanov (dimitri.mazmanov@ericsson.com)
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#

set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source openrc

# This script registers a new OpenStack region in Keystone.
# It relies on availability of the following environment variables
#
# $NEW_PUBLIC_URL - public URL for the OpenStack services
# $NEW_INTERNAL_URL - internal URL for the OpenStack services
# $NEW_ADMIN_URL - admin URL for the OpenStack services. Typically the same as internal URL
# $NEW_REGION - new region name. E.g. RegionTwo
#
# Invoke the script on the master region - the region which hosts a centralized Keystone instance.
# Additional services can be register using the following pattern:
#
# openstack endpoint create --publicurl "" --adminurl "" --internalurl "" --region ${region} <service>

# if running as part of Jenkins job, read the file from WORKSPACE
WORKSPACE=${WORKSPACE:-/root}
ENDPOINT_FILE="${WORKSPACE}/endpoints.ini"

# Get an option from an INI file
# iniget config-file section option
function iniget {
    local xtrace
    xtrace=$(set +o | grep xtrace)
    set +o xtrace
    local file=$1
    local section=$2
    local option=$3
    local line

    line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
    echo ${line#*=}
    $xtrace
}

error () {
    logger -s -t "registration.error" "$*"
    exit 1
}

public_url=$(iniget ${ENDPOINT_FILE} DEFAULT public_url)
internal_url=$(iniget ${ENDPOINT_FILE} DEFAULT internal_url)
admin_url=$(iniget ${ENDPOINT_FILE} DEFAULT admin_url)
region=$(iniget ${ENDPOINT_FILE} DEFAULT os_region)

if [ -z $public_url || -z $internal_url || -z $admin_url || -z $region ]; then
    error "The provided endpoint information is incomplete. Please che the values for public_url, admin_url, internal_url and os_region."
fi

# Nova
openstack endpoint create nova public "http://${public_url}:8774/v2.1" --region ${region}
openstack endpoint create nova admin "http://${admin_url}:8774/v2.1" --region ${region}
openstack endpoint create nova internal "http://${internal_url}:8774/v2.1" --region ${region}

openstack endpoint create compute_legacy public "http://${public_url}:8774/v2/%(tenant_id)s" --region ${region}
openstack endpoint create compute_legacy admin "http://${admin_url}:8774/v2/%(tenant_id)s" --region ${region}
openstack endpoint create compute_legacy internal "http://${internal_url}:8774/v2/%(tenant_id)s" --region ${region}

# Neutron
openstack endpoint create neutron public "http://${public_url}:9696" --region ${region}
openstack endpoint create neutron admin "http://${admin_url}:9696" --region ${region}
openstack endpoint create neutron internal "http://${internal_url}:9696" --region ${region}

# Cinder
openstack endpoint create cinder public "http://${public_url}:8776/v1/%(tenant_id)s" --region ${region}
openstack endpoint create cinder admin "http://${admin_url}:8776/v1/%(tenant_id)s" --region ${region}
openstack endpoint create cinder internal "http://${internal_url}:8776/v1/%(tenant_id)s" --region ${region}

openstack endpoint create cinderv2 public "http://${public_url}:8776/v2/%(tenant_id)s" --region ${region}
openstack endpoint create cinderv2 admin "http://${admin_url}:8776/v2/%(tenant_id)s" --region ${region}
openstack endpoint create cinderv2 internal "http://${internal_url}:8776/v2/%(tenant_id)s" --region ${region}

openstack endpoint create cinderv3 public "http://${public_url}:8776/v3/%(tenant_id)s" --region ${region}
openstack endpoint create cinderv3 admin "http://${admin_url}:8776/v3/%(tenant_id)s" --region ${region}
openstack endpoint create cinderv3 internal "http://${internal_url}:8776/v3/%(tenant_id)s" --region ${region}

# Glance
openstack endpoint create glance public "http://${public_url}:9292" --region ${region}
openstack endpoint create glance admin "http://${admin_url}:9292" --region ${region}
openstack endpoint create glance internal "http://${internal_url}:9292" --region ${region}

# Heat
openstack endpoint create heat public "http://${public_url}:8004/v1/%(tenant_id)s" --region ${region}
openstack endpoint create heat admin "http://${admin_url}:8004/v1/%(tenant_id)s" --region ${region}
openstack endpoint create heat internal "http://${internal_url}:8004/v1/%(tenant_id)s" --region ${region}

openstack endpoint create heat-cfn public "http://${public_url}:8000/v1" --region ${region}
openstack endpoint create heat-cfn admin "http://${admin_url}:8004/v1/%(tenant_id)s" --region ${region}
openstack endpoint create heat-cfn internal "http://${internal_url}:8004/v1/%(tenant_id)s" --region ${region}

# Swift
openstack endpoint create swift public "http://${public_url}:8080/v1/AUTH_%(tenant_id)s" --region ${region}
openstack endpoint create swift admin "http://${admin_url}:8080/v1/AUTH_%(tenant_id)s" --region ${region}
openstack endpoint create swift internal "http://${internal_url}:8080/v1/AUTH_%(tenant_id)s" --region ${region}

openstack endpoint create swift_s3 public "http://${public_url}:8080" --region ${region}
openstack endpoint create swift_s3 admin "http://${admin_url}:8080" --region ${region}
openstack endpoint create swift_s3 internal "http://${internal_url}:8080" --region ${region}

# Glare
openstack endpoint create glare public "http://${public_url}:9494" --region ${region}
openstack endpoint create glare admin "http://${admin_url}:9494" --region ${region}
openstack endpoint create glare internal "http://${internal_url}:9494" --region ${region}

# Ceilometer
openstack endpoint create ceilometer public "http://${public_url}:8777" --region ${region}
openstack endpoint create ceilometer admin "http://${admin_url}:8777" --region ${region}
openstack endpoint create ceilometer internal "http://${internal_url}:8777" --region ${region}

#Aodh
openstack endpoint create aodh public "http://${public_url}:8042" --region ${region}
openstack endpoint create aodh admin "http://${admin_url}:8042" --region ${region}
openstack endpoint create aodh internal "http://${internal_url}:8042" --region ${region}