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