Browse code

create and store secret and access keys

Vishvananda Ishaya authored on 2012/02/07 07:56:37
Showing 5 changed files
... ...
@@ -37,7 +37,7 @@ driver = keystone.token.backends.kvs.Token
37 37
 driver = keystone.policy.backends.simple.SimpleMatch
38 38
 
39 39
 [ec2]
40
-driver = keystone.contrib.ec2.backends.kvs.Ec2
40
+driver = keystone.contrib.ec2.backends.sql.Ec2
41 41
 
42 42
 [filter:debug]
43 43
 paste.filter_factory = keystone.common.wsgi:Debug.factory
... ...
@@ -98,6 +98,25 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
98 98
                                      "description=Swift Service"
99 99
 fi
100 100
 
101
+# create ec2 creds and parse the secret and access key returned
102
+RESULT=`$BIN_DIR/keystone-manage ec2 create user_id=$ADMIN_USER tenant_id=$ADMIN_TENANT`
103
+ADMIN_ACCESS=`echo $RESULT | python -c "import sys; import json; result = json.loads(sys.stdin.read()); print result['access'];"`
104
+ADMIN_SECRET=`echo $RESULT | python -c "import sys; import json; result = json.loads(sys.stdin.read()); print result['secret'];"`
105
+
106
+
107
+RESULT=`$BIN_DIR/keystone-manage ec2 create user_id=$DEMO_USER tenant_id=$DEMO_TENANT`
108
+DEMO_ACCESS=`echo $RESULT | python -c "import sys; import json; result = json.loads(sys.stdin.read()); print result['access'];"`
109
+DEMO_SECRET=`echo $RESULT | python -c "import sys; import json; result = json.loads(sys.stdin.read()); print result['secret'];"`
110
+
111
+# write the secret and access to ec2rc
112
+cat > $DEVSTACK_DIR/ec2rc <<EOF
113
+ADMIN_ACCESS=$ADMIN_ACCESS
114
+ADMIN_SECRET=$ADMIN_SECRET
115
+DEMO_ACCESS=$DEMO_ACCESS
116
+DEMO_SECRET=$DEMO_SECRET
117
+EOF
118
+
119
+
101 120
 #endpointTemplates
102 121
 #$BIN_DIR/keystone-manage $* endpointTemplates add \
103 122
 #      RegionOne nova
... ...
@@ -130,8 +149,3 @@ fi
130 130
 # Tokens
131 131
 #$BIN_DIR/keystone-manage token add %SERVICE_TOKEN% admin admin 2015-02-05T00:00
132 132
 
133
-# EC2 related creds - note we are setting the secret key to ADMIN_PASSWORD
134
-# but keystone doesn't parse them - it is just a blob from keystone's
135
-# point of view
136
-#$BIN_DIR/keystone-manage credentials add admin EC2 'admin' '%ADMIN_PASSWORD%' admin || echo "no support for adding credentials"
137
-#$BIN_DIR/keystone-manage credentials add demo EC2 'demo' '%ADMIN_PASSWORD%' demo || echo "no support for adding credentials"
... ...
@@ -56,10 +56,10 @@ export NOVA_REGION_NAME=${NOVA_REGION_NAME:-RegionOne}
56 56
 export EC2_URL=${EC2_URL:-http://$SERVICE_HOST:8773/services/Cloud}
57 57
 
58 58
 # Access key is set in the initial keystone data to be the same as username
59
-export EC2_ACCESS_KEY=${USERNAME:-demo}
59
+export EC2_ACCESS_KEY=${DEMO_ACCESS}
60 60
 
61 61
 # Secret key is set in the initial keystone data to the admin password
62
-export EC2_SECRET_KEY=${ADMIN_PASSWORD:-secrete}
62
+export EC2_SECRET_KEY=${DEMO_SECRET}
63 63
 
64 64
 # Euca2ools Certificate stuff for uploading bundles
65 65
 # You can get your certs using ./tools/get_certs.sh
... ...
@@ -1398,7 +1398,7 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
1398 1398
     # initialize keystone with default users/endpoints
1399 1399
     pushd $KEYSTONE_DIR
1400 1400
     $KEYSTONE_DIR/bin/keystone-manage db_sync
1401
-    ENABLED_SERVICES=$ENABLED_SERVICES BIN_DIR=$KEYSTONE_DIR/bin bash $KEYSTONE_DATA
1401
+    DEVSTACK_DIR=$TOP_DIR ENABLED_SERVICES=$ENABLED_SERVICES BIN_DIR=$KEYSTONE_DIR/bin bash $KEYSTONE_DATA
1402 1402
     popd
1403 1403
 fi
1404 1404
 
... ...
@@ -76,6 +76,11 @@ case "$LIBVIRT_TYPE" in
76 76
         IMAGE_URLS="http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-uec.tar.gz";;
77 77
 esac
78 78
 
79
+# use stored ec2 env variables
80
+if [ -f ./ec2rc ]; then
81
+    source ./ec2rc
82
+fi
83
+
79 84
 # allow local overrides of env variables
80 85
 if [ -f ./localrc ]; then
81 86
     source ./localrc