blob: fc1e8136a463cc0f8832ee81f2321519ba9838a2 [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#
Attila Fazekas85a85f82014-01-21 11:13:55 +01005# Tenant User Roles
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +00006# ------------------------------------------------------------------
Attila Fazekas85a85f82014-01-21 11:13:55 +01007# service glance service
8# service glance-swift ResellerAdmin
9# service heat service # if enabled
10# service ceilometer admin # if enabled
Jay Pipesb297d2d2012-05-10 11:21:22 -040011# Tempest Only:
Attila Fazekas85a85f82014-01-21 11:13:55 +010012# alt_demo alt_demo Member
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060013#
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
Dean Troyer3f7c06f2012-04-03 17:19:36 -050018# SERVICE_HOST - host used for endpoint creation
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060019# ENABLED_SERVICES - stack.sh's list of services to start
20# DEVSTACK_DIR - Top-level DevStack directory
Dean Troyer3f7c06f2012-04-03 17:19:36 -050021# KEYSTONE_CATALOG_BACKEND - used to determine service catalog creation
22
23# Defaults
24# --------
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060025
26ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
27SERVICE_PASSWORD=${SERVICE_PASSWORD:-$ADMIN_PASSWORD}
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000028export SERVICE_TOKEN=$SERVICE_TOKEN
29export SERVICE_ENDPOINT=$SERVICE_ENDPOINT
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060030SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000031
Jesse Andrews73e27b82011-09-12 17:55:00 -070032# Roles
Dean Troyer3f7c06f2012-04-03 17:19:36 -050033# -----
34
guillaume pernot901eed72012-11-29 08:44:58 +010035# 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
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090039keystone role-create --name=ResellerAdmin
Joe Gordon1216b9f2013-06-04 18:55:06 +000040# Service role, so service users do not have to be admins
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090041keystone role-create --name=service
Jesse Andrews73e27b82011-09-12 17:55:00 -070042
Dean Troyer671c16e2012-12-13 16:22:38 -060043
Dean Troyer3f7c06f2012-04-03 17:19:36 -050044# Services
45# --------
termiea96a4182012-01-09 22:13:29 -080046
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010047if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +000048 # Nova needs ResellerAdmin role to download images when accessing
guillaume pernot901eed72012-11-29 08:44:58 +010049 # swift through the s3 api.
Dean Troyer3f7c06f2012-04-03 17:19:36 -050050 keystone user-role-add \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090051 --tenant $SERVICE_TENANT_NAME \
52 --user nova \
53 --role ResellerAdmin
Jesse Andrews9c7c9082011-11-23 10:10:53 -080054fi
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060055
Dean Troyer3f7c06f2012-04-03 17:19:36 -050056# Glance
57if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090058 keystone user-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -050059 --name=glance \
60 --pass="$SERVICE_PASSWORD" \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090061 --tenant $SERVICE_TENANT_NAME \
62 --email=glance@example.com
Dean Troyer3f7c06f2012-04-03 17:19:36 -050063 keystone user-role-add \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090064 --tenant $SERVICE_TENANT_NAME \
65 --user glance \
Attila Fazekas85a85f82014-01-21 11:13:55 +010066 --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
Dean Troyer3f7c06f2012-04-03 17:19:36 -050079 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090080 keystone service-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -050081 --name=glance \
82 --type=image \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090083 --description="Glance Image Service"
Dean Troyer3f7c06f2012-04-03 17:19:36 -050084 keystone endpoint-create \
85 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090086 --service glance \
Steve Baker8d6c9bc2012-09-11 10:05:14 +120087 --publicurl "http://$SERVICE_HOST:9292" \
88 --adminurl "http://$SERVICE_HOST:9292" \
89 --internalurl "http://$SERVICE_HOST:9292"
Dean Troyer3f7c06f2012-04-03 17:19:36 -050090 fi
91fi
92
Chmouel Boudjnahba313052013-07-10 21:03:43 +020093# Ceilometer
Gordon Chungab0595e2014-01-16 09:44:57 -050094if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then
guillaume pernot901eed72012-11-29 08:44:58 +010095 # Ceilometer needs ResellerAdmin role to access swift account stats.
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090096 keystone user-role-add --tenant $SERVICE_TENANT_NAME \
97 --user ceilometer \
98 --role ResellerAdmin
Julien Danjouf36afe52012-10-04 18:00:10 +020099fi
100
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500101# EC2
102if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
103 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900104 keystone service-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500105 --name=ec2 \
106 --type=ec2 \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900107 --description="EC2 Compatibility Layer"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500108 keystone endpoint-create \
109 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900110 --service ec2 \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500111 --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
115fi
116
117# S3
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100118if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift3" ]]; then
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500119 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900120 keystone service-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500121 --name=s3 \
122 --type=s3 \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900123 --description="S3"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500124 keystone endpoint-create \
125 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900126 --service s3 \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500127 --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
Gabriel Hurleya3a496f2012-02-13 12:29:23 -0800131fi
Jay Pipesb297d2d2012-05-10 11:21:22 -0400132
133if [[ "$ENABLED_SERVICES" =~ "tempest" ]]; then
134 # Tempest has some tests that validate various authorization checks
135 # between two regular users in separate tenants
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900136 keystone tenant-create \
137 --name=alt_demo
138 keystone user-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500139 --name=alt_demo \
140 --pass="$ADMIN_PASSWORD" \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900141 --email=alt_demo@example.com
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500142 keystone user-role-add \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900143 --tenant alt_demo \
144 --user alt_demo \
145 --role Member
Jay Pipesb297d2d2012-05-10 11:21:22 -0400146fi