... | ... |
@@ -9,7 +9,7 @@ if is_service_enabled tempest; then |
9 | 9 |
install_tempest |
10 | 10 |
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then |
11 | 11 |
# Tempest config must come after layer 2 services are running |
12 |
- : |
|
12 |
+ create_tempest_accounts |
|
13 | 13 |
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then |
14 | 14 |
echo_summary "Initializing Tempest" |
15 | 15 |
configure_tempest |
16 | 16 |
deleted file mode 100755 |
... | ... |
@@ -1,146 +0,0 @@ |
1 |
-#!/bin/bash |
|
2 |
-# |
|
3 |
-# Initial data for Keystone using python-keystoneclient |
|
4 |
-# |
|
5 |
-# Tenant User Roles |
|
6 |
-# ------------------------------------------------------------------ |
|
7 |
-# service glance service |
|
8 |
-# service glance-swift ResellerAdmin |
|
9 |
-# service heat service # if enabled |
|
10 |
-# service ceilometer admin # if enabled |
|
11 |
-# Tempest Only: |
|
12 |
-# alt_demo alt_demo Member |
|
13 |
-# |
|
14 |
-# Variables set before calling this script: |
|
15 |
-# SERVICE_TOKEN - aka admin_token in keystone.conf |
|
16 |
-# SERVICE_ENDPOINT - local Keystone admin endpoint |
|
17 |
-# SERVICE_TENANT_NAME - name of tenant containing service accounts |
|
18 |
-# SERVICE_HOST - host used for endpoint creation |
|
19 |
-# ENABLED_SERVICES - stack.sh's list of services to start |
|
20 |
-# DEVSTACK_DIR - Top-level DevStack directory |
|
21 |
-# KEYSTONE_CATALOG_BACKEND - used to determine service catalog creation |
|
22 |
- |
|
23 |
-# Defaults |
|
24 |
-# -------- |
|
25 |
- |
|
26 |
-ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete} |
|
27 |
-SERVICE_PASSWORD=${SERVICE_PASSWORD:-$ADMIN_PASSWORD} |
|
28 |
-export SERVICE_TOKEN=$SERVICE_TOKEN |
|
29 |
-export SERVICE_ENDPOINT=$SERVICE_ENDPOINT |
|
30 |
-SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service} |
|
31 |
- |
|
32 |
-# Roles |
|
33 |
-# ----- |
|
34 |
- |
|
35 |
-# The ResellerAdmin role is used by Nova and Ceilometer so we need to keep it. |
|
36 |
-# The admin role in swift allows a user to act as an admin for their tenant, |
|
37 |
-# but ResellerAdmin is needed for a user to act as any tenant. The name of this |
|
38 |
-# role is also configurable in swift-proxy.conf |
|
39 |
-keystone role-create --name=ResellerAdmin |
|
40 |
-# Service role, so service users do not have to be admins |
|
41 |
-keystone role-create --name=service |
|
42 |
- |
|
43 |
- |
|
44 |
-# Services |
|
45 |
-# -------- |
|
46 |
- |
|
47 |
-if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then |
|
48 |
- # Nova needs ResellerAdmin role to download images when accessing |
|
49 |
- # swift through the s3 api. |
|
50 |
- keystone user-role-add \ |
|
51 |
- --tenant $SERVICE_TENANT_NAME \ |
|
52 |
- --user nova \ |
|
53 |
- --role ResellerAdmin |
|
54 |
-fi |
|
55 |
- |
|
56 |
-# Glance |
|
57 |
-if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
|
58 |
- keystone user-create \ |
|
59 |
- --name=glance \ |
|
60 |
- --pass="$SERVICE_PASSWORD" \ |
|
61 |
- --tenant $SERVICE_TENANT_NAME \ |
|
62 |
- --email=glance@example.com |
|
63 |
- keystone user-role-add \ |
|
64 |
- --tenant $SERVICE_TENANT_NAME \ |
|
65 |
- --user glance \ |
|
66 |
- --role service |
|
67 |
- # required for swift access |
|
68 |
- if [[ "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
|
69 |
- keystone user-create \ |
|
70 |
- --name=glance-swift \ |
|
71 |
- --pass="$SERVICE_PASSWORD" \ |
|
72 |
- --tenant $SERVICE_TENANT_NAME \ |
|
73 |
- --email=glance-swift@example.com |
|
74 |
- keystone user-role-add \ |
|
75 |
- --tenant $SERVICE_TENANT_NAME \ |
|
76 |
- --user glance-swift \ |
|
77 |
- --role ResellerAdmin |
|
78 |
- fi |
|
79 |
- if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
|
80 |
- keystone service-create \ |
|
81 |
- --name=glance \ |
|
82 |
- --type=image \ |
|
83 |
- --description="Glance Image Service" |
|
84 |
- keystone endpoint-create \ |
|
85 |
- --region RegionOne \ |
|
86 |
- --service glance \ |
|
87 |
- --publicurl "http://$SERVICE_HOST:9292" \ |
|
88 |
- --adminurl "http://$SERVICE_HOST:9292" \ |
|
89 |
- --internalurl "http://$SERVICE_HOST:9292" |
|
90 |
- fi |
|
91 |
-fi |
|
92 |
- |
|
93 |
-# Ceilometer |
|
94 |
-if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then |
|
95 |
- # Ceilometer needs ResellerAdmin role to access swift account stats. |
|
96 |
- keystone user-role-add --tenant $SERVICE_TENANT_NAME \ |
|
97 |
- --user ceilometer \ |
|
98 |
- --role ResellerAdmin |
|
99 |
-fi |
|
100 |
- |
|
101 |
-# EC2 |
|
102 |
-if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
|
103 |
- if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
|
104 |
- keystone service-create \ |
|
105 |
- --name=ec2 \ |
|
106 |
- --type=ec2 \ |
|
107 |
- --description="EC2 Compatibility Layer" |
|
108 |
- keystone endpoint-create \ |
|
109 |
- --region RegionOne \ |
|
110 |
- --service ec2 \ |
|
111 |
- --publicurl "http://$SERVICE_HOST:8773/services/Cloud" \ |
|
112 |
- --adminurl "http://$SERVICE_HOST:8773/services/Admin" \ |
|
113 |
- --internalurl "http://$SERVICE_HOST:8773/services/Cloud" |
|
114 |
- fi |
|
115 |
-fi |
|
116 |
- |
|
117 |
-# S3 |
|
118 |
-if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift3" ]]; then |
|
119 |
- if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
|
120 |
- keystone service-create \ |
|
121 |
- --name=s3 \ |
|
122 |
- --type=s3 \ |
|
123 |
- --description="S3" |
|
124 |
- keystone endpoint-create \ |
|
125 |
- --region RegionOne \ |
|
126 |
- --service s3 \ |
|
127 |
- --publicurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
|
128 |
- --adminurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
|
129 |
- --internalurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" |
|
130 |
- fi |
|
131 |
-fi |
|
132 |
- |
|
133 |
-if [[ "$ENABLED_SERVICES" =~ "tempest" ]]; then |
|
134 |
- # Tempest has some tests that validate various authorization checks |
|
135 |
- # between two regular users in separate tenants |
|
136 |
- keystone tenant-create \ |
|
137 |
- --name=alt_demo |
|
138 |
- keystone user-create \ |
|
139 |
- --name=alt_demo \ |
|
140 |
- --pass="$ADMIN_PASSWORD" \ |
|
141 |
- --email=alt_demo@example.com |
|
142 |
- keystone user-role-add \ |
|
143 |
- --tenant alt_demo \ |
|
144 |
- --user alt_demo \ |
|
145 |
- --role Member |
|
146 |
-fi |
... | ... |
@@ -69,6 +69,11 @@ function is_ceilometer_enabled { |
69 | 69 |
|
70 | 70 |
# create_ceilometer_accounts() - Set up common required ceilometer accounts |
71 | 71 |
|
72 |
+# Project User Roles |
|
73 |
+# ------------------------------------------------------------------ |
|
74 |
+# SERVICE_TENANT_NAME ceilometer admin |
|
75 |
+# SERVICE_TENANT_NAME ceilometer ResellerAdmin (if Swift is enabled) |
|
76 |
+ |
|
72 | 77 |
create_ceilometer_accounts() { |
73 | 78 |
|
74 | 79 |
SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }") |
... | ... |
@@ -99,6 +104,13 @@ create_ceilometer_accounts() { |
99 | 99 |
--adminurl "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/" \ |
100 | 100 |
--internalurl "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/" |
101 | 101 |
fi |
102 |
+ if is_service_enabled swift; then |
|
103 |
+ # Ceilometer needs ResellerAdmin role to access swift account stats. |
|
104 |
+ openstack role add \ |
|
105 |
+ --project $SERVICE_TENANT_NAME \ |
|
106 |
+ --user ceilometer \ |
|
107 |
+ ResellerAdmin |
|
108 |
+ fi |
|
102 | 109 |
fi |
103 | 110 |
} |
104 | 111 |
|
... | ... |
@@ -159,6 +159,49 @@ function configure_glance { |
159 | 159 |
cp -p $GLANCE_DIR/etc/schema-image.json $GLANCE_SCHEMA_JSON |
160 | 160 |
} |
161 | 161 |
|
162 |
+# create_glance_accounts() - Set up common required glance accounts |
|
163 |
+ |
|
164 |
+# Project User Roles |
|
165 |
+# ------------------------------------------------------------------ |
|
166 |
+# SERVICE_TENANT_NAME glance service |
|
167 |
+# SERVICE_TENANT_NAME glance-swift ResellerAdmin (if Swift is enabled) |
|
168 |
+ |
|
169 |
+function create_glance_accounts { |
|
170 |
+ if is_service_enabled g-api; then |
|
171 |
+ openstack user create \ |
|
172 |
+ --password "$SERVICE_PASSWORD" \ |
|
173 |
+ --project $SERVICE_TENANT_NAME \ |
|
174 |
+ glance |
|
175 |
+ openstack role add \ |
|
176 |
+ --project $SERVICE_TENANT_NAME \ |
|
177 |
+ --user glance \ |
|
178 |
+ service |
|
179 |
+ # required for swift access |
|
180 |
+ if is_service_enabled s-proxy; then |
|
181 |
+ openstack user create \ |
|
182 |
+ --password "$SERVICE_PASSWORD" \ |
|
183 |
+ --project $SERVICE_TENANT_NAME \ |
|
184 |
+ glance-swift |
|
185 |
+ openstack role add \ |
|
186 |
+ --project $SERVICE_TENANT_NAME \ |
|
187 |
+ --user glance-swift \ |
|
188 |
+ ResellerAdmin |
|
189 |
+ fi |
|
190 |
+ if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
|
191 |
+ openstack service create \ |
|
192 |
+ --type image \ |
|
193 |
+ --description "Glance Image Service" \ |
|
194 |
+ glance |
|
195 |
+ openstack endpoint create \ |
|
196 |
+ --region RegionOne \ |
|
197 |
+ --publicurl "http://$GLANCE_HOSTPORT" \ |
|
198 |
+ --adminurl "http://$GLANCE_HOSTPORT" \ |
|
199 |
+ --internalurl "http://$GLANCE_HOSTPORT" \ |
|
200 |
+ glance |
|
201 |
+ fi |
|
202 |
+ fi |
|
203 |
+} |
|
204 |
+ |
|
162 | 205 |
# create_glance_cache_dir() - Part of the init_glance() process |
163 | 206 |
function create_glance_cache_dir { |
164 | 207 |
# Create cache dir |
... | ... |
@@ -266,9 +266,11 @@ function configure_keystone { |
266 | 266 |
|
267 | 267 |
# Tenant User Roles |
268 | 268 |
# ------------------------------------------------------------------ |
269 |
+# admin admin admin |
|
269 | 270 |
# service -- -- |
271 |
+# -- -- service |
|
272 |
+# -- -- ResellerAdmin |
|
270 | 273 |
# -- -- Member |
271 |
-# admin admin admin |
|
272 | 274 |
# demo admin admin |
273 | 275 |
# demo demo Member, anotherrole |
274 | 276 |
# invisible_to_admin demo Member |
... | ... |
@@ -294,10 +296,17 @@ function create_keystone_accounts { |
294 | 294 |
--project $ADMIN_TENANT \ |
295 | 295 |
--user $ADMIN_USER |
296 | 296 |
|
297 |
- # service |
|
298 |
- SERVICE_TENANT=$(openstack project create \ |
|
299 |
- $SERVICE_TENANT_NAME \ |
|
300 |
- | grep " id " | get_field 2) |
|
297 |
+ # Create service project/role |
|
298 |
+ openstack project create $SERVICE_TENANT_NAME |
|
299 |
+ |
|
300 |
+ # Service role, so service users do not have to be admins |
|
301 |
+ openstack role create service |
|
302 |
+ |
|
303 |
+ # The ResellerAdmin role is used by Nova and Ceilometer so we need to keep it. |
|
304 |
+ # The admin role in swift allows a user to act as an admin for their tenant, |
|
305 |
+ # but ResellerAdmin is needed for a user to act as any tenant. The name of this |
|
306 |
+ # role is also configurable in swift-proxy.conf |
|
307 |
+ openstack role create ResellerAdmin |
|
301 | 308 |
|
302 | 309 |
# The Member role is used by Horizon and Swift so we need to keep it: |
303 | 310 |
MEMBER_ROLE=$(openstack role create \ |
... | ... |
@@ -316,9 +316,10 @@ function configure_nova { |
316 | 316 |
|
317 | 317 |
# create_nova_accounts() - Set up common required nova accounts |
318 | 318 |
|
319 |
-# Tenant User Roles |
|
319 |
+# Project User Roles |
|
320 | 320 |
# ------------------------------------------------------------------ |
321 |
-# service nova admin, [ResellerAdmin (swift only)] |
|
321 |
+# SERVICE_TENANT_NAME nova admin |
|
322 |
+# SERVICE_TENANT_NAME nova ResellerAdmin (if Swift is enabled) |
|
322 | 323 |
|
323 | 324 |
# Migrated from keystone_data.sh |
324 | 325 |
create_nova_accounts() { |
... | ... |
@@ -363,6 +364,48 @@ create_nova_accounts() { |
363 | 363 |
--internalurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" |
364 | 364 |
fi |
365 | 365 |
fi |
366 |
+ |
|
367 |
+ if is_service_enabled n-api; then |
|
368 |
+ # Swift |
|
369 |
+ if is_service_enabled swift; then |
|
370 |
+ # Nova needs ResellerAdmin role to download images when accessing |
|
371 |
+ # swift through the s3 api. |
|
372 |
+ openstack role add \ |
|
373 |
+ --project $SERVICE_TENANT_NAME \ |
|
374 |
+ --user nova \ |
|
375 |
+ ResellerAdmin |
|
376 |
+ fi |
|
377 |
+ |
|
378 |
+ # EC2 |
|
379 |
+ if [[ "$KEYSTONE_CATALOG_BACKEND" = "sql" ]]; then |
|
380 |
+ openstack service create \ |
|
381 |
+ --type ec2 \ |
|
382 |
+ --description "EC2 Compatibility Layer" \ |
|
383 |
+ ec2 |
|
384 |
+ openstack endpoint create \ |
|
385 |
+ --region RegionOne \ |
|
386 |
+ --publicurl "http://$SERVICE_HOST:8773/services/Cloud" \ |
|
387 |
+ --adminurl "http://$SERVICE_HOST:8773/services/Admin" \ |
|
388 |
+ --internalurl "http://$SERVICE_HOST:8773/services/Cloud" \ |
|
389 |
+ ec2 |
|
390 |
+ fi |
|
391 |
+ fi |
|
392 |
+ |
|
393 |
+ # S3 |
|
394 |
+ if is_service_enabled n-obj swift3; then |
|
395 |
+ if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
|
396 |
+ openstack service create \ |
|
397 |
+ --type s3 \ |
|
398 |
+ --description "S3" \ |
|
399 |
+ s3 |
|
400 |
+ openstack endpoint create \ |
|
401 |
+ --region RegionOne \ |
|
402 |
+ --publicurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
|
403 |
+ --adminurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
|
404 |
+ --internalurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
|
405 |
+ s3 |
|
406 |
+ fi |
|
407 |
+ fi |
|
366 | 408 |
} |
367 | 409 |
|
368 | 410 |
# create_nova_conf() - Create a new nova.conf file |
... | ... |
@@ -372,6 +372,30 @@ function configure_tempest { |
372 | 372 |
$errexit |
373 | 373 |
} |
374 | 374 |
|
375 |
+# create_tempest_accounts() - Set up common required tempest accounts |
|
376 |
+ |
|
377 |
+# Project User Roles |
|
378 |
+# ------------------------------------------------------------------ |
|
379 |
+# alt_demo alt_demo Member |
|
380 |
+ |
|
381 |
+# Migrated from keystone_data.sh |
|
382 |
+function create_tempest_accounts { |
|
383 |
+ if is_service_enabled tempest; then |
|
384 |
+ # Tempest has some tests that validate various authorization checks |
|
385 |
+ # between two regular users in separate tenants |
|
386 |
+ openstack project create \ |
|
387 |
+ alt_demo |
|
388 |
+ openstack user create \ |
|
389 |
+ --project alt_demo \ |
|
390 |
+ --password "$ADMIN_PASSWORD" \ |
|
391 |
+ alt_demo |
|
392 |
+ openstack role add \ |
|
393 |
+ --project alt_demo \ |
|
394 |
+ --user alt_demo \ |
|
395 |
+ Member |
|
396 |
+ fi |
|
397 |
+} |
|
398 |
+ |
|
375 | 399 |
# install_tempest() - Collect source and prepare |
376 | 400 |
function install_tempest { |
377 | 401 |
git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH |
... | ... |
@@ -908,14 +908,13 @@ if is_service_enabled key; then |
908 | 908 |
SERVICE_ENDPOINT=http://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT_INT/v2.0 |
909 | 909 |
fi |
910 | 910 |
|
911 |
- # Do the keystone-specific bits from keystone_data.sh |
|
912 |
- export OS_SERVICE_TOKEN=$SERVICE_TOKEN |
|
913 |
- export OS_SERVICE_ENDPOINT=$SERVICE_ENDPOINT |
|
914 |
- # Add temporarily to make openstackclient work |
|
911 |
+ # Setup OpenStackclient token-flow auth |
|
915 | 912 |
export OS_TOKEN=$SERVICE_TOKEN |
916 | 913 |
export OS_URL=$SERVICE_ENDPOINT |
914 |
+ |
|
917 | 915 |
create_keystone_accounts |
918 | 916 |
create_nova_accounts |
917 |
+ create_glance_accounts |
|
919 | 918 |
create_cinder_accounts |
920 | 919 |
create_neutron_accounts |
921 | 920 |
|
... | ... |
@@ -923,7 +922,7 @@ if is_service_enabled key; then |
923 | 923 |
create_ceilometer_accounts |
924 | 924 |
fi |
925 | 925 |
|
926 |
- if is_service_enabled swift || is_service_enabled s-proxy; then |
|
926 |
+ if is_service_enabled swift; then |
|
927 | 927 |
create_swift_accounts |
928 | 928 |
fi |
929 | 929 |
|
... | ... |
@@ -931,20 +930,14 @@ if is_service_enabled key; then |
931 | 931 |
create_heat_accounts |
932 | 932 |
fi |
933 | 933 |
|
934 |
- # ``keystone_data.sh`` creates services, admin and demo users, and roles. |
|
935 |
- ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD \ |
|
936 |
- SERVICE_TOKEN=$SERVICE_TOKEN SERVICE_ENDPOINT=$SERVICE_ENDPOINT SERVICE_HOST=$SERVICE_HOST \ |
|
937 |
- S3_SERVICE_PORT=$S3_SERVICE_PORT KEYSTONE_CATALOG_BACKEND=$KEYSTONE_CATALOG_BACKEND \ |
|
938 |
- DEVSTACK_DIR=$TOP_DIR ENABLED_SERVICES=$ENABLED_SERVICES \ |
|
939 |
- bash -x $FILES/keystone_data.sh |
|
940 |
- |
|
941 |
- # Set up auth creds now that keystone is bootstrapped |
|
934 |
+ # Begone token-flow auth |
|
942 | 935 |
unset OS_TOKEN OS_URL |
936 |
+ |
|
937 |
+ # Set up password-flow auth creds now that keystone is bootstrapped |
|
943 | 938 |
export OS_AUTH_URL=$SERVICE_ENDPOINT |
944 | 939 |
export OS_TENANT_NAME=admin |
945 | 940 |
export OS_USERNAME=admin |
946 | 941 |
export OS_PASSWORD=$ADMIN_PASSWORD |
947 |
- unset OS_SERVICE_TOKEN OS_SERVICE_ENDPOINT |
|
948 | 942 |
fi |
949 | 943 |
|
950 | 944 |
|