blob: 32d4e1a024212c5835ceb632d312256154c0d635 [file] [log] [blame]
Jesse Andrews73e27b82011-09-12 17:55:00 -07001#!/bin/bash
Dean Troyerb7d1fbb2012-03-02 08:43:09 -06002#
3# Initial data for Keystone using python-keystoneclient
4#
Doug Hellmann4a2b1c62012-11-01 16:23:52 -04005# Tenant User Roles
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +00006# ------------------------------------------------------------------
Doug Hellmann4a2b1c62012-11-01 16:23:52 -04007# service glance admin
Doug Hellmann4a2b1c62012-11-01 16:23:52 -04008# service quantum admin # if enabled
9# service swift admin # if enabled
10# service cinder admin # if enabled
11# service heat admin # if enabled
12# service ceilometer admin # if enabled
Jay Pipesb297d2d2012-05-10 11:21:22 -040013# Tempest Only:
14# alt_demo alt_demo Member
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060015#
16# Variables set before calling this script:
17# SERVICE_TOKEN - aka admin_token in keystone.conf
18# SERVICE_ENDPOINT - local Keystone admin endpoint
19# SERVICE_TENANT_NAME - name of tenant containing service accounts
Dean Troyer3f7c06f2012-04-03 17:19:36 -050020# SERVICE_HOST - host used for endpoint creation
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060021# ENABLED_SERVICES - stack.sh's list of services to start
22# DEVSTACK_DIR - Top-level DevStack directory
Dean Troyer3f7c06f2012-04-03 17:19:36 -050023# KEYSTONE_CATALOG_BACKEND - used to determine service catalog creation
24
25# Defaults
26# --------
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060027
28ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
29SERVICE_PASSWORD=${SERVICE_PASSWORD:-$ADMIN_PASSWORD}
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000030export SERVICE_TOKEN=$SERVICE_TOKEN
31export SERVICE_ENDPOINT=$SERVICE_ENDPOINT
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060032SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000033
34function get_id () {
Dean Troyer3f7c06f2012-04-03 17:19:36 -050035 echo `"$@" | awk '/ id / { print $4 }'`
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000036}
37
Dean Troyerd835de82012-11-29 17:11:35 -060038# Lookups
39SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
40ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
Jesse Andrews73e27b82011-09-12 17:55:00 -070041
Dean Troyer0bd24102012-03-08 00:33:54 -060042
Jesse Andrews73e27b82011-09-12 17:55:00 -070043# Roles
Dean Troyer3f7c06f2012-04-03 17:19:36 -050044# -----
45
guillaume pernot901eed72012-11-29 08:44:58 +010046# The ResellerAdmin role is used by Nova and Ceilometer so we need to keep it.
47# The admin role in swift allows a user to act as an admin for their tenant,
48# but ResellerAdmin is needed for a user to act as any tenant. The name of this
49# role is also configurable in swift-proxy.conf
50RESELLER_ROLE=$(get_id keystone role-create --name=ResellerAdmin)
Jesse Andrews73e27b82011-09-12 17:55:00 -070051
Dean Troyer3f7c06f2012-04-03 17:19:36 -050052# Services
53# --------
termiea96a4182012-01-09 22:13:29 -080054
Dean Troyera0dce262012-12-11 16:52:37 -060055if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
56 NOVA_USER=$(keystone user-list | awk "/ nova / { print \$2 }")
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +000057 # Nova needs ResellerAdmin role to download images when accessing
guillaume pernot901eed72012-11-29 08:44:58 +010058 # swift through the s3 api.
Dean Troyer3f7c06f2012-04-03 17:19:36 -050059 keystone user-role-add \
60 --tenant_id $SERVICE_TENANT \
61 --user_id $NOVA_USER \
62 --role_id $RESELLER_ROLE
Jesse Andrews9c7c9082011-11-23 10:10:53 -080063fi
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060064
Steve Bakerbfdad752012-08-18 09:00:42 +120065# Heat
66if [[ "$ENABLED_SERVICES" =~ "heat" ]]; then
67 HEAT_USER=$(get_id keystone user-create --name=heat \
68 --pass="$SERVICE_PASSWORD" \
69 --tenant_id $SERVICE_TENANT \
70 --email=heat@example.com)
71 keystone user-role-add --tenant_id $SERVICE_TENANT \
72 --user_id $HEAT_USER \
73 --role_id $ADMIN_ROLE
74 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Steve Baker36cf7ee2012-09-17 16:49:24 +120075 HEAT_CFN_SERVICE=$(get_id keystone service-create \
Steve Bakerbb421be2012-10-10 13:19:10 +130076 --name=heat-cfn \
77 --type=cloudformation \
78 --description="Heat CloudFormation Service")
Steve Bakerbfdad752012-08-18 09:00:42 +120079 keystone endpoint-create \
80 --region RegionOne \
Angus Salkelde2790212012-09-11 11:24:09 +100081 --service_id $HEAT_CFN_SERVICE \
82 --publicurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" \
83 --adminurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" \
84 --internalurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1"
Steve Bakerbb421be2012-10-10 13:19:10 +130085 HEAT_SERVICE=$(get_id keystone service-create \
86 --name=heat \
87 --type=orchestration \
88 --description="Heat Service")
89 keystone endpoint-create \
90 --region RegionOne \
91 --service_id $HEAT_SERVICE \
92 --publicurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \
93 --adminurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \
94 --internalurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s"
Steve Bakerbfdad752012-08-18 09:00:42 +120095 fi
96fi
97
Dean Troyer3f7c06f2012-04-03 17:19:36 -050098# Glance
99if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
100 GLANCE_USER=$(get_id keystone user-create \
101 --name=glance \
102 --pass="$SERVICE_PASSWORD" \
103 --tenant_id $SERVICE_TENANT \
104 --email=glance@example.com)
105 keystone user-role-add \
106 --tenant_id $SERVICE_TENANT \
107 --user_id $GLANCE_USER \
108 --role_id $ADMIN_ROLE
109 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
110 GLANCE_SERVICE=$(get_id keystone service-create \
111 --name=glance \
112 --type=image \
113 --description="Glance Image Service")
114 keystone endpoint-create \
115 --region RegionOne \
116 --service_id $GLANCE_SERVICE \
Steve Baker8d6c9bc2012-09-11 10:05:14 +1200117 --publicurl "http://$SERVICE_HOST:9292" \
118 --adminurl "http://$SERVICE_HOST:9292" \
119 --internalurl "http://$SERVICE_HOST:9292"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500120 fi
121fi
122
123# Swift
124if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
125 SWIFT_USER=$(get_id keystone user-create \
126 --name=swift \
127 --pass="$SERVICE_PASSWORD" \
128 --tenant_id $SERVICE_TENANT \
129 --email=swift@example.com)
130 keystone user-role-add \
131 --tenant_id $SERVICE_TENANT \
132 --user_id $SWIFT_USER \
133 --role_id $ADMIN_ROLE
134 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
135 SWIFT_SERVICE=$(get_id keystone service-create \
136 --name=swift \
137 --type="object-store" \
138 --description="Swift Service")
139 keystone endpoint-create \
140 --region RegionOne \
141 --service_id $SWIFT_SERVICE \
142 --publicurl "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s" \
Steve Baker8d6c9bc2012-09-11 10:05:14 +1200143 --adminurl "http://$SERVICE_HOST:8080" \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500144 --internalurl "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s"
145 fi
146fi
147
148if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
149 QUANTUM_USER=$(get_id keystone user-create \
150 --name=quantum \
151 --pass="$SERVICE_PASSWORD" \
152 --tenant_id $SERVICE_TENANT \
153 --email=quantum@example.com)
154 keystone user-role-add \
155 --tenant_id $SERVICE_TENANT \
156 --user_id $QUANTUM_USER \
157 --role_id $ADMIN_ROLE
158 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
159 QUANTUM_SERVICE=$(get_id keystone service-create \
160 --name=quantum \
161 --type=network \
162 --description="Quantum Service")
163 keystone endpoint-create \
164 --region RegionOne \
165 --service_id $QUANTUM_SERVICE \
166 --publicurl "http://$SERVICE_HOST:9696/" \
167 --adminurl "http://$SERVICE_HOST:9696/" \
168 --internalurl "http://$SERVICE_HOST:9696/"
169 fi
170fi
171
Doug Hellmann4a2b1c62012-11-01 16:23:52 -0400172if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]]; then
173 CEILOMETER_USER=$(get_id keystone user-create --name=ceilometer \
174 --pass="$SERVICE_PASSWORD" \
175 --tenant_id $SERVICE_TENANT \
176 --email=ceilometer@example.com)
177 keystone user-role-add --tenant_id $SERVICE_TENANT \
178 --user_id $CEILOMETER_USER \
179 --role_id $ADMIN_ROLE
guillaume pernot901eed72012-11-29 08:44:58 +0100180 # Ceilometer needs ResellerAdmin role to access swift account stats.
181 keystone user-role-add --tenant_id $SERVICE_TENANT \
182 --user_id $CEILOMETER_USER \
183 --role_id $RESELLER_ROLE
Julien Danjouf36afe52012-10-04 18:00:10 +0200184 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
185 CEILOMETER_SERVICE=$(get_id keystone service-create \
186 --name=ceilometer \
187 --type=metering \
188 --description="Ceilometer Service")
189 keystone endpoint-create \
190 --region RegionOne \
191 --service_id $CEILOMETER_SERVICE \
192 --publicurl "http://$SERVICE_HOST:8777/" \
193 --adminurl "http://$SERVICE_HOST:8777/" \
194 --internalurl "http://$SERVICE_HOST:8777/"
195 fi
196fi
197
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500198# EC2
199if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
200 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
201 EC2_SERVICE=$(get_id keystone service-create \
202 --name=ec2 \
203 --type=ec2 \
204 --description="EC2 Compatibility Layer")
205 keystone endpoint-create \
206 --region RegionOne \
207 --service_id $EC2_SERVICE \
208 --publicurl "http://$SERVICE_HOST:8773/services/Cloud" \
209 --adminurl "http://$SERVICE_HOST:8773/services/Admin" \
210 --internalurl "http://$SERVICE_HOST:8773/services/Cloud"
211 fi
212fi
213
214# S3
215if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift" ]]; then
216 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
217 S3_SERVICE=$(get_id keystone service-create \
218 --name=s3 \
219 --type=s3 \
220 --description="S3")
221 keystone endpoint-create \
222 --region RegionOne \
223 --service_id $S3_SERVICE \
224 --publicurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \
225 --adminurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \
226 --internalurl "http://$SERVICE_HOST:$S3_SERVICE_PORT"
227 fi
Gabriel Hurleya3a496f2012-02-13 12:29:23 -0800228fi
Jay Pipesb297d2d2012-05-10 11:21:22 -0400229
230if [[ "$ENABLED_SERVICES" =~ "tempest" ]]; then
231 # Tempest has some tests that validate various authorization checks
232 # between two regular users in separate tenants
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500233 ALT_DEMO_TENANT=$(get_id keystone tenant-create \
234 --name=alt_demo)
235 ALT_DEMO_USER=$(get_id keystone user-create \
236 --name=alt_demo \
237 --pass="$ADMIN_PASSWORD" \
238 --email=alt_demo@example.com)
239 keystone user-role-add \
240 --tenant_id $ALT_DEMO_TENANT \
241 --user_id $ALT_DEMO_USER \
242 --role_id $MEMBER_ROLE
Jay Pipesb297d2d2012-05-10 11:21:22 -0400243fi
Dean Troyer67787e62012-05-02 11:48:15 -0500244
Chmouel Boudjnahd55509d2012-07-20 15:00:02 +0000245if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
Dean Troyer67787e62012-05-02 11:48:15 -0500246 CINDER_USER=$(get_id keystone user-create --name=cinder \
247 --pass="$SERVICE_PASSWORD" \
248 --tenant_id $SERVICE_TENANT \
249 --email=cinder@example.com)
250 keystone user-role-add --tenant_id $SERVICE_TENANT \
251 --user_id $CINDER_USER \
252 --role_id $ADMIN_ROLE
Anthony Young1cdf5fa2012-07-03 13:57:39 -0700253 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
254 CINDER_SERVICE=$(get_id keystone service-create \
255 --name=cinder \
256 --type=volume \
257 --description="Cinder Service")
258 keystone endpoint-create \
259 --region RegionOne \
260 --service_id $CINDER_SERVICE \
261 --publicurl "http://$SERVICE_HOST:8776/v1/\$(tenant_id)s" \
262 --adminurl "http://$SERVICE_HOST:8776/v1/\$(tenant_id)s" \
263 --internalurl "http://$SERVICE_HOST:8776/v1/\$(tenant_id)s"
264 fi
Dean Troyer67787e62012-05-02 11:48:15 -0500265fi