From cbea3447c7d1f20e58d6deabc1c0fe28918ecab2 Mon Sep 17 00:00:00 2001 From: ihrachyshka Date: Sat, 28 Jun 2014 18:09:54 +0200 Subject: [PATCH] Add ability to switch database driver Also added mysqlconnector packages into default installation. blueprint enable-mysql-connector Change-Id: Ib2cda7cb183dc8f0ff4759cc6e9ecab469fd121c --- files/apts/keystone | 1 + files/apts/neutron | 1 + files/apts/nova | 1 + files/rpms-suse/keystone | 1 + files/rpms-suse/neutron | 1 + files/rpms-suse/nova | 1 + files/rpms/neutron | 1 + files/rpms/nova | 1 + lib/database | 10 +++++++++- stackrc | 12 ++++++++++++ 10 files changed, 29 insertions(+), 1 deletion(-) diff --git a/files/apts/keystone b/files/apts/keystone index b7218b7890..d316a4291b 100644 --- a/files/apts/keystone +++ b/files/apts/keystone @@ -6,6 +6,7 @@ sqlite3 python-pysqlite2 python-sqlalchemy python-mysqldb +python-mysql.connector python-webob python-greenlet python-routes diff --git a/files/apts/neutron b/files/apts/neutron index 92e0a06261..d3a08c77a1 100644 --- a/files/apts/neutron +++ b/files/apts/neutron @@ -15,6 +15,7 @@ python-kombu python-eventlet python-sqlalchemy python-mysqldb +python-mysql.connector python-pyudev python-qpid # dist:precise dnsmasq-base diff --git a/files/apts/nova b/files/apts/nova index e7798491ef..090ca4d48d 100644 --- a/files/apts/nova +++ b/files/apts/nova @@ -6,6 +6,7 @@ parted iputils-arping mysql-server # NOPRIME python-mysqldb +python-mysql.connector python-xattr # needed for glance which is needed for nova --- this shouldn't be here python-lxml # needed for glance which is needed for nova --- this shouldn't be here gawk diff --git a/files/rpms-suse/keystone b/files/rpms-suse/keystone index 403d82f926..a734cb9d09 100644 --- a/files/rpms-suse/keystone +++ b/files/rpms-suse/keystone @@ -10,5 +10,6 @@ python-devel python-greenlet python-lxml python-mysql +python-mysql.connector python-pysqlite sqlite3 diff --git a/files/rpms-suse/neutron b/files/rpms-suse/neutron index f3bafc7a6d..79f5bff7ce 100644 --- a/files/rpms-suse/neutron +++ b/files/rpms-suse/neutron @@ -10,6 +10,7 @@ python-greenlet python-iso8601 python-kombu python-mysql +python-mysql.connector python-Paste python-PasteDeploy python-pyudev diff --git a/files/rpms-suse/nova b/files/rpms-suse/nova index 7a1160e319..2a210e500c 100644 --- a/files/rpms-suse/nova +++ b/files/rpms-suse/nova @@ -35,6 +35,7 @@ python-lockfile python-lxml # needed for glance which is needed for nova --- this shouldn't be here python-mox python-mysql +python-mysql.connector python-numpy # needed by websockify for spice console python-paramiko python-sqlalchemy-migrate diff --git a/files/rpms/neutron b/files/rpms/neutron index f02c02bd16..aaff48ae4c 100644 --- a/files/rpms/neutron +++ b/files/rpms/neutron @@ -4,6 +4,7 @@ dnsmasq-utils # for dhcp_release ebtables iptables iputils +mysql-connector-python mysql-server # NOPRIME openvswitch # NOPRIME python-boto diff --git a/files/rpms/nova b/files/rpms/nova index 6097991a9a..ccee8a73b1 100644 --- a/files/rpms/nova +++ b/files/rpms/nova @@ -15,6 +15,7 @@ libvirt-python # NOPRIME libxml2-python numpy # needed by websockify for spice console m2crypto +mysql-connector-python mysql-server # NOPRIME parted polkit diff --git a/lib/database b/lib/database index 0661049e70..e226515347 100644 --- a/lib/database +++ b/lib/database @@ -89,7 +89,7 @@ function initialize_database_backends { # a multi-node DevStack installation. # NOTE: Don't specify ``/db`` in this string so we can use it for multiple services - BASE_SQL_CONN=${BASE_SQL_CONN:-${DATABASE_TYPE}://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST} + BASE_SQL_CONN=${BASE_SQL_CONN:-$(get_database_type)://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST} return 0 } @@ -120,6 +120,14 @@ function database_connection_url { database_connection_url_$DATABASE_TYPE $db } +function get_database_type { + if [[ -n "${SQLALCHEMY_DATABASE_DRIVER}" ]]; then + echo "${DATABASE_TYPE}+${SQLALCHEMY_DATABASE_DRIVER}" + else + echo "${DATABASE_TYPE}" + fi +} + # Restore xtrace $XTRACE diff --git a/stackrc b/stackrc index fb843666b0..a8467bab98 100644 --- a/stackrc +++ b/stackrc @@ -52,6 +52,18 @@ if [[ -z "$ENABLED_SERVICES" ]]; then ENABLED_SERVICES+=,rabbit,tempest,mysql fi +# SQLAlchemy supports multiple database drivers for each database server +# type. For example, deployer may use MySQLdb, MySQLConnector, or oursql +# to access MySQL database. +# +# When defined, the variable controls which database driver is used to +# connect to database server. Otherwise using default driver defined for +# each database type. +# +# You can find the list of currently supported drivers for each database +# type at: http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html +# SQLALCHEMY_DATABASE_DRIVER="mysqldb" + # Global toggle for enabling services under mod_wsgi. If this is set to # ``True`` all services that use HTTPD + mod_wsgi as the preferred method of # deployment, will be deployed under Apache. If this is set to ``False`` all