blob: cc2421c9a10e85531cf1d73afad128f463f60f34 [file] [log] [blame]
Jesse Andrews73e27b82011-09-12 17:55:00 -07001#!/bin/bash
Jesse Andrews73e27b82011-09-12 17:55:00 -07002# Tenants
Vishvananda Ishayad1f52432012-02-09 03:50:57 +00003export SERVICE_TOKEN=$SERVICE_TOKEN
4export SERVICE_ENDPOINT=$SERVICE_ENDPOINT
5
6function get_id () {
7 echo `$@ | grep id | awk '{print $4}'`
8}
9
10ADMIN_TENANT=`get_id keystone tenant-create --name=admin`
11DEMO_TENANT=`get_id keystone tenant-create --name=demo`
12INVIS_TENANT=`get_id keystone tenant-create --name=invisible_to_admin`
termiea96a4182012-01-09 22:13:29 -080013
Jesse Andrews73e27b82011-09-12 17:55:00 -070014
15# Users
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000016ADMIN_USER=`get_id keystone user-create \
17 --name=admin \
18 --pass="$ADMIN_PASSWORD" \
19 --email=admin@example.com`
20DEMO_USER=`get_id keystone user-create \
21 --name=demo \
22 --pass="$ADMIN_PASSWORD" \
23 --email=admin@example.com`
Jesse Andrews73e27b82011-09-12 17:55:00 -070024
25# Roles
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000026ADMIN_ROLE=`get_id keystone role-create --name=admin`
27MEMBER_ROLE=`get_id keystone role-create --name=Member`
28KEYSTONEADMIN_ROLE=`get_id keystone role-create --name=KeystoneAdmin`
29KEYSTONESERVICE_ROLE=`get_id keystone role-create --name=KeystoneServiceAdmin`
30SYSADMIN_ROLE=`get_id keystone role-create --name=sysadmin`
31NETADMIN_ROLE=`get_id keystone role-create --name=netadmin`
termiea96a4182012-01-09 22:13:29 -080032
33
34# Add Roles to Users in Tenants
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000035keystone add-user-role $ADMIN_USER $ADMIN_ROLE $ADMIN_TENANT
36keystone add-user-role $DEMO_USER $MEMBER_ROLE $DEMO_TENANT
37keystone add-user-role $DEMO_USER $SYSADMIN_ROLE $DEMO_TENANT
38keystone add-user-role $DEMO_USER $NETADMIN_ROLE $DEMO_TENANT
39keystone add-user-role $DEMO_USER $MEMBER_ROLE $INVIS_TENANT
40keystone add-user-role $ADMIN_USER $ADMIN_ROLE $DEMO_TENANT
termiea96a4182012-01-09 22:13:29 -080041
42# TODO(termie): these two might be dubious
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000043keystone add-user-role $ADMIN_USER $KEYSTONEADMIN_ROLE $ADMIN_TENANT
44keystone add-user-role $ADMIN_USER $KEYSTONESERVICE_ROLE $ADMIN_TENANT
Jesse Andrews73e27b82011-09-12 17:55:00 -070045
Anthony Young8bdc2632011-09-22 08:00:44 +000046# Services
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000047keystone service-create \
48 --name=nova \
49 --type=compute \
50 --description="Nova Compute Service"
termiea96a4182012-01-09 22:13:29 -080051
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000052keystone service-create \
53 --name=ec2 \
54 --type=ec2 \
55 --description="EC2 Compatibility Layer"
termiea96a4182012-01-09 22:13:29 -080056
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000057keystone service-create \
58 --name=glance \
59 --type=image \
60 --description="Glance Image Service"
termiea96a4182012-01-09 22:13:29 -080061
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000062keystone service-create \
63 --name=keystone \
64 --type=identity \
65 --description="Keystone Identity Service"
Jesse Andrews9c7c9082011-11-23 10:10:53 -080066if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000067 keystone service-create \
68 --name=swift \
69 --type="object-store" \
70 --description="Swift Service"
Jesse Andrews9c7c9082011-11-23 10:10:53 -080071fi
Gabriel Hurleya3a496f2012-02-13 12:29:23 -080072if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then
73 keystone service-create \
74 --name=quantum \
75 --type=network \
76 --description="Quantum Service"
77fi
Anthony Young8bdc2632011-09-22 08:00:44 +000078
Vishvananda Ishaya658ac7a2012-02-06 22:56:37 +000079# create ec2 creds and parse the secret and access key returned
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000080RESULT=`keystone ec2-create-credentials --tenant_id=$ADMIN_TENANT --user_id=$ADMIN_USER`
81 echo `$@ | grep id | awk '{print $4}'`
82ADMIN_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'`
83ADMIN_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'`
Vishvananda Ishaya658ac7a2012-02-06 22:56:37 +000084
85
Vishvananda Ishayad1f52432012-02-09 03:50:57 +000086RESULT=`keystone ec2-create-credentials --tenant_id=$DEMO_TENANT --user_id=$DEMO_USER`
87DEMO_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'`
88DEMO_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'`
Vishvananda Ishaya658ac7a2012-02-06 22:56:37 +000089
90# write the secret and access to ec2rc
91cat > $DEVSTACK_DIR/ec2rc <<EOF
92ADMIN_ACCESS=$ADMIN_ACCESS
93ADMIN_SECRET=$ADMIN_SECRET
94DEMO_ACCESS=$DEMO_ACCESS
95DEMO_SECRET=$DEMO_SECRET
96EOF