Browse code

Add ability to switch database driver

Also added mysqlconnector packages into default installation.

blueprint enable-mysql-connector

Change-Id: Ib2cda7cb183dc8f0ff4759cc6e9ecab469fd121c

ihrachyshka authored on 2014/06/29 01:09:54
Showing 10 changed files
... ...
@@ -6,6 +6,7 @@ sqlite3
6 6
 python-pysqlite2
7 7
 python-sqlalchemy
8 8
 python-mysqldb
9
+python-mysql.connector
9 10
 python-webob
10 11
 python-greenlet
11 12
 python-routes
... ...
@@ -15,6 +15,7 @@ python-kombu
15 15
 python-eventlet
16 16
 python-sqlalchemy
17 17
 python-mysqldb
18
+python-mysql.connector
18 19
 python-pyudev
19 20
 python-qpid # dist:precise
20 21
 dnsmasq-base
... ...
@@ -6,6 +6,7 @@ parted
6 6
 iputils-arping
7 7
 mysql-server # NOPRIME
8 8
 python-mysqldb
9
+python-mysql.connector
9 10
 python-xattr # needed for glance which is needed for nova --- this shouldn't be here
10 11
 python-lxml # needed for glance which is needed for nova --- this shouldn't be here
11 12
 gawk
... ...
@@ -10,5 +10,6 @@ python-devel
10 10
 python-greenlet
11 11
 python-lxml
12 12
 python-mysql
13
+python-mysql.connector
13 14
 python-pysqlite
14 15
 sqlite3
... ...
@@ -10,6 +10,7 @@ python-greenlet
10 10
 python-iso8601
11 11
 python-kombu
12 12
 python-mysql
13
+python-mysql.connector
13 14
 python-Paste
14 15
 python-PasteDeploy
15 16
 python-pyudev
... ...
@@ -35,6 +35,7 @@ python-lockfile
35 35
 python-lxml # needed for glance which is needed for nova --- this shouldn't be here
36 36
 python-mox
37 37
 python-mysql
38
+python-mysql.connector
38 39
 python-numpy # needed by websockify for spice console
39 40
 python-paramiko
40 41
 python-sqlalchemy-migrate
... ...
@@ -4,6 +4,7 @@ dnsmasq-utils # for dhcp_release
4 4
 ebtables
5 5
 iptables
6 6
 iputils
7
+mysql-connector-python
7 8
 mysql-server # NOPRIME
8 9
 openvswitch # NOPRIME
9 10
 python-boto
... ...
@@ -15,6 +15,7 @@ libvirt-python # NOPRIME
15 15
 libxml2-python
16 16
 numpy # needed by websockify for spice console
17 17
 m2crypto
18
+mysql-connector-python
18 19
 mysql-server # NOPRIME
19 20
 parted
20 21
 polkit
... ...
@@ -89,7 +89,7 @@ function initialize_database_backends {
89 89
     # a multi-node DevStack installation.
90 90
 
91 91
     # NOTE: Don't specify ``/db`` in this string so we can use it for multiple services
92
-    BASE_SQL_CONN=${BASE_SQL_CONN:-${DATABASE_TYPE}://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST}
92
+    BASE_SQL_CONN=${BASE_SQL_CONN:-$(get_database_type)://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST}
93 93
 
94 94
     return 0
95 95
 }
... ...
@@ -120,6 +120,14 @@ function database_connection_url {
120 120
     database_connection_url_$DATABASE_TYPE $db
121 121
 }
122 122
 
123
+function get_database_type {
124
+    if [[ -n "${SQLALCHEMY_DATABASE_DRIVER}" ]]; then
125
+        echo "${DATABASE_TYPE}+${SQLALCHEMY_DATABASE_DRIVER}"
126
+    else
127
+        echo "${DATABASE_TYPE}"
128
+    fi
129
+}
130
+
123 131
 
124 132
 # Restore xtrace
125 133
 $XTRACE
... ...
@@ -52,6 +52,18 @@ if [[ -z "$ENABLED_SERVICES" ]]; then
52 52
     ENABLED_SERVICES+=,rabbit,tempest,mysql
53 53
 fi
54 54
 
55
+# SQLAlchemy supports multiple database drivers for each database server
56
+# type. For example, deployer may use MySQLdb, MySQLConnector, or oursql
57
+# to access MySQL database.
58
+#
59
+# When defined, the variable controls which database driver is used to
60
+# connect to database server. Otherwise using default driver defined for
61
+# each database type.
62
+#
63
+# You can find the list of currently supported drivers for each database
64
+# type at: http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html
65
+# SQLALCHEMY_DATABASE_DRIVER="mysqldb"
66
+
55 67
 # Global toggle for enabling services under mod_wsgi. If this is set to
56 68
 # ``True`` all services that use HTTPD + mod_wsgi as the preferred method of
57 69
 # deployment, will be deployed under Apache. If this is set to ``False`` all