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 |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 35 | keystone add-user-role $ADMIN_USER $ADMIN_ROLE $ADMIN_TENANT |
| 36 | keystone add-user-role $DEMO_USER $MEMBER_ROLE $DEMO_TENANT |
| 37 | keystone add-user-role $DEMO_USER $SYSADMIN_ROLE $DEMO_TENANT |
| 38 | keystone add-user-role $DEMO_USER $NETADMIN_ROLE $DEMO_TENANT |
| 39 | keystone add-user-role $DEMO_USER $MEMBER_ROLE $INVIS_TENANT |
| 40 | keystone add-user-role $ADMIN_USER $ADMIN_ROLE $DEMO_TENANT |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 41 | |
| 42 | # TODO(termie): these two might be dubious |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 43 | keystone add-user-role $ADMIN_USER $KEYSTONEADMIN_ROLE $ADMIN_TENANT |
| 44 | keystone add-user-role $ADMIN_USER $KEYSTONESERVICE_ROLE $ADMIN_TENANT |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 45 | |
Anthony Young | 8bdc263 | 2011-09-22 08:00:44 +0000 | [diff] [blame] | 46 | # Services |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 47 | keystone service-create \ |
| 48 | --name=nova \ |
| 49 | --type=compute \ |
| 50 | --description="Nova Compute Service" |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 51 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 52 | keystone service-create \ |
| 53 | --name=ec2 \ |
| 54 | --type=ec2 \ |
| 55 | --description="EC2 Compatibility Layer" |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 56 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 57 | keystone service-create \ |
| 58 | --name=glance \ |
| 59 | --type=image \ |
| 60 | --description="Glance Image Service" |
termie | a96a418 | 2012-01-09 22:13:29 -0800 | [diff] [blame] | 61 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 62 | keystone service-create \ |
| 63 | --name=keystone \ |
| 64 | --type=identity \ |
| 65 | --description="Keystone Identity Service" |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 66 | if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 67 | keystone service-create \ |
| 68 | --name=swift \ |
| 69 | --type="object-store" \ |
| 70 | --description="Swift Service" |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 71 | fi |
Gabriel Hurley | a3a496f | 2012-02-13 12:29:23 -0800 | [diff] [blame^] | 72 | if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then |
| 73 | keystone service-create \ |
| 74 | --name=quantum \ |
| 75 | --type=network \ |
| 76 | --description="Quantum Service" |
| 77 | fi |
Anthony Young | 8bdc263 | 2011-09-22 08:00:44 +0000 | [diff] [blame] | 78 | |
Vishvananda Ishaya | 658ac7a | 2012-02-06 22:56:37 +0000 | [diff] [blame] | 79 | # create ec2 creds and parse the secret and access key returned |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 80 | RESULT=`keystone ec2-create-credentials --tenant_id=$ADMIN_TENANT --user_id=$ADMIN_USER` |
| 81 | echo `$@ | grep id | awk '{print $4}'` |
| 82 | ADMIN_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'` |
| 83 | ADMIN_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'` |
Vishvananda Ishaya | 658ac7a | 2012-02-06 22:56:37 +0000 | [diff] [blame] | 84 | |
| 85 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 86 | RESULT=`keystone ec2-create-credentials --tenant_id=$DEMO_TENANT --user_id=$DEMO_USER` |
| 87 | DEMO_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'` |
| 88 | DEMO_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'` |
Vishvananda Ishaya | 658ac7a | 2012-02-06 22:56:37 +0000 | [diff] [blame] | 89 | |
| 90 | # write the secret and access to ec2rc |
| 91 | cat > $DEVSTACK_DIR/ec2rc <<EOF |
| 92 | ADMIN_ACCESS=$ADMIN_ACCESS |
| 93 | ADMIN_SECRET=$ADMIN_SECRET |
| 94 | DEMO_ACCESS=$DEMO_ACCESS |
| 95 | DEMO_SECRET=$DEMO_SECRET |
| 96 | EOF |