Browse code

Simplify database_connection_url

* does not expects dynamic scoping.
* does not uses eval.

Change-Id: I5ba4e5b7ffaabbb3c2bddadf9e53a2875de8b7c0

Attila Fazekas authored on 2013/03/03 20:23:04
Showing 9 changed files
... ...
@@ -68,7 +68,7 @@ function configure_ceilometer() {
68 68
 
69 69
     iniset $CEILOMETER_CONF DEFAULT notification_topics 'notifications,glance_notifications'
70 70
     iniset $CEILOMETER_CONF DEFAULT verbose True
71
-    iniset $CEILOMETER_CONF DEFAULT sql_connection $BASE_SQL_CONN/nova?charset=utf8
71
+    iniset $CEILOMETER_CONF DEFAULT `database_connection_url nova`
72 72
 
73 73
     # Install the policy file for the API server
74 74
     cp $CEILOMETER_DIR/etc/ceilometer/policy.json $CEILOMETER_CONF_DIR
... ...
@@ -185,9 +185,7 @@ function configure_cinder() {
185 185
         iniset $CINDER_CONF DEFAULT volume_name_template ${VOLUME_NAME_PREFIX}%s
186 186
     fi
187 187
     iniset $CINDER_CONF DEFAULT iscsi_helper tgtadm
188
-    local dburl
189
-    database_connection_url dburl cinder
190
-    iniset $CINDER_CONF DEFAULT sql_connection $dburl
188
+    iniset $CINDER_CONF DEFAULT sql_connection `database_connection_url cinder`
191 189
     iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI
192 190
     iniset $CINDER_CONF DEFAULT rootwrap_config "$CINDER_CONF_DIR/rootwrap.conf"
193 191
     iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions
... ...
@@ -115,9 +115,8 @@ EOF
115 115
 }
116 116
 
117 117
 function database_connection_url_mysql {
118
-    local output=$1
119
-    local db=$2
120
-    eval "$output=$BASE_SQL_CONN/$db?charset=utf8"
118
+    local db=$1
119
+    echo "$BASE_SQL_CONN/$db?charset=utf8"
121 120
 }
122 121
 
123 122
 # Restore xtrace
... ...
@@ -70,9 +70,8 @@ EOF
70 70
 }
71 71
 
72 72
 function database_connection_url_postgresql {
73
-    local output=$1
74
-    local db=$2
75
-    eval "$output=$BASE_SQL_CONN/$db?client_encoding=utf8"
73
+    local db=$1
74
+    echo "$BASE_SQL_CONN/$db?client_encoding=utf8"
76 75
 }
77 76
 
78 77
 # Restore xtrace
... ...
@@ -81,8 +81,7 @@ function configure_glance() {
81 81
     cp $GLANCE_DIR/etc/glance-registry.conf $GLANCE_REGISTRY_CONF
82 82
     iniset $GLANCE_REGISTRY_CONF DEFAULT debug True
83 83
     inicomment $GLANCE_REGISTRY_CONF DEFAULT log_file
84
-    local dburl
85
-    database_connection_url dburl glance
84
+    local dburl=`database_connection_url glance`
86 85
     iniset $GLANCE_REGISTRY_CONF DEFAULT sql_connection $dburl
87 86
     iniset $GLANCE_REGISTRY_CONF DEFAULT use_syslog $SYSLOG
88 87
     iniset $GLANCE_REGISTRY_CONF paste_deploy flavor keystone
... ...
@@ -117,9 +117,7 @@ function configure_heat() {
117 117
     iniset $HEAT_ENGINE_CONF DEFAULT heat_metadata_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT
118 118
     iniset $HEAT_ENGINE_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition
119 119
     iniset $HEAT_ENGINE_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT
120
-    local dburl
121
-    database_connection_url dburl heat
122
-    iniset $HEAT_ENGINE_CONF DEFAULT sql_connection $dburl
120
+    iniset $HEAT_ENGINE_CONF DEFAULT sql_connection `database_connection_url heat`
123 121
     iniset $HEAT_ENGINE_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random`
124 122
 
125 123
     iniset_rpc_backend heat $HEAT_ENGINE_CONF DEFAULT
... ...
@@ -91,8 +91,6 @@ function configure_keystone() {
91 91
     fi
92 92
 
93 93
     # Rewrite stock ``keystone.conf``
94
-    local dburl
95
-    database_connection_url dburl keystone
96 94
 
97 95
     if is_service_enabled ldap; then
98 96
         #Set all needed ldap values
... ...
@@ -123,7 +121,7 @@ function configure_keystone() {
123 123
 
124 124
     iniset $KEYSTONE_CONF DEFAULT admin_token "$SERVICE_TOKEN"
125 125
     iniset $KEYSTONE_CONF signing token_format "$KEYSTONE_TOKEN_FORMAT"
126
-    iniset $KEYSTONE_CONF sql connection $dburl
126
+    iniset $KEYSTONE_CONF sql connection `database_connection_url keystone`
127 127
     iniset $KEYSTONE_CONF ec2 driver "keystone.contrib.ec2.backends.sql.Ec2"
128 128
     sed -e "
129 129
         /^pipeline.*ec2_extension crud_/s|ec2_extension crud_extension|ec2_extension s3_extension crud_extension|;
... ...
@@ -377,12 +377,9 @@ function create_nova_conf() {
377 377
     iniset $NOVA_CONF DEFAULT s3_port "$S3_SERVICE_PORT"
378 378
     iniset $NOVA_CONF DEFAULT osapi_compute_extension "nova.api.openstack.compute.contrib.standard_extensions"
379 379
     iniset $NOVA_CONF DEFAULT my_ip "$HOST_IP"
380
-    local dburl
381
-    database_connection_url dburl nova
382
-    iniset $NOVA_CONF DEFAULT sql_connection "$dburl"
380
+    iniset $NOVA_CONF DEFAULT sql_connection `database_connection_url nova`
383 381
     if is_baremetal; then
384
-        database_connection_url dburl nova_bm
385
-        iniset $NOVA_CONF baremetal sql_connection $dburl
382
+        iniset $NOVA_CONF baremetal sql_connection `database_connection_url nova_bm`
386 383
     fi
387 384
     iniset $NOVA_CONF DEFAULT libvirt_type "$LIBVIRT_TYPE"
388 385
     iniset $NOVA_CONF DEFAULT libvirt_cpu_mode "none"
... ...
@@ -405,9 +405,7 @@ function _configure_quantum_common() {
405 405
     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
406 406
     cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
407 407
 
408
-    database_connection_url dburl $Q_DB_NAME
409
-    iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection $dburl
410
-    unset dburl
408
+    iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection `database_connection_url $Q_DB_NAME`
411 409
 
412 410
     _quantum_setup_rootwrap
413 411
 }