forked from docc-lab/openstack-build-ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-basic-users.sh
executable file
·65 lines (51 loc) · 1.83 KB
/
setup-basic-users.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
##
## Initialize some basic useful stuff.
##
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 0;
fi
logtstart "basic-users"
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
. $OURDIR/admin-openrc.sh
if [ $GENIUSER -eq 1 ] ; then
echo "*** Importing GENI user keys for admin user..."
$PYTHONBINNAME $DIRNAME/setup-user-info.py
#
# XXX: ugh, this is ugly, but now that we have two admin users, we have
# to create keys for the admin user -- but we upload keys as the adminapi
# user. I can't find a way with the API to upload keys for another user
# (seems very dumb, I must be missing something, but...)... so what we do
# is add the keys once for the adminapi user, change the db manually to
# make those keys be for the admin user, then add the same keys again (for
# the adminapi user). Then both admin users have the keys.
#
if [ -x /usr/bin/keystone ]; then
AAID=`keystone user-get ${ADMIN_API} | awk '/ id / {print $4}'`
AID=`keystone user-get admin | awk '/ id / {print $4}'`
else
AAID=`openstack user show adminapi | awk '/ id / { print $4 }'`
AID=`openstack user show admin | awk '/ id / { print $4 }'`
fi
# Do this for both the nova and nova_api DBs; that has changed over time.
echo "update key_pairs set user_id='$AID' where user_id='$AAID'" \
| mysql -u root --password=${DB_ROOT_PASS} nova
echo "update key_pairs set user_id='$AID' where user_id='$AAID'" \
| mysql -u root --password=${DB_ROOT_PASS} nova_api
# Ok, do it again!
echo "*** Importing GENI user keys, for ${ADMIN_API} user..."
$PYTHONBINNAME $DIRNAME/setup-user-info.py
fi
logtend "basic-users"
exit 0