| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 1 | # lib/keystone | 
|  | 2 | # Functions to control the configuration and operation of **Keystone** | 
|  | 3 |  | 
|  | 4 | # Dependencies: | 
|  | 5 | # ``functions`` file | 
|  | 6 | # ``BASE_SQL_CONN`` | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 7 | # ``SERVICE_HOST``, ``SERVICE_PROTOCOL`` | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 8 | # ``SERVICE_TOKEN`` | 
|  | 9 | # ``S3_SERVICE_PORT`` (template backend only) | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 10 | # ``STACK_USER`` | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 11 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 12 | # ``stack.sh`` calls the entry points in this order: | 
|  | 13 | # | 
|  | 14 | # install_keystone | 
|  | 15 | # configure_keystone | 
|  | 16 | # init_keystone | 
|  | 17 | # start_keystone | 
| Dean Troyer | d835de8 | 2012-11-29 17:11:35 -0600 | [diff] [blame] | 18 | # create_keystone_accounts | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 19 | # stop_keystone | 
|  | 20 | # cleanup_keystone | 
|  | 21 |  | 
| Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 22 | # Save trace setting | 
|  | 23 | XTRACE=$(set +o | grep xtrace) | 
|  | 24 | set +o xtrace | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 25 |  | 
|  | 26 |  | 
|  | 27 | # Defaults | 
|  | 28 | # -------- | 
|  | 29 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 30 | # Set up default directories | 
|  | 31 | KEYSTONE_DIR=$DEST/keystone | 
|  | 32 | KEYSTONE_CONF_DIR=${KEYSTONE_CONF_DIR:-/etc/keystone} | 
|  | 33 | KEYSTONE_CONF=$KEYSTONE_CONF_DIR/keystone.conf | 
| Alan Pevec | e0bb447 | 2013-03-12 11:10:52 +0100 | [diff] [blame] | 34 | KEYSTONE_PASTE_INI=${KEYSTONE_PASTE_INI:-$KEYSTONE_CONF_DIR/keystone-paste.ini} | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 35 | KEYSTONE_AUTH_CACHE_DIR=${KEYSTONE_AUTH_CACHE_DIR:-/var/cache/keystone} | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 36 |  | 
|  | 37 | KEYSTONECLIENT_DIR=$DEST/python-keystoneclient | 
|  | 38 |  | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 39 | # Select the backend for Keystone's service catalog | 
| Dean Troyer | b80379c | 2012-09-10 18:30:37 -0500 | [diff] [blame] | 40 | KEYSTONE_CATALOG_BACKEND=${KEYSTONE_CATALOG_BACKEND:-sql} | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 41 | KEYSTONE_CATALOG=$KEYSTONE_CONF_DIR/default_catalog.templates | 
|  | 42 |  | 
| Davanum Srinivas | 5bd96f9 | 2013-01-29 15:12:20 -0500 | [diff] [blame] | 43 | # Select the backend for Tokens | 
|  | 44 | KEYSTONE_TOKEN_BACKEND=${KEYSTONE_TOKEN_BACKEND:-sql} | 
|  | 45 |  | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 46 | # Select Keystone's token format | 
|  | 47 | # Choose from 'UUID' and 'PKI' | 
|  | 48 | KEYSTONE_TOKEN_FORMAT=${KEYSTONE_TOKEN_FORMAT:-PKI} | 
|  | 49 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 50 | # Set Keystone interface configuration | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 51 | KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST} | 
|  | 52 | KEYSTONE_AUTH_PORT=${KEYSTONE_AUTH_PORT:-35357} | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 53 | KEYSTONE_AUTH_PORT_INT=${KEYSTONE_AUTH_PORT_INT:-35358} | 
|  | 54 | KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-$SERVICE_PROTOCOL} | 
|  | 55 |  | 
|  | 56 | # Public facing bits | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 57 | KEYSTONE_SERVICE_HOST=${KEYSTONE_SERVICE_HOST:-$SERVICE_HOST} | 
|  | 58 | KEYSTONE_SERVICE_PORT=${KEYSTONE_SERVICE_PORT:-5000} | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 59 | KEYSTONE_SERVICE_PORT_INT=${KEYSTONE_SERVICE_PORT_INT:-5001} | 
|  | 60 | KEYSTONE_SERVICE_PROTOCOL=${KEYSTONE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 61 |  | 
| Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 62 | # Set the tenant for service accounts in Keystone | 
|  | 63 | SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service} | 
|  | 64 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 65 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 66 | # Functions | 
|  | 67 | # --------- | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 68 |  | 
|  | 69 | # cleanup_keystone() - Remove residual data files, anything left over from previous | 
|  | 70 | # runs that a clean run would need to clean up | 
|  | 71 | function cleanup_keystone() { | 
|  | 72 | # kill instances (nova) | 
|  | 73 | # delete image files (glance) | 
|  | 74 | # This function intentionally left blank | 
|  | 75 | : | 
|  | 76 | } | 
|  | 77 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 78 | # configure_keystone() - Set config files, create data dirs, etc | 
|  | 79 | function configure_keystone() { | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 80 | if [[ ! -d $KEYSTONE_CONF_DIR ]]; then | 
|  | 81 | sudo mkdir -p $KEYSTONE_CONF_DIR | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 82 | fi | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 83 | sudo chown $STACK_USER $KEYSTONE_CONF_DIR | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 84 |  | 
|  | 85 | if [[ "$KEYSTONE_CONF_DIR" != "$KEYSTONE_DIR/etc" ]]; then | 
|  | 86 | cp -p $KEYSTONE_DIR/etc/keystone.conf.sample $KEYSTONE_CONF | 
|  | 87 | cp -p $KEYSTONE_DIR/etc/policy.json $KEYSTONE_CONF_DIR | 
| Alan Pevec | e0bb447 | 2013-03-12 11:10:52 +0100 | [diff] [blame] | 88 | if [[ -f "$KEYSTONE_DIR/etc/keystone-paste.ini" ]]; then | 
|  | 89 | cp -p "$KEYSTONE_DIR/etc/keystone-paste.ini" "$KEYSTONE_PASTE_INI" | 
|  | 90 | fi | 
|  | 91 | fi | 
|  | 92 | if [[ -f "$KEYSTONE_PASTE_INI" ]]; then | 
|  | 93 | iniset "$KEYSTONE_CONF" paste_deploy config_file "$KEYSTONE_PASTE_INI" | 
|  | 94 | else | 
|  | 95 | # compatibility with mixed cfg and paste.deploy configuration | 
|  | 96 | KEYSTONE_PASTE_INI="$KEYSTONE_CONF" | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 97 | fi | 
|  | 98 |  | 
|  | 99 | # Rewrite stock ``keystone.conf`` | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 100 |  | 
| Brad Topol | f127e2f | 2013-01-22 10:17:50 -0600 | [diff] [blame] | 101 | if is_service_enabled ldap; then | 
|  | 102 | #Set all needed ldap values | 
|  | 103 | iniset $KEYSTONE_CONF ldap password  $LDAP_PASSWORD | 
|  | 104 | iniset $KEYSTONE_CONF ldap user "dc=Manager,dc=openstack,dc=org" | 
|  | 105 | iniset $KEYSTONE_CONF ldap suffix "dc=openstack,dc=org" | 
| Brad Topol | f41024e | 2013-02-19 15:36:41 -0600 | [diff] [blame] | 106 | iniset $KEYSTONE_CONF ldap use_dumb_member "True" | 
|  | 107 | iniset $KEYSTONE_CONF ldap user_attribute_ignore "enabled,email,tenants,tenantId" | 
|  | 108 | iniset $KEYSTONE_CONF ldap tenant_attribute_ignore "enabled" | 
|  | 109 | iniset $KEYSTONE_CONF ldap tenant_domain_id_attribute "businessCategory" | 
|  | 110 | iniset $KEYSTONE_CONF ldap tenant_desc_attribute "description" | 
|  | 111 | iniset $KEYSTONE_CONF ldap tenant_tree_dn "ou=Projects,dc=openstack,dc=org" | 
|  | 112 | iniset $KEYSTONE_CONF ldap user_domain_id_attribute "businessCategory" | 
|  | 113 | iniset $KEYSTONE_CONF ldap user_tree_dn "ou=Users,dc=openstack,dc=org" | 
|  | 114 | iniset $KEYSTONE_CONF DEFAULT member_role_id "9fe2ff9ee4384b1894a90878d3e92bab" | 
|  | 115 | iniset $KEYSTONE_CONF DEFAULT member_role_name "_member_" | 
| Brad Topol | f127e2f | 2013-01-22 10:17:50 -0600 | [diff] [blame] | 116 | fi | 
|  | 117 |  | 
|  | 118 | if [[  "$KEYSTONE_IDENTITY_BACKEND" == "ldap"  ]]; then | 
|  | 119 | iniset $KEYSTONE_CONF identity driver "keystone.identity.backends.ldap.Identity" | 
|  | 120 | fi | 
|  | 121 |  | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 122 | if is_service_enabled tls-proxy; then | 
|  | 123 | # Set the service ports for a proxy to take the originals | 
|  | 124 | iniset $KEYSTONE_CONF DEFAULT public_port $KEYSTONE_SERVICE_PORT_INT | 
|  | 125 | iniset $KEYSTONE_CONF DEFAULT admin_port $KEYSTONE_AUTH_PORT_INT | 
|  | 126 | fi | 
|  | 127 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 128 | iniset $KEYSTONE_CONF DEFAULT admin_token "$SERVICE_TOKEN" | 
| Doug Hellmann | 4de55e9 | 2012-10-26 12:24:28 -0400 | [diff] [blame] | 129 | iniset $KEYSTONE_CONF signing token_format "$KEYSTONE_TOKEN_FORMAT" | 
| Attila Fazekas | 7e79d91 | 2013-03-03 12:23:04 +0100 | [diff] [blame] | 130 | iniset $KEYSTONE_CONF sql connection `database_connection_url keystone` | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 131 | iniset $KEYSTONE_CONF ec2 driver "keystone.contrib.ec2.backends.sql.Ec2" | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 132 |  | 
| Davanum Srinivas | 5bd96f9 | 2013-01-29 15:12:20 -0500 | [diff] [blame] | 133 | if [[ "$KEYSTONE_TOKEN_BACKEND" = "sql" ]]; then | 
|  | 134 | iniset $KEYSTONE_CONF token driver keystone.token.backends.sql.Token | 
|  | 135 | else | 
|  | 136 | iniset $KEYSTONE_CONF token driver keystone.token.backends.kvs.Token | 
|  | 137 | fi | 
|  | 138 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 139 | if [[ "$KEYSTONE_CATALOG_BACKEND" = "sql" ]]; then | 
|  | 140 | # Configure ``keystone.conf`` to use sql | 
|  | 141 | iniset $KEYSTONE_CONF catalog driver keystone.catalog.backends.sql.Catalog | 
|  | 142 | inicomment $KEYSTONE_CONF catalog template_file | 
|  | 143 | else | 
|  | 144 | cp -p $FILES/default_catalog.templates $KEYSTONE_CATALOG | 
|  | 145 |  | 
|  | 146 | # Add swift endpoints to service catalog if swift is enabled | 
| Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 147 | if is_service_enabled s-proxy; then | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 148 | echo "catalog.RegionOne.object_store.publicURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG | 
|  | 149 | echo "catalog.RegionOne.object_store.adminURL = http://%SERVICE_HOST%:8080/" >> $KEYSTONE_CATALOG | 
|  | 150 | echo "catalog.RegionOne.object_store.internalURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG | 
|  | 151 | echo "catalog.RegionOne.object_store.name = Swift Service" >> $KEYSTONE_CATALOG | 
|  | 152 | fi | 
|  | 153 |  | 
|  | 154 | # Add quantum endpoints to service catalog if quantum is enabled | 
|  | 155 | if is_service_enabled quantum; then | 
|  | 156 | echo "catalog.RegionOne.network.publicURL = http://%SERVICE_HOST%:$Q_PORT/" >> $KEYSTONE_CATALOG | 
|  | 157 | echo "catalog.RegionOne.network.adminURL = http://%SERVICE_HOST%:$Q_PORT/" >> $KEYSTONE_CATALOG | 
|  | 158 | echo "catalog.RegionOne.network.internalURL = http://%SERVICE_HOST%:$Q_PORT/" >> $KEYSTONE_CATALOG | 
|  | 159 | echo "catalog.RegionOne.network.name = Quantum Service" >> $KEYSTONE_CATALOG | 
|  | 160 | fi | 
|  | 161 |  | 
| Vincent Untz | 7e86dbe | 2012-12-13 08:50:37 +0100 | [diff] [blame] | 162 | sed -e " | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 163 | s,%SERVICE_HOST%,$SERVICE_HOST,g; | 
|  | 164 | s,%S3_SERVICE_PORT%,$S3_SERVICE_PORT,g; | 
|  | 165 | " -i $KEYSTONE_CATALOG | 
|  | 166 |  | 
|  | 167 | # Configure ``keystone.conf`` to use templates | 
|  | 168 | iniset $KEYSTONE_CONF catalog driver "keystone.catalog.backends.templated.TemplatedCatalog" | 
|  | 169 | iniset $KEYSTONE_CONF catalog template_file "$KEYSTONE_CATALOG" | 
|  | 170 | fi | 
|  | 171 |  | 
|  | 172 | # Set up logging | 
|  | 173 | LOGGING_ROOT="devel" | 
|  | 174 | if [ "$SYSLOG" != "False" ]; then | 
|  | 175 | LOGGING_ROOT="$LOGGING_ROOT,production" | 
|  | 176 | fi | 
|  | 177 | KEYSTONE_LOG_CONFIG="--log-config $KEYSTONE_CONF_DIR/logging.conf" | 
|  | 178 | cp $KEYSTONE_DIR/etc/logging.conf.sample $KEYSTONE_CONF_DIR/logging.conf | 
|  | 179 | iniset $KEYSTONE_CONF_DIR/logging.conf logger_root level "DEBUG" | 
|  | 180 | iniset $KEYSTONE_CONF_DIR/logging.conf logger_root handlers "devel,production" | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 181 | } | 
|  | 182 |  | 
| Dean Troyer | d835de8 | 2012-11-29 17:11:35 -0600 | [diff] [blame] | 183 | # create_keystone_accounts() - Sets up common required keystone accounts | 
|  | 184 |  | 
|  | 185 | # Tenant               User       Roles | 
|  | 186 | # ------------------------------------------------------------------ | 
|  | 187 | # service              --         -- | 
|  | 188 | # --                   --         Member | 
|  | 189 | # admin                admin      admin | 
|  | 190 | # demo                 admin      admin | 
|  | 191 | # demo                 demo       Member, anotherrole | 
|  | 192 | # invisible_to_admin   demo       Member | 
|  | 193 |  | 
|  | 194 | # Migrated from keystone_data.sh | 
|  | 195 | create_keystone_accounts() { | 
|  | 196 |  | 
|  | 197 | # admin | 
|  | 198 | ADMIN_TENANT=$(keystone tenant-create \ | 
|  | 199 | --name admin \ | 
|  | 200 | | grep " id " | get_field 2) | 
|  | 201 | ADMIN_USER=$(keystone user-create \ | 
|  | 202 | --name admin \ | 
|  | 203 | --pass "$ADMIN_PASSWORD" \ | 
|  | 204 | --email admin@example.com \ | 
|  | 205 | | grep " id " | get_field 2) | 
|  | 206 | ADMIN_ROLE=$(keystone role-create \ | 
|  | 207 | --name admin \ | 
|  | 208 | | grep " id " | get_field 2) | 
|  | 209 | keystone user-role-add \ | 
|  | 210 | --user_id $ADMIN_USER \ | 
|  | 211 | --role_id $ADMIN_ROLE \ | 
|  | 212 | --tenant_id $ADMIN_TENANT | 
|  | 213 |  | 
|  | 214 | # service | 
|  | 215 | SERVICE_TENANT=$(keystone tenant-create \ | 
|  | 216 | --name $SERVICE_TENANT_NAME \ | 
|  | 217 | | grep " id " | get_field 2) | 
|  | 218 |  | 
|  | 219 | # The Member role is used by Horizon and Swift so we need to keep it: | 
|  | 220 | MEMBER_ROLE=$(keystone role-create --name=Member | grep " id " | get_field 2) | 
|  | 221 | # ANOTHER_ROLE demonstrates that an arbitrary role may be created and used | 
|  | 222 | # TODO(sleepsonthefloor): show how this can be used for rbac in the future! | 
|  | 223 | ANOTHER_ROLE=$(keystone role-create --name=anotherrole | grep " id " | get_field 2) | 
|  | 224 |  | 
|  | 225 | # invisible tenant - admin can't see this one | 
|  | 226 | INVIS_TENANT=$(keystone tenant-create --name=invisible_to_admin | grep " id " | get_field 2) | 
|  | 227 |  | 
|  | 228 | # demo | 
|  | 229 | DEMO_TENANT=$(keystone tenant-create \ | 
|  | 230 | --name=demo \ | 
|  | 231 | | grep " id " | get_field 2) | 
|  | 232 | DEMO_USER=$(keystone user-create \ | 
|  | 233 | --name demo \ | 
|  | 234 | --pass "$ADMIN_PASSWORD" \ | 
|  | 235 | --email demo@example.com \ | 
|  | 236 | | grep " id " | get_field 2) | 
|  | 237 | keystone user-role-add --user_id $DEMO_USER --role_id $MEMBER_ROLE --tenant_id $DEMO_TENANT | 
|  | 238 | keystone user-role-add --user_id $ADMIN_USER --role_id $ADMIN_ROLE --tenant_id $DEMO_TENANT | 
|  | 239 | keystone user-role-add --user_id $DEMO_USER --role_id $ANOTHER_ROLE --tenant_id $DEMO_TENANT | 
|  | 240 | keystone user-role-add --user_id $DEMO_USER --role_id $MEMBER_ROLE --tenant_id $INVIS_TENANT | 
|  | 241 |  | 
|  | 242 | # Keystone | 
|  | 243 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then | 
|  | 244 | KEYSTONE_SERVICE=$(keystone service-create \ | 
|  | 245 | --name keystone \ | 
|  | 246 | --type identity \ | 
|  | 247 | --description "Keystone Identity Service" \ | 
|  | 248 | | grep " id " | get_field 2) | 
|  | 249 | keystone endpoint-create \ | 
|  | 250 | --region RegionOne \ | 
|  | 251 | --service_id $KEYSTONE_SERVICE \ | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 252 | --publicurl "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0" \ | 
|  | 253 | --adminurl "$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0" \ | 
|  | 254 | --internalurl "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0" | 
| Dean Troyer | d835de8 | 2012-11-29 17:11:35 -0600 | [diff] [blame] | 255 | fi | 
| Dean Troyer | d835de8 | 2012-11-29 17:11:35 -0600 | [diff] [blame] | 256 | } | 
|  | 257 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 258 | # init_keystone() - Initialize databases, etc. | 
|  | 259 | function init_keystone() { | 
|  | 260 | # (Re)create keystone database | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 261 | recreate_database keystone utf8 | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 262 |  | 
|  | 263 | # Initialize keystone database | 
|  | 264 | $KEYSTONE_DIR/bin/keystone-manage db_sync | 
|  | 265 |  | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 266 | if [[ "$KEYSTONE_TOKEN_FORMAT" == "PKI" ]]; then | 
|  | 267 | # Set up certificates | 
| Vishvananda Ishaya | 23431f3 | 2012-12-12 15:57:33 -0800 | [diff] [blame] | 268 | rm -rf $KEYSTONE_CONF_DIR/ssl | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 269 | $KEYSTONE_DIR/bin/keystone-manage pki_setup | 
|  | 270 |  | 
|  | 271 | # Create cache dir | 
|  | 272 | sudo mkdir -p $KEYSTONE_AUTH_CACHE_DIR | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 273 | sudo chown $STACK_USER $KEYSTONE_AUTH_CACHE_DIR | 
| Vishvananda Ishaya | 23431f3 | 2012-12-12 15:57:33 -0800 | [diff] [blame] | 274 | rm -f $KEYSTONE_AUTH_CACHE_DIR/* | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 275 | fi | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 276 | } | 
|  | 277 |  | 
|  | 278 | # install_keystoneclient() - Collect source and prepare | 
|  | 279 | function install_keystoneclient() { | 
|  | 280 | git_clone $KEYSTONECLIENT_REPO $KEYSTONECLIENT_DIR $KEYSTONECLIENT_BRANCH | 
| Sean Dague | 1b4b4be | 2013-04-01 16:44:31 -0400 | [diff] [blame] | 281 | setup_develop $KEYSTONECLIENT_DIR | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 282 | } | 
|  | 283 |  | 
|  | 284 | # install_keystone() - Collect source and prepare | 
|  | 285 | function install_keystone() { | 
| Brad Topol | f127e2f | 2013-01-22 10:17:50 -0600 | [diff] [blame] | 286 | # only install ldap if the service has been enabled | 
|  | 287 | if is_service_enabled ldap; then | 
|  | 288 | install_ldap | 
|  | 289 | fi | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 290 | git_clone $KEYSTONE_REPO $KEYSTONE_DIR $KEYSTONE_BRANCH | 
| Sean Dague | 1b4b4be | 2013-04-01 16:44:31 -0400 | [diff] [blame] | 291 | setup_develop $KEYSTONE_DIR | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 292 | } | 
|  | 293 |  | 
|  | 294 | # start_keystone() - Start running processes, including screen | 
|  | 295 | function start_keystone() { | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 296 | # Get right service port for testing | 
|  | 297 | local service_port=$KEYSTONE_SERVICE_PORT | 
|  | 298 | if is_service_enabled tls-proxy; then | 
|  | 299 | service_port=$KEYSTONE_SERVICE_PORT_INT | 
|  | 300 | fi | 
|  | 301 |  | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 302 | # Start Keystone in a screen window | 
|  | 303 | screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug" | 
| Dean Troyer | d835de8 | 2012-11-29 17:11:35 -0600 | [diff] [blame] | 304 | echo "Waiting for keystone to start..." | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 305 | if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= curl -s http://$SERVICE_HOST:$service_port/v2.0/ >/dev/null; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 306 | die $LINENO "keystone did not start" | 
| Dean Troyer | d835de8 | 2012-11-29 17:11:35 -0600 | [diff] [blame] | 307 | fi | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 308 |  | 
|  | 309 | # Start proxies if enabled | 
|  | 310 | if is_service_enabled tls-proxy; then | 
|  | 311 | start_tls_proxy '*' $KEYSTONE_SERVICE_PORT $KEYSTONE_SERVICE_HOST $KEYSTONE_SERVICE_PORT_INT & | 
|  | 312 | start_tls_proxy '*' $KEYSTONE_AUTH_PORT $KEYSTONE_AUTH_HOST $KEYSTONE_AUTH_PORT_INT & | 
|  | 313 | fi | 
| Dean Troyer | d81a027 | 2012-08-31 18:04:55 -0500 | [diff] [blame] | 314 | } | 
|  | 315 |  | 
|  | 316 | # stop_keystone() - Stop running processes | 
|  | 317 | function stop_keystone() { | 
|  | 318 | # Kill the Keystone screen window | 
|  | 319 | screen -S $SCREEN_NAME -p key -X kill | 
|  | 320 | } | 
| Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 321 |  | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 322 |  | 
| Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 323 | # Restore xtrace | 
|  | 324 | $XTRACE | 
| Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 325 |  | 
|  | 326 | # Local variables: | 
|  | 327 | # mode: shell-script | 
|  | 328 | # End: |