Browse code

Merge "Enforce UTF-8 encoding when creating databases"

Jenkins authored on 2015/01/21 00:44:07
Showing 14 changed files
... ...
@@ -131,7 +131,7 @@ function configure_tuskar {
131 131
 function init_tuskar {
132 132
 
133 133
     # (re)create tuskar database
134
-    recreate_database tuskar utf8
134
+    recreate_database tuskar
135 135
 
136 136
     tuskar-dbsync --config-file $TUSKAR_CONF
137 137
     create_tuskar_cache_dir
... ...
@@ -265,7 +265,7 @@ function init_ceilometer {
265 265
 
266 266
     if is_service_enabled mysql postgresql; then
267 267
         if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] ; then
268
-            recreate_database ceilometer utf8
268
+            recreate_database ceilometer
269 269
             $CEILOMETER_BIN_DIR/ceilometer-dbsync
270 270
         fi
271 271
     fi
... ...
@@ -387,7 +387,7 @@ function init_cinder {
387 387
 
388 388
     if is_service_enabled $DATABASE_BACKENDS; then
389 389
         # (Re)create cinder database
390
-        recreate_database cinder utf8
390
+        recreate_database cinder
391 391
 
392 392
         # Migrate cinder database
393 393
         $CINDER_BIN_DIR/cinder-manage db sync
... ...
@@ -99,11 +99,9 @@ function initialize_database_backends {
99 99
 
100 100
 # Recreate a given database
101 101
 #  $1 The name of the database
102
-#  $2 The character set/encoding of the database
103 102
 function recreate_database {
104 103
     local db=$1
105
-    local charset=$2
106
-    recreate_database_$DATABASE_TYPE $db $charset
104
+    recreate_database_$DATABASE_TYPE $db
107 105
 }
108 106
 
109 107
 # Install the database
... ...
@@ -58,9 +58,8 @@ function cleanup_database_mysql {
58 58
 
59 59
 function recreate_database_mysql {
60 60
     local db=$1
61
-    local charset=$2
62 61
     mysql -u$DATABASE_USER -p$DATABASE_PASSWORD -h$MYSQL_HOST -e "DROP DATABASE IF EXISTS $db;"
63
-    mysql -u$DATABASE_USER -p$DATABASE_PASSWORD -h$MYSQL_HOST -e "CREATE DATABASE $db CHARACTER SET $charset;"
62
+    mysql -u$DATABASE_USER -p$DATABASE_PASSWORD -h$MYSQL_HOST -e "CREATE DATABASE $db CHARACTER SET utf8;"
64 63
 }
65 64
 
66 65
 function configure_database_mysql {
... ...
@@ -37,10 +37,9 @@ function cleanup_database_postgresql {
37 37
 
38 38
 function recreate_database_postgresql {
39 39
     local db=$1
40
-    local charset=$2
41 40
     # Avoid unsightly error when calling dropdb when the database doesn't exist
42 41
     psql -h$DATABASE_HOST -U$DATABASE_USER -dtemplate1 -c "DROP DATABASE IF EXISTS $db"
43
-    createdb -h $DATABASE_HOST -U$DATABASE_USER -l C -T template0 -E $charset $db
42
+    createdb -h $DATABASE_HOST -U$DATABASE_USER -l C -T template0 -E utf8 $db
44 43
 }
45 44
 
46 45
 function configure_database_postgresql {
... ...
@@ -279,7 +279,7 @@ function init_glance {
279 279
     mkdir -p $GLANCE_CACHE_DIR
280 280
 
281 281
     # (Re)create glance database
282
-    recreate_database glance utf8
282
+    recreate_database glance
283 283
 
284 284
     # Migrate glance database
285 285
     $GLANCE_BIN_DIR/glance-manage db_sync
... ...
@@ -175,7 +175,7 @@ function configure_heat {
175 175
 function init_heat {
176 176
 
177 177
     # (re)create heat database
178
-    recreate_database heat utf8
178
+    recreate_database heat
179 179
 
180 180
     $HEAT_DIR/bin/heat-manage db_sync
181 181
     create_heat_cache_dir
... ...
@@ -386,7 +386,7 @@ function create_ironic_accounts {
386 386
 # init_ironic() - Initialize databases, etc.
387 387
 function init_ironic {
388 388
     # (Re)create  ironic database
389
-    recreate_database ironic utf8
389
+    recreate_database ironic
390 390
 
391 391
     # Migrate ironic database
392 392
     $IRONIC_BIN_DIR/ironic-dbsync --config-file=$IRONIC_CONF_FILE
... ...
@@ -456,7 +456,7 @@ function init_keystone {
456 456
     fi
457 457
 
458 458
     # (Re)create keystone database
459
-    recreate_database keystone utf8
459
+    recreate_database keystone
460 460
 
461 461
     # Initialize keystone database
462 462
     $KEYSTONE_DIR/bin/keystone-manage db_sync
... ...
@@ -592,7 +592,7 @@ function create_neutron_initial_network {
592 592
 
593 593
 # init_neutron() - Initialize databases, etc.
594 594
 function init_neutron {
595
-    recreate_database $Q_DB_NAME utf8
595
+    recreate_database $Q_DB_NAME
596 596
     # Run Neutron db migrations
597 597
     $NEUTRON_BIN_DIR/neutron-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head
598 598
     for svc in fwaas lbaas vpnaas; do
... ...
@@ -628,16 +628,13 @@ function init_nova {
628 628
     # Only do this step once on the API node for an entire cluster.
629 629
     if is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-api; then
630 630
         # (Re)create nova database
631
-        # Explicitly use latin1: to avoid lp#829209, nova expects the database to
632
-        # use latin1 by default, and then upgrades the database to utf8 (see the
633
-        # 082_essex.py in nova)
634
-        recreate_database nova latin1
631
+        recreate_database nova
635 632
 
636 633
         # Migrate nova database
637 634
         $NOVA_BIN_DIR/nova-manage db sync
638 635
 
639 636
         if is_service_enabled n-cell; then
640
-            recreate_database $NOVA_CELLS_DB latin1
637
+            recreate_database $NOVA_CELLS_DB
641 638
         fi
642 639
     fi
643 640
 
... ...
@@ -143,7 +143,7 @@ function configure_sahara {
143 143
         setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
144 144
     fi
145 145
 
146
-    recreate_database sahara utf8
146
+    recreate_database sahara
147 147
     $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
148 148
 }
149 149
 
... ...
@@ -199,7 +199,7 @@ function install_trove {
199 199
 # init_trove() - Initializes Trove Database as a Service
200 200
 function init_trove {
201 201
     # (Re)Create trove db
202
-    recreate_database trove utf8
202
+    recreate_database trove
203 203
 
204 204
     # Initialize the trove database
205 205
     $TROVE_BIN_DIR/trove-manage db_sync