4049N/A#!/usr/bin/python2.7
3998N/A
5403N/A# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3998N/A#
3998N/A# Licensed under the Apache License, Version 2.0 (the "License"); you may
3998N/A# not use this file except in compliance with the License. You may obtain
3998N/A# a copy of the License at
3998N/A#
3998N/A# http://www.apache.org/licenses/LICENSE-2.0
3998N/A#
3998N/A# Unless required by applicable law or agreed to in writing, software
3998N/A# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
3998N/A# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
3998N/A# License for the specific language governing permissions and limitations
3998N/A# under the License.
3998N/A
3998N/Aimport glob
3998N/Aimport os
3998N/Afrom subprocess import check_call, Popen, PIPE
3998N/Aimport sys
3998N/Aimport traceback
3998N/A
3998N/Aimport smf_include
3998N/A
4285N/Afrom openstack_common import alter_mysql_tables, create_backups, modify_conf
4285N/A
3998N/A
3998N/ANEUTRON_CONF_MAPPINGS = {
6846N/A # Deprecated group/name for Liberty
6846N/A ('DEFAULT', 'use_syslog'): (None, None),
6846N/A ('DEFAULT', 'log_format'): (None, None),
6846N/A ('DEFAULT', 'rpc_thread_pool_size'):
6846N/A ('DEFAULT', 'executor_thread_pool_size'),
5403N/A ('DEFAULT', 'nova_region_name'): ('nova', 'region_name'),
6846N/A ('DEFAULT', 'nova_admin_username'): ('nova', 'username'),
6846N/A ('DEFAULT', 'nova_admin_tenant_id'): ('nova', 'tenant_id'),
6846N/A ('DEFAULT', 'nova_admin_tenant_name'): ('nova', 'tenant_name'),
6846N/A ('DEFAULT', 'nova_admin_password'): ('nova', 'password'),
6846N/A ('DEFAULT', 'nova_admin_auth_url'): ('nova', 'auth_url'),
3998N/A}
3998N/A
4285N/ANEUTRON_CONF_EXCEPTIONS = [
5403N/A ('database', 'connection'),
4285N/A ('keystone_authtoken', 'auth_uri'),
4285N/A ('keystone_authtoken', 'identity_uri'),
4285N/A ('keystone_authtoken', 'admin_tenant_name'),
4285N/A ('keystone_authtoken', 'admin_user'),
4285N/A ('keystone_authtoken', 'admin_password'),
4285N/A ('keystone_authtoken', 'signing_dir'),
6029N/A # Do not overwrite EVS options with OVS options since upgrade
6029N/A # doesn't handle EVS to OVS upgrade
6029N/A ('DEFAULT', 'core_plugin'),
6029N/A ('DEFAULT', 'service_plugins'),
6874N/A ('nova', 'username'),
6874N/A ('nova', 'tenant_name'),
6874N/A ('nova', 'password'),
6874N/A ('nova', 'auth_url'),
4285N/A]
4285N/A
6874N/AL3_AGENT_MAPPINGS = {
6874N/A ('DEFAULT', 'evs_controller'): (None, None),
6874N/A ('DEFAULT', 'external_network_datalink'): (None, None),
6874N/A}
6874N/A
6029N/AL3_AGENT_EXCEPTIONS = [
6029N/A ('DEFAULT', 'ovs_integration_bridge'),
6029N/A ('DEFAULT', 'interface_driver'),
6029N/A ('DEFAULT', 'external_network_bridge'),
6874N/A ('DEFAULT', 'auth_url'),
6029N/A]
6029N/A
6874N/ADHCP_AGENT_MAPPINGS = {
6874N/A ('DEFAULT', 'evs_controller'): (None, None)
6874N/A}
6874N/A
6029N/ADHCP_AGENT_EXCEPTIONS = [
6029N/A ('DEFAULT', 'ovs_integration_bridge'),
6029N/A ('DEFAULT', 'interface_driver'),
6029N/A]
3998N/A
4285N/AMETADATA_AGENT_EXCEPTIONS = [
4285N/A ('DEFAULT', 'auth_url'),
4285N/A ('DEFAULT', 'auth_region'),
4285N/A ('DEFAULT', 'admin_tenant_name'),
4285N/A ('DEFAULT', 'admin_user'),
4285N/A ('DEFAULT', 'admin_password'),
4285N/A ('DEFAULT', 'metadata_workers'),
4285N/A]
3998N/A
6846N/AOPENVSWITCH_AGENT_EXCEPTIONS = [
6846N/A ('ovs', 'integration_bridge'),
6846N/A ('ovs', 'tunnel_bridge'),
6846N/A ('securitygroup', 'enable_security_group'),
6846N/A ('securitygroup', 'enable_ipset'),
6846N/A]
6846N/A
6874N/AML2_CONF_MAPPINGS = {
6874N/A ('ml2', 'segment_mtu'): ('DEFAULT', 'global_physnet_mtu'),
6874N/A}
6874N/A
6874N/AML2_CONF_EXCEPTIONS = [
6846N/A ('ml2', 'type_drivers'),
6846N/A ('ml2', 'tenant_network_types'),
6846N/A ('ml2', 'mechanism_drivers'),
6846N/A ('securitygroup', 'enable_security_group'),
6846N/A ('securitygroup', 'enable_ipset'),
6846N/A]
6846N/A
3998N/A
3998N/Adef start():
3998N/A # pull out the current version of config/upgrade-id
3998N/A p = Popen(['/usr/bin/svcprop', '-p', 'config/upgrade-id',
3998N/A os.environ['SMF_FMRI']], stdout=PIPE, stderr=PIPE)
3998N/A curr_ver, _err = p.communicate()
3998N/A curr_ver = curr_ver.strip()
3998N/A
3998N/A # extract the openstack-upgrade-id from the pkg
3998N/A p = Popen(['/usr/bin/pkg', 'contents', '-H', '-t', 'set', '-o', 'value',
3998N/A '-a', 'name=openstack.upgrade-id',
3998N/A 'pkg:/cloud/openstack/neutron'], stdout=PIPE, stderr=PIPE)
3998N/A pkg_ver, _err = p.communicate()
3998N/A pkg_ver = pkg_ver.strip()
3998N/A
3998N/A if curr_ver == pkg_ver:
3998N/A # No need to upgrade
3998N/A sys.exit(smf_include.SMF_EXIT_OK)
3998N/A
6846N/A # TODO: Kilo EVS check. If upgrade is from Kilo running EVS,
6846N/A # fail the upgrade.
6846N/A
3998N/A # look for any .new files
3998N/A if glob.glob('/etc/neutron/*.new'):
3998N/A # the versions are different, so perform an upgrade
3998N/A # modify the configuration files
4285N/A
4285N/A # backup all the old configuration files
4285N/A create_backups('/etc/neutron')
4285N/A
3998N/A modify_conf('/etc/neutron/api-paste.ini')
6874N/A modify_conf('/etc/neutron/dhcp_agent.ini', mapping=DHCP_AGENT_MAPPINGS,
6874N/A exception_list=DHCP_AGENT_EXCEPTIONS)
6874N/A modify_conf('/etc/neutron/l3_agent.ini', mapping=L3_AGENT_MAPPINGS,
5717N/A exception_list=L3_AGENT_EXCEPTIONS)
6874N/A modify_conf('/etc/neutron/neutron.conf', mapping=NEUTRON_CONF_MAPPINGS,
6874N/A exception_list=NEUTRON_CONF_EXCEPTIONS)
5717N/A modify_conf('/etc/neutron/metadata_agent.ini', mapping=None,
5717N/A exception_list=METADATA_AGENT_EXCEPTIONS)
3998N/A
6846N/A # look for any .new files for ml2 plugin
6846N/A if glob.glob('/etc/neutron/plugins/ml2/*.new'):
6846N/A # modify the configuration files
6846N/A # backup all the old configuration files
6846N/A create_backups('/etc/neutron/plugins/ml2')
5838N/A
6846N/A modify_conf('/etc/neutron/plugins/ml2/openvswitch_agent.ini',
6846N/A mapping=None,
6846N/A exception_list=OPENVSWITCH_AGENT_EXCEPTIONS)
6846N/A
6846N/A modify_conf('/etc/neutron/plugins/ml2/ml2_conf.ini',
6874N/A mapping=ML2_CONF_MAPPINGS,
6874N/A exception_list=ML2_CONF_EXCEPTIONS)
3998N/A
3998N/A # update the current version
3998N/A check_call(['/usr/sbin/svccfg', '-s', os.environ['SMF_FMRI'], 'setprop',
3998N/A 'config/upgrade-id', '=', pkg_ver])
3998N/A check_call(['/usr/sbin/svccfg', '-s', os.environ['SMF_FMRI'], 'refresh'])
3998N/A
3998N/A sys.exit(smf_include.SMF_EXIT_OK)
3998N/A
3998N/A
3998N/Aif __name__ == '__main__':
3998N/A os.putenv('LC_ALL', 'C')
3998N/A try:
3998N/A smf_include.smf_main()
4285N/A except RuntimeError:
4285N/A sys.exit(smf_include.SMF_EXIT_ERR_FATAL)
3998N/A except Exception as err:
3998N/A print 'Unknown error: %s' % err
3998N/A print
3998N/A traceback.print_exc(file=sys.stdout)
3998N/A sys.exit(smf_include.SMF_EXIT_ERR_FATAL)