Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Dean Troyer | b7d1fbb | 2012-03-02 08:43:09 -0600 | [diff] [blame] | 2 | # |
| 3 | # Initial data for Keystone using python-keystoneclient |
| 4 | # |
Attila Fazekas | 85a85f8 | 2014-01-21 11:13:55 +0100 | [diff] [blame^] | 5 | # Tenant User Roles |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 6 | # ------------------------------------------------------------------ |
Attila Fazekas | 85a85f8 | 2014-01-21 11:13:55 +0100 | [diff] [blame^] | 7 | # service glance service |
| 8 | # service glance-swift ResellerAdmin |
| 9 | # service heat service # if enabled |
| 10 | # service ceilometer admin # if enabled |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 11 | # Tempest Only: |
Attila Fazekas | 85a85f8 | 2014-01-21 11:13:55 +0100 | [diff] [blame^] | 12 | # alt_demo alt_demo Member |
Dean Troyer | b7d1fbb | 2012-03-02 08:43:09 -0600 | [diff] [blame] | 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 |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 18 | # SERVICE_HOST - host used for endpoint creation |
Dean Troyer | b7d1fbb | 2012-03-02 08:43:09 -0600 | [diff] [blame] | 19 | # ENABLED_SERVICES - stack.sh's list of services to start |
| 20 | # DEVSTACK_DIR - Top-level DevStack directory |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 21 | # KEYSTONE_CATALOG_BACKEND - used to determine service catalog creation |
| 22 | |
| 23 | # Defaults |
| 24 | # -------- |
Dean Troyer | b7d1fbb | 2012-03-02 08:43:09 -0600 | [diff] [blame] | 25 | |
| 26 | ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete} |
| 27 | SERVICE_PASSWORD=${SERVICE_PASSWORD:-$ADMIN_PASSWORD} |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 28 | export SERVICE_TOKEN=$SERVICE_TOKEN |
| 29 | export SERVICE_ENDPOINT=$SERVICE_ENDPOINT |
Dean Troyer | b7d1fbb | 2012-03-02 08:43:09 -0600 | [diff] [blame] | 30 | SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service} |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 31 | |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 32 | # Roles |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 33 | # ----- |
| 34 | |
guillaume pernot | 901eed7 | 2012-11-29 08:44:58 +0100 | [diff] [blame] | 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 |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 39 | keystone role-create --name=ResellerAdmin |
Joe Gordon | 1216b9f | 2013-06-04 18:55:06 +0000 | [diff] [blame] | 40 | # Service role, so service users do not have to be admins |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 41 | keystone role-create --name=service |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 42 | |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 43 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 44 | # Services |
| 45 | # -------- |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 46 | |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 47 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 48 | # Nova needs ResellerAdmin role to download images when accessing |
guillaume pernot | 901eed7 | 2012-11-29 08:44:58 +0100 | [diff] [blame] | 49 | # swift through the s3 api. |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 50 | keystone user-role-add \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 51 | --tenant $SERVICE_TENANT_NAME \ |
| 52 | --user nova \ |
| 53 | --role ResellerAdmin |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 54 | fi |
Dean Troyer | b7d1fbb | 2012-03-02 08:43:09 -0600 | [diff] [blame] | 55 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 56 | # Heat |
| 57 | if [[ "$ENABLED_SERVICES" =~ "heat" ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 58 | keystone user-create --name=heat \ |
Sean Dague | 922c8ae | 2013-10-22 10:06:06 -0400 | [diff] [blame] | 59 | --pass="$SERVICE_PASSWORD" \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 60 | --tenant $SERVICE_TENANT_NAME \ |
| 61 | --email=heat@example.com |
| 62 | keystone user-role-add --tenant $SERVICE_TENANT_NAME \ |
| 63 | --user heat \ |
| 64 | --role service |
Steve Baker | 053a5f8 | 2012-12-11 17:08:48 +1300 | [diff] [blame] | 65 | # heat_stack_user role is for users created by Heat |
| 66 | keystone role-create --name heat_stack_user |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 67 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 68 | keystone service-create \ |
Steve Baker | bb421be | 2012-10-10 13:19:10 +1300 | [diff] [blame] | 69 | --name=heat-cfn \ |
| 70 | --type=cloudformation \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 71 | --description="Heat CloudFormation Service" |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 72 | keystone endpoint-create \ |
| 73 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 74 | --service heat-cfn \ |
Angus Salkeld | e279021 | 2012-09-11 11:24:09 +1000 | [diff] [blame] | 75 | --publicurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" \ |
| 76 | --adminurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" \ |
| 77 | --internalurl "http://$SERVICE_HOST:$HEAT_API_CFN_PORT/v1" |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 78 | keystone service-create \ |
Steve Baker | bb421be | 2012-10-10 13:19:10 +1300 | [diff] [blame] | 79 | --name=heat \ |
| 80 | --type=orchestration \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 81 | --description="Heat Service" |
Steve Baker | bb421be | 2012-10-10 13:19:10 +1300 | [diff] [blame] | 82 | keystone endpoint-create \ |
| 83 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 84 | --service heat \ |
Steve Baker | bb421be | 2012-10-10 13:19:10 +1300 | [diff] [blame] | 85 | --publicurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \ |
| 86 | --adminurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" \ |
| 87 | --internalurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1/\$(tenant_id)s" |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 88 | fi |
| 89 | fi |
| 90 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 91 | # Glance |
| 92 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 93 | keystone user-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 94 | --name=glance \ |
| 95 | --pass="$SERVICE_PASSWORD" \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 96 | --tenant $SERVICE_TENANT_NAME \ |
| 97 | --email=glance@example.com |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 98 | keystone user-role-add \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 99 | --tenant $SERVICE_TENANT_NAME \ |
| 100 | --user glance \ |
Attila Fazekas | 85a85f8 | 2014-01-21 11:13:55 +0100 | [diff] [blame^] | 101 | --role service |
| 102 | # required for swift access |
| 103 | if [[ "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
| 104 | keystone user-create \ |
| 105 | --name=glance-swift \ |
| 106 | --pass="$SERVICE_PASSWORD" \ |
| 107 | --tenant $SERVICE_TENANT_NAME \ |
| 108 | --email=glance-swift@example.com |
| 109 | keystone user-role-add \ |
| 110 | --tenant $SERVICE_TENANT_NAME \ |
| 111 | --user glance-swift \ |
| 112 | --role ResellerAdmin |
| 113 | fi |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 114 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 115 | keystone service-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 116 | --name=glance \ |
| 117 | --type=image \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 118 | --description="Glance Image Service" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 119 | keystone endpoint-create \ |
| 120 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 121 | --service glance \ |
Steve Baker | 8d6c9bc | 2012-09-11 10:05:14 +1200 | [diff] [blame] | 122 | --publicurl "http://$SERVICE_HOST:9292" \ |
| 123 | --adminurl "http://$SERVICE_HOST:9292" \ |
| 124 | --internalurl "http://$SERVICE_HOST:9292" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 125 | fi |
| 126 | fi |
| 127 | |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 128 | # Ceilometer |
Gordon Chung | ab0595e | 2014-01-16 09:44:57 -0500 | [diff] [blame] | 129 | if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then |
guillaume pernot | 901eed7 | 2012-11-29 08:44:58 +0100 | [diff] [blame] | 130 | # Ceilometer needs ResellerAdmin role to access swift account stats. |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 131 | keystone user-role-add --tenant $SERVICE_TENANT_NAME \ |
| 132 | --user ceilometer \ |
| 133 | --role ResellerAdmin |
Julien Danjou | f36afe5 | 2012-10-04 18:00:10 +0200 | [diff] [blame] | 134 | fi |
| 135 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 136 | # EC2 |
| 137 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
| 138 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 139 | keystone service-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 140 | --name=ec2 \ |
| 141 | --type=ec2 \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 142 | --description="EC2 Compatibility Layer" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 143 | keystone endpoint-create \ |
| 144 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 145 | --service ec2 \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 146 | --publicurl "http://$SERVICE_HOST:8773/services/Cloud" \ |
| 147 | --adminurl "http://$SERVICE_HOST:8773/services/Admin" \ |
| 148 | --internalurl "http://$SERVICE_HOST:8773/services/Cloud" |
| 149 | fi |
| 150 | fi |
| 151 | |
| 152 | # S3 |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 153 | if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift3" ]]; then |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 154 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 155 | keystone service-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 156 | --name=s3 \ |
| 157 | --type=s3 \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 158 | --description="S3" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 159 | keystone endpoint-create \ |
| 160 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 161 | --service s3 \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 162 | --publicurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
| 163 | --adminurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" \ |
| 164 | --internalurl "http://$SERVICE_HOST:$S3_SERVICE_PORT" |
| 165 | fi |
Gabriel Hurley | a3a496f | 2012-02-13 12:29:23 -0800 | [diff] [blame] | 166 | fi |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 167 | |
| 168 | if [[ "$ENABLED_SERVICES" =~ "tempest" ]]; then |
| 169 | # Tempest has some tests that validate various authorization checks |
| 170 | # between two regular users in separate tenants |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 171 | keystone tenant-create \ |
| 172 | --name=alt_demo |
| 173 | keystone user-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 174 | --name=alt_demo \ |
| 175 | --pass="$ADMIN_PASSWORD" \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 176 | --email=alt_demo@example.com |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 177 | keystone user-role-add \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 178 | --tenant alt_demo \ |
| 179 | --user alt_demo \ |
| 180 | --role Member |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 181 | fi |