Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 2 | # Tenants |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 3 | export SERVICE_TOKEN=$SERVICE_TOKEN |
| 4 | export SERVICE_ENDPOINT=$SERVICE_ENDPOINT |
| 5 | |
| 6 | function get_id () { |
| 7 | echo `$@ | grep id | awk '{print $4}'` |
| 8 | } |
| 9 | |
| 10 | ADMIN_TENANT=`get_id keystone tenant-create --name=admin` |
| 11 | DEMO_TENANT=`get_id keystone tenant-create --name=demo` |
| 12 | INVIS_TENANT=`get_id keystone tenant-create --name=invisible_to_admin` |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 13 | |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 14 | |
| 15 | # Users |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 16 | ADMIN_USER=`get_id keystone user-create \ |
| 17 | --name=admin \ |
| 18 | --pass="$ADMIN_PASSWORD" \ |
| 19 | --email=admin@example.com` |
| 20 | DEMO_USER=`get_id keystone user-create \ |
| 21 | --name=demo \ |
| 22 | --pass="$ADMIN_PASSWORD" \ |
| 23 | --email=admin@example.com` |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 24 | |
| 25 | # Roles |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 26 | ADMIN_ROLE=`get_id keystone role-create --name=admin` |
| 27 | MEMBER_ROLE=`get_id keystone role-create --name=Member` |
| 28 | KEYSTONEADMIN_ROLE=`get_id keystone role-create --name=KeystoneAdmin` |
| 29 | KEYSTONESERVICE_ROLE=`get_id keystone role-create --name=KeystoneServiceAdmin` |
| 30 | SYSADMIN_ROLE=`get_id keystone role-create --name=sysadmin` |
| 31 | NETADMIN_ROLE=`get_id keystone role-create --name=netadmin` |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 32 | |
| 33 | |
| 34 | # Add Roles to Users in Tenants |
| 35 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 36 | keystone add-user-role $ADMIN_USER $ADMIN_ROLE $ADMIN_TENANT |
| 37 | keystone add-user-role $DEMO_USER $MEMBER_ROLE $DEMO_TENANT |
| 38 | keystone add-user-role $DEMO_USER $SYSADMIN_ROLE $DEMO_TENANT |
| 39 | keystone add-user-role $DEMO_USER $NETADMIN_ROLE $DEMO_TENANT |
| 40 | keystone add-user-role $DEMO_USER $MEMBER_ROLE $INVIS_TENANT |
| 41 | keystone add-user-role $ADMIN_USER $ADMIN_ROLE $DEMO_TENANT |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 42 | |
| 43 | # TODO(termie): these two might be dubious |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 44 | keystone add-user-role $ADMIN_USER $KEYSTONEADMIN_ROLE $ADMIN_TENANT |
| 45 | keystone add-user-role $ADMIN_USER $KEYSTONESERVICE_ROLE $ADMIN_TENANT |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 46 | |
Anthony Young | 8bdc263 | 2011-09-22 08:00:44 +0000 | [diff] [blame] | 47 | # Services |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 48 | keystone service-create \ |
| 49 | --name=nova \ |
| 50 | --type=compute \ |
| 51 | --description="Nova Compute Service" |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 52 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 53 | keystone service-create \ |
| 54 | --name=ec2 \ |
| 55 | --type=ec2 \ |
| 56 | --description="EC2 Compatibility Layer" |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 57 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 58 | keystone service-create \ |
| 59 | --name=glance \ |
| 60 | --type=image \ |
| 61 | --description="Glance Image Service" |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 62 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 63 | keystone service-create \ |
| 64 | --name=keystone \ |
| 65 | --type=identity \ |
| 66 | --description="Keystone Identity Service" |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 67 | if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 68 | keystone service-create \ |
| 69 | --name=swift \ |
| 70 | --type="object-store" \ |
| 71 | --description="Swift Service" |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 72 | fi |
Anthony Young | 8bdc263 | 2011-09-22 08:00:44 +0000 | [diff] [blame] | 73 | |
Vishvananda Ishaya | 658ac7a | 2012-02-06 22:56:37 +0000 | [diff] [blame] | 74 | # create ec2 creds and parse the secret and access key returned |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 75 | RESULT=`keystone ec2-create-credentials --tenant_id=$ADMIN_TENANT --user_id=$ADMIN_USER` |
| 76 | echo `$@ | grep id | awk '{print $4}'` |
| 77 | ADMIN_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'` |
| 78 | ADMIN_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'` |
Vishvananda Ishaya | 658ac7a | 2012-02-06 22:56:37 +0000 | [diff] [blame] | 79 | |
| 80 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 81 | RESULT=`keystone ec2-create-credentials --tenant_id=$DEMO_TENANT --user_id=$DEMO_USER` |
| 82 | DEMO_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'` |
| 83 | DEMO_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'` |
Vishvananda Ishaya | 658ac7a | 2012-02-06 22:56:37 +0000 | [diff] [blame] | 84 | |
| 85 | # write the secret and access to ec2rc |
| 86 | cat > $DEVSTACK_DIR/ec2rc <<EOF |
| 87 | ADMIN_ACCESS=$ADMIN_ACCESS |
| 88 | ADMIN_SECRET=$ADMIN_SECRET |
| 89 | DEMO_ACCESS=$DEMO_ACCESS |
| 90 | DEMO_SECRET=$DEMO_SECRET |
| 91 | EOF |