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 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 56 | # Glance |
| 57 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 58 | keystone user-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 59 | --name=glance \ |
| 60 | --pass="$SERVICE_PASSWORD" \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 61 | --tenant $SERVICE_TENANT_NAME \ |
| 62 | --email=glance@example.com |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 63 | keystone user-role-add \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 64 | --tenant $SERVICE_TENANT_NAME \ |
| 65 | --user glance \ |
Attila Fazekas | 85a85f8 | 2014-01-21 11:13:55 +0100 | [diff] [blame] | 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 |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 79 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 80 | keystone service-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 81 | --name=glance \ |
| 82 | --type=image \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 83 | --description="Glance Image Service" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 84 | keystone endpoint-create \ |
| 85 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 86 | --service glance \ |
Steve Baker | 8d6c9bc | 2012-09-11 10:05:14 +1200 | [diff] [blame] | 87 | --publicurl "http://$SERVICE_HOST:9292" \ |
| 88 | --adminurl "http://$SERVICE_HOST:9292" \ |
| 89 | --internalurl "http://$SERVICE_HOST:9292" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 90 | fi |
| 91 | fi |
| 92 | |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 93 | # Ceilometer |
Gordon Chung | ab0595e | 2014-01-16 09:44:57 -0500 | [diff] [blame] | 94 | if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then |
guillaume pernot | 901eed7 | 2012-11-29 08:44:58 +0100 | [diff] [blame] | 95 | # Ceilometer needs ResellerAdmin role to access swift account stats. |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 96 | keystone user-role-add --tenant $SERVICE_TENANT_NAME \ |
| 97 | --user ceilometer \ |
| 98 | --role ResellerAdmin |
Julien Danjou | f36afe5 | 2012-10-04 18:00:10 +0200 | [diff] [blame] | 99 | fi |
| 100 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 101 | # EC2 |
| 102 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
| 103 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 104 | keystone service-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 105 | --name=ec2 \ |
| 106 | --type=ec2 \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 107 | --description="EC2 Compatibility Layer" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 108 | keystone endpoint-create \ |
| 109 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 110 | --service ec2 \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 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 |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 118 | if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift3" ]]; then |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 119 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 120 | keystone service-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 121 | --name=s3 \ |
| 122 | --type=s3 \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 123 | --description="S3" |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 124 | keystone endpoint-create \ |
| 125 | --region RegionOne \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 126 | --service s3 \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 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 |
Gabriel Hurley | a3a496f | 2012-02-13 12:29:23 -0800 | [diff] [blame] | 131 | fi |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 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 |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 136 | keystone tenant-create \ |
| 137 | --name=alt_demo |
| 138 | keystone user-create \ |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 139 | --name=alt_demo \ |
| 140 | --pass="$ADMIN_PASSWORD" \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 141 | --email=alt_demo@example.com |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 142 | keystone user-role-add \ |
Ken'ichi Ohmichi | 9aadec3 | 2013-12-27 19:08:26 +0900 | [diff] [blame] | 143 | --tenant alt_demo \ |
| 144 | --user alt_demo \ |
| 145 | --role Member |
Jay Pipes | b297d2d | 2012-05-10 11:21:22 -0400 | [diff] [blame] | 146 | fi |