blob: 07b6b601d21d647febe56d4edd6e9425bfeb27df [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
Joe Gordon1216b9f2013-06-04 18:55:06 +00008# service heat service # if enabled
Eoghan Glynne3d3cb72013-06-20 15:05:54 +00009# service ceilometer admin # if enabled
Jay Pipesb297d2d2012-05-10 11:21:22 -040010# Tempest Only:
11# alt_demo alt_demo Member
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060012#
13# Variables set before calling this script:
14# SERVICE_TOKEN - aka admin_token in keystone.conf
15# SERVICE_ENDPOINT - local Keystone admin endpoint
16# SERVICE_TENANT_NAME - name of tenant containing service accounts
Dean Troyer3f7c06f2012-04-03 17:19:36 -050017# SERVICE_HOST - host used for endpoint creation
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060018# ENABLED_SERVICES - stack.sh's list of services to start
19# DEVSTACK_DIR - Top-level DevStack directory
Dean Troyer3f7c06f2012-04-03 17:19:36 -050020# KEYSTONE_CATALOG_BACKEND - used to determine service catalog creation
21
22# Defaults
23# --------
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060024
25ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
26SERVICE_PASSWORD=${SERVICE_PASSWORD:-$ADMIN_PASSWORD}
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000027export SERVICE_TOKEN=$SERVICE_TOKEN
28export SERVICE_ENDPOINT=$SERVICE_ENDPOINT
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060029SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000030
Jesse Andrews73e27b82011-09-12 17:55:00 -070031# Roles
Dean Troyer3f7c06f2012-04-03 17:19:36 -050032# -----
33
guillaume pernot901eed72012-11-29 08:44:58 +010034# The ResellerAdmin role is used by Nova and Ceilometer so we need to keep it.
35# The admin role in swift allows a user to act as an admin for their tenant,
36# but ResellerAdmin is needed for a user to act as any tenant. The name of this
37# role is also configurable in swift-proxy.conf
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090038keystone role-create --name=ResellerAdmin
Joe Gordon1216b9f2013-06-04 18:55:06 +000039# Service role, so service users do not have to be admins
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090040keystone role-create --name=service
Jesse Andrews73e27b82011-09-12 17:55:00 -070041
Dean Troyer671c16e2012-12-13 16:22:38 -060042
Dean Troyer3f7c06f2012-04-03 17:19:36 -050043# Services
44# --------
termiea96a4182012-01-09 22:13:29 -080045
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010046if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +000047 # Nova needs ResellerAdmin role to download images when accessing
guillaume pernot901eed72012-11-29 08:44:58 +010048 # swift through the s3 api.
Dean Troyer3f7c06f2012-04-03 17:19:36 -050049 keystone user-role-add \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090050 --tenant $SERVICE_TENANT_NAME \
51 --user nova \
52 --role ResellerAdmin
Jesse Andrews9c7c9082011-11-23 10:10:53 -080053fi
Dean Troyerb7d1fbb2012-03-02 08:43:09 -060054
Steve Bakerbfdad752012-08-18 09:00:42 +120055# Heat
56if [[ "$ENABLED_SERVICES" =~ "heat" ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090057 keystone user-create --name=heat \
Sean Dague922c8ae2013-10-22 10:06:06 -040058 --pass="$SERVICE_PASSWORD" \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090059 --tenant $SERVICE_TENANT_NAME \
60 --email=heat@example.com
61 keystone user-role-add --tenant $SERVICE_TENANT_NAME \
62 --user heat \
63 --role service
Steve Baker053a5f82012-12-11 17:08:48 +130064 # heat_stack_user role is for users created by Heat
65 keystone role-create --name heat_stack_user
Steve Bakerbfdad752012-08-18 09:00:42 +120066 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090067 keystone service-create \
Steve Bakerbb421be2012-10-10 13:19:10 +130068 --name=heat-cfn \
69 --type=cloudformation \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090070 --description="Heat CloudFormation Service"
Steve Bakerbfdad752012-08-18 09:00:42 +120071 keystone endpoint-create \
72 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090073 --service heat-cfn \
Angus Salkelde2790212012-09-11 11:24:09 +100074 --publicurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" \
75 --adminurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" \
76 --internalurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1"
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090077 keystone service-create \
Steve Bakerbb421be2012-10-10 13:19:10 +130078 --name=heat \
79 --type=orchestration \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090080 --description="Heat Service"
Steve Bakerbb421be2012-10-10 13:19:10 +130081 keystone endpoint-create \
82 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090083 --service heat \
Steve Bakerbb421be2012-10-10 13:19:10 +130084 --publicurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \
85 --adminurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \
86 --internalurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s"
Steve Bakerbfdad752012-08-18 09:00:42 +120087 fi
88fi
89
Dean Troyer3f7c06f2012-04-03 17:19:36 -050090# Glance
91if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090092 keystone user-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -050093 --name=glance \
94 --pass="$SERVICE_PASSWORD" \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090095 --tenant $SERVICE_TENANT_NAME \
96 --email=glance@example.com
Dean Troyer3f7c06f2012-04-03 17:19:36 -050097 keystone user-role-add \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +090098 --tenant $SERVICE_TENANT_NAME \
99 --user glance \
100 --role admin
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500101 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900102 keystone service-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500103 --name=glance \
104 --type=image \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900105 --description="Glance Image Service"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500106 keystone endpoint-create \
107 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900108 --service glance \
Steve Baker8d6c9bc2012-09-11 10:05:14 +1200109 --publicurl "http://$SERVICE_HOST:9292" \
110 --adminurl "http://$SERVICE_HOST:9292" \
111 --internalurl "http://$SERVICE_HOST:9292"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500112 fi
113fi
114
Chmouel Boudjnahba313052013-07-10 21:03:43 +0200115# Ceilometer
Doug Hellmann4a2b1c62012-11-01 16:23:52 -0400116if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900117 keystone user-create --name=ceilometer \
Sean Dague922c8ae2013-10-22 10:06:06 -0400118 --pass="$SERVICE_PASSWORD" \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900119 --tenant $SERVICE_TENANT_NAME \
120 --email=ceilometer@example.com
121 keystone user-role-add --tenant $SERVICE_TENANT_NAME \
122 --user ceilometer \
123 --role admin
guillaume pernot901eed72012-11-29 08:44:58 +0100124 # Ceilometer needs ResellerAdmin role to access swift account stats.
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900125 keystone user-role-add --tenant $SERVICE_TENANT_NAME \
126 --user ceilometer \
127 --role ResellerAdmin
Julien Danjouf36afe52012-10-04 18:00:10 +0200128 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900129 keystone service-create \
Julien Danjouf36afe52012-10-04 18:00:10 +0200130 --name=ceilometer \
131 --type=metering \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900132 --description="Ceilometer Service"
Julien Danjouf36afe52012-10-04 18:00:10 +0200133 keystone endpoint-create \
134 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900135 --service ceilometer \
Eoghan Glynn21ddaac2013-03-05 12:40:59 +0000136 --publicurl "http://$SERVICE_HOST:8777" \
137 --adminurl "http://$SERVICE_HOST:8777" \
138 --internalurl "http://$SERVICE_HOST:8777"
Julien Danjouf36afe52012-10-04 18:00:10 +0200139 fi
140fi
141
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500142# EC2
143if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
144 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900145 keystone service-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500146 --name=ec2 \
147 --type=ec2 \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900148 --description="EC2 Compatibility Layer"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500149 keystone endpoint-create \
150 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900151 --service ec2 \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500152 --publicurl "http://$SERVICE_HOST:8773/services/Cloud" \
153 --adminurl "http://$SERVICE_HOST:8773/services/Admin" \
154 --internalurl "http://$SERVICE_HOST:8773/services/Cloud"
155 fi
156fi
157
158# S3
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100159if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift3" ]]; then
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500160 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900161 keystone service-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500162 --name=s3 \
163 --type=s3 \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900164 --description="S3"
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500165 keystone endpoint-create \
166 --region RegionOne \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900167 --service s3 \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500168 --publicurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \
169 --adminurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \
170 --internalurl "http://$SERVICE_HOST:$S3_SERVICE_PORT"
171 fi
Gabriel Hurleya3a496f2012-02-13 12:29:23 -0800172fi
Jay Pipesb297d2d2012-05-10 11:21:22 -0400173
174if [[ "$ENABLED_SERVICES" =~ "tempest" ]]; then
175 # Tempest has some tests that validate various authorization checks
176 # between two regular users in separate tenants
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900177 keystone tenant-create \
178 --name=alt_demo
179 keystone user-create \
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500180 --name=alt_demo \
181 --pass="$ADMIN_PASSWORD" \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900182 --email=alt_demo@example.com
Dean Troyer3f7c06f2012-04-03 17:19:36 -0500183 keystone user-role-add \
Ken'ichi Ohmichi9aadec32013-12-27 19:08:26 +0900184 --tenant alt_demo \
185 --user alt_demo \
186 --role Member
Jay Pipesb297d2d2012-05-10 11:21:22 -0400187fi