glance-upgrade revision 4049
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import glob
import time
('DEFAULT', 'db_backend'): ('database', 'backend'),
('DEFAULT', 'sql_connection'): ('database', 'connection'),
('DATABASE', 'sql_connection'): ('database', 'connection'),
('sql', 'connection'): ('database', 'connection'),
('DEFAULT', 'sql_idle_timeout'): ('database', 'idle_timeout'),
('DATABASE', 'sql_idle_timeout'): ('database', 'idle_timeout'),
('sql', 'idle_timeout'): ('database', 'idle_timeout'),
('DEFAULT', 'sql_min_pool_size'): ('database', 'min_pool_size'),
('DATABASE', 'sql_min_pool_size'): ('database', 'min_pool_size'),
('DEFAULT', 'sql_max_pool_size'): ('database', 'max_pool_size'),
('DATABASE', 'sql_max_pool_size'): ('database', 'max_pool_size'),
('DEFAULT', 'sql_max_retries'): ('database', 'max_retries'),
('DATABASE', 'sql_max_retries'): ('database', 'max_retries'),
('DEFAULT', 'sql_retry_interval'): ('database', 'retry_interval'),
('DATABASE', 'reconnect_interval'): ('database', 'retry_interval'),
('DEFAULT', 'sql_max_overflow'): ('database', 'max_overflow'),
('DATABASE', 'sqlalchemy_max_overflow'): ('database', 'max_overflow'),
('DEFAULT', 'sql_connection_debug'): ('database', 'connection_debug'),
('DEFAULT', 'sql_connection_trace'): ('database', 'connection_trace'),
('DATABASE', 'sqlalchemy_pool_timeout'): ('database', 'pool_timeout'),
}
('DEFAULT', 'db_backend'): ('database', 'backend'),
('DEFAULT', 'sql_connection'): ('database', 'connection'),
('DATABASE', 'sql_connection'): ('database', 'connection'),
('sql', 'connection'): ('database', 'connection'),
('DEFAULT', 'sql_idle_timeout'): ('database', 'idle_timeout'),
('DATABASE', 'sql_idle_timeout'): ('database', 'idle_timeout'),
('sql', 'idle_timeout'): ('database', 'idle_timeout'),
('DEFAULT', 'sql_min_pool_size'): ('database', 'min_pool_size'),
('DATABASE', 'sql_min_pool_size'): ('database', 'min_pool_size'),
('DEFAULT', 'sql_max_pool_size'): ('database', 'max_pool_size'),
('DATABASE', 'sql_max_pool_size'): ('database', 'max_pool_size'),
('DEFAULT', 'sql_max_retries'): ('database', 'max_retries'),
('DATABASE', 'sql_max_retries'): ('database', 'max_retries'),
('DEFAULT', 'sql_retry_interval'): ('database', 'retry_interval'),
('DATABASE', 'reconnect_interval'): ('database', 'retry_interval'),
('DEFAULT', 'sql_max_overflow'): ('database', 'max_overflow'),
('DATABASE', 'sqlalchemy_max_overflow'): ('database', 'max_overflow'),
('DEFAULT', 'sql_connection_debug'): ('database', 'connection_debug'),
('DEFAULT', 'sql_connection_trace'): ('database', 'connection_trace'),
('DATABASE', 'sqlalchemy_pool_timeout'): ('database', 'pool_timeout'),
}
""" look for deprecated variables and, if found, convert it to the new
"""
print "Removing from configuration"
else:
""" Convert MySQL tables to use utf8
"""
try:
break
# mysql is not ready. sleep for 2 more seconds
time.sleep(2)
else:
print "Unable to connect to MySQL: %s" % err
print ("Please verify MySQL is properly configured and online "
"before using svcadm(1M) to clear this service.")
if res:
"CHARACTER SET 'utf8', COLLATE 'utf8_general_ci'"
db.close()
""" Copy over all uncommented options from the old configuration file. In
"""
# open the previous version
# open the new version
try:
if err.errno == errno.ENOENT:
# The upgrade did not deliver a .new file so, return
return
else:
print "\nupdating %s" % old_file
# walk every single section for uncommented options
# DEFAULT items show up in every section so remove them
if section != 'DEFAULT':
else:
# keep a copy of the old value
# option is deprecated so continue
continue
if section != 'DEFAULT':
# print to the log when a value for the same section.key is
# changing to a new value
try:
print "Changing [%s] %s:\n- %s\n+ %s" % \
print
# the new configuration file does not have this option set so
# just continue
# Only copy the old value to the new conf file if the entry doesn't
# exist or if it contains '%SERVICE'
# copy the old conf file to a backup
# copy the new conf file in place
# pull out the current version of config/upgrade-id
# extract the openstack-upgrade-id from the pkg
# No need to upgrade
# look for any .new files
# the versions are different, so perform an upgrade
# modify the configuration files
# In certain cases the database section does not exist and the
# default database chosen is sqlite.
if engine.url.username != '%SERVICE_USER%':
print "altered character set to utf8 in glance tables"
# update the current version
if __name__ == '__main__':
try:
print 'Unknown error: %s' % err
print