ლ(ಠ益ಠლ)

OpenStack Keystone: MySQLdb Import Error

During the configuration of the Keystone identity service on an Ubuntu 14.04.2 LTS host, I observed a missing dependency which is not documented within the generic OpenStack Kilo documentation.

I attempted to populate the Identity service database:

1
$ su -s /bin/sh -c "keystone-manage db_sync" keystone

The result:

1
2
CRITICAL keystone [-] ImportError: No module named MySQLdb
TRACE keystone ImportError: No module named MySQLdb

Install the python-mysqldb package:

1
$ apt-get install python-mysqldb

Now populate the keystone database:

1
$ su -s /bin/sh -c "keystone-manage db_sync" keystone

Error:

1
TRACE keystone OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on 'controller' (110)") None None

Add controller to /etc/hosts:

1
2
# cat /etc/hosts
127.0.0.1       localhost controller

Try to populate the keystone database (again):

1
$ su -s /bin/sh -c "keystone-manage db_sync" keystone

Success! You should now see a default set of tables pushed into the keystone database:

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
mysql> use keystone;
Database changed

mysql> show tables;
+-----------------------+
| Tables_in_keystone    |
+-----------------------+
| assignment            |
| credential            |
| domain                |
| endpoint              |
| group                 |
| migrate_version       |
| policy                |
| project               |
| region                |
| role                  |
| service               |
| token                 |
| trust                 |
| trust_role            |
| user                  |
| user_group_membership |
+-----------------------+
16 rows in set (0.00 sec)

For reference, my personal keystone configuration changes, consistent with the Kilo documentation–sensitive tokens have been redacted:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ diff -U0 /etc/keystone/keystone.conf.orig /etc/keystone/keystone.conf
--- /etc/keystone/keystone.conf.orig 2015-06-23 20:12:22.000000000 -0500
+++ /etc/keystone/keystone.conf 2015-07-30 02:41:46.499812802 -0500
@@ -13 +13 @@
-#admin_token=ADMIN
+admin_token=XXX
@@ -385,0 +386 @@
+verbose = True
@@ -626 +627,2 @@
-connection = sqlite:////var/lib/keystone/keystone.db
+#connection = sqlite:////var/lib/keystone/keystone.db
+connection = mysql://keystone:[email protected]/keystone
@@ -1176,0 +1179 @@
+driver = keystone.contrib.revoke.backends.sql.Revoke
@@ -1295,0 +1299 @@
+provider = keystone.token.providers.uuid.Provider
@@ -1298,0 +1303 @@
+driver = keystone.token.persistence.backends.memcache.Token

Mentally brace yourself for further gaps in the generic OpenStack documentation.

Comments