PSARC/2015/233 OpenStack Common Package
20866995 glance.images table is corrupted/missing on upgrade from 69 to 71
20984895 Upgrade still fails when the mappings change section to 'None'
20984926 nova-upgrade has multiple deprecation mappings for DEFAULT.sql_connection
20990795 OpenStack upgrade methods should preserve some values from the previous release
20992699 Restore OpenStack upgrade services once upgrade bugs are fixed in s12/s11.3
21085479 An openstack-common package should be added to Userland
21150246 MySQL needs more time to come online
#!/usr/bin/python2.6
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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 os
from subprocess import check_call, Popen, PIPE
import sys
import traceback
import iniparse
import smf_include
import sqlalchemy
from openstack_common import alter_mysql_tables, create_backups, modify_conf
NEUTRON_CONF_MAPPINGS = {
# Deprecated group/name
('DEFAULT', 'rabbit_durable_queues'): ('DEFAULT', 'amqp_durable_queues'),
('rpc_notifier2', 'topics'): ('DEFAULT', 'notification_topics'),
('DEFAULT', 'matchmaker_ringfile'): ('matchmaker_ring', 'ringfile'),
# As of Juno, EVS now uses the standard quota driver
('quotas', 'quota_driver'): (None, None),
}
NEUTRON_CONF_EXCEPTIONS = [
('DEFAULT', 'lockpath'),
('keystone_authtoken', 'auth_uri'),
('keystone_authtoken', 'identity_uri'),
('keystone_authtoken', 'admin_tenant_name'),
('keystone_authtoken', 'admin_user'),
('keystone_authtoken', 'admin_password'),
('keystone_authtoken', 'signing_dir'),
('database', 'connection'),
]
DHCP_AGENT_MAPPINGS = {
# Deprecated group/name
('DEFAULT', 'dnsmasq_dns_server'): ('DEFAULT', 'dnsmasq_dns_servers'),
}
EVS_PLUGIN_MAPPINGS = {
# No longer referenced by the service
('DATABASE', 'sql_connection'): (None, None),
}
L3_AGENT_EXCEPTIONS = [
('DEFAULT', 'enable_metadata_proxy'),
]
METADATA_AGENT_EXCEPTIONS = [
('DEFAULT', 'auth_url'),
('DEFAULT', 'auth_region'),
('DEFAULT', 'admin_tenant_name'),
('DEFAULT', 'admin_user'),
('DEFAULT', 'admin_password'),
('DEFAULT', 'metadata_workers'),
]
def start():
# pull out the current version of config/upgrade-id
p = Popen(['/usr/bin/svcprop', '-p', 'config/upgrade-id',
os.environ['SMF_FMRI']], stdout=PIPE, stderr=PIPE)
curr_ver, _err = p.communicate()
curr_ver = curr_ver.strip()
# extract the openstack-upgrade-id from the pkg
p = Popen(['/usr/bin/pkg', 'contents', '-H', '-t', 'set', '-o', 'value',
'-a', 'name=openstack.upgrade-id',
'pkg:/cloud/openstack/neutron'], stdout=PIPE, stderr=PIPE)
pkg_ver, _err = p.communicate()
pkg_ver = pkg_ver.strip()
if curr_ver == pkg_ver:
# No need to upgrade
sys.exit(smf_include.SMF_EXIT_OK)
# look for any .new files
if glob.glob('/etc/neutron/*.new'):
# the versions are different, so perform an upgrade
# modify the configuration files
# backup all the old configuration files
create_backups('/etc/neutron')
modify_conf('/etc/neutron/api-paste.ini')
modify_conf('/etc/neutron/dhcp_agent.ini', DHCP_AGENT_MAPPINGS)
modify_conf('/etc/neutron/l3_agent.ini', None, L3_AGENT_EXCEPTIONS)
modify_conf('/etc/neutron/neutron.conf', NEUTRON_CONF_MAPPINGS,
NEUTRON_CONF_EXCEPTIONS)
modify_conf('/etc/neutron/plugins/evs/evs_plugin.ini',
EVS_PLUGIN_MAPPINGS)
modify_conf('/etc/neutron/metadata_agent.ini', None,
METADATA_AGENT_EXCEPTIONS)
config = iniparse.RawConfigParser()
config.read('/etc/neutron/neutron.conf')
# In certain cases the database section does not exist and the
# default database chosen is sqlite.
if config.has_section('database'):
db_connection = config.get('database', 'connection')
engine = sqlalchemy.create_engine(db_connection)
# migrate EVS to Neutron db
if engine.url.username != '%SERVICE_USER%':
check_call(['/usr/lib/neutron/evs-neutron-migration'])
print "EVS to Neutron migration complete"
if engine.url.drivername == 'mysql':
alter_mysql_tables(engine)
print "altered character set to utf8 in neutron tables"
check_call(['/usr/bin/neutron-db-manage', '--config-file',
'/etc/neutron/neutron.conf', '--config-file',
'/etc/neutron/plugins/evs/evs_plugin.ini', 'stamp',
'juno'])
# update the current version
check_call(['/usr/sbin/svccfg', '-s', os.environ['SMF_FMRI'], 'setprop',
'config/upgrade-id', '=', pkg_ver])
check_call(['/usr/sbin/svccfg', '-s', os.environ['SMF_FMRI'], 'refresh'])
sys.exit(smf_include.SMF_EXIT_OK)
if __name__ == '__main__':
os.putenv('LC_ALL', 'C')
try:
smf_include.smf_main()
except RuntimeError:
sys.exit(smf_include.SMF_EXIT_ERR_FATAL)
except Exception as err:
print 'Unknown error: %s' % err
print
traceback.print_exc(file=sys.stdout)
sys.exit(smf_include.SMF_EXIT_ERR_FATAL)