nova-upgrade revision 6852
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 iniparse
3998N/Aimport smf_include
3998N/Aimport sqlalchemy
3998N/A
4285N/Afrom openstack_common import alter_mysql_tables, create_backups, modify_conf, \
4285N/A move_conf
4285N/A
3998N/ANOVA_CONF_MAPPINGS = {
6852N/A # Deprecated group/name for Liberty
5403N/A ('DEFAULT', 'network_device_mtu'): (None, None),
6852N/A ('DEFAULT', 'vnc_keymap'): ('vnc', 'keymap'),
6852N/A ('DEFAULT', 'vnc_enabled'): ('vnc', 'enabled'),
6852N/A ('DEFAULT', 'xvpvncproxy_base_url'): ('vnc', 'xvpvncproxy_base_url'),
5403N/A ('ironic', 'client_log_level'): (None, None),
6852N/A ('neutron', 'admin_username'): ('neutron', 'username'),
6852N/A ('DEFAULT', 'ssl_ca_file'): ('ssl', 'ca_file'),
6852N/A ('osapi_v21', 'enabled'): (None, None),
6852N/A ('DEFAULT', 'novncproxy_base_url'): ('vnc', 'novncproxy_base_url'),
5403N/A ('neutron', 'admin_user_id'): (None, None),
5403N/A ('neutron', 'admin_tenant_id'): (None, None),
6852N/A ('DEFAULT', 'ssl_cert_file'): ('ssl', 'cert_file'),
5403N/A ('DEFAULT', 'log_format'): (None, None),
6852N/A ('DEFAULT', 'vncserver_proxyclient_address'):
6852N/A ('vnc', 'vncserver_proxyclient_address'),
6852N/A ('osapi_v21', 'extensions_blacklist'): (None, None),
6852N/A ('workarounds', 'destroy_after_evacuate'): (None, None),
6852N/A ('neutron', 'admin_tenant_name'): ('neutron', 'tenant_name'),
6852N/A ('DEFAULT', 'osapi_compute_ext_list'): (None, None),
6852N/A ('DEFAULT', 'rpc_thread_pool_size'):
6852N/A ('DEFAULT', 'executor_thread_pool_size'),
6852N/A ('DEFAULT', 'vncserver_listen'): ('vnc', 'vncserver_listen'),
6852N/A ('neutron', 'admin_password'): ('neutron', 'password'),
6852N/A ('DEFAULT', 'ssl_key_file'): ('ssl', 'key_file'),
6852N/A ('neutron', 'admin_auth_url'): ('neutron', 'auth_url'),
6852N/A # Deprecated group/name for Mitaka
6852N/A ('DEFAULT', 'cert_manager'): (None, None),
6852N/A ('DEFAULT', 'compute_available_monitors'): (None, None),
6852N/A ('DEFAULT', 'compute_manager'): (None, None),
6852N/A ('DEFAULT', 'compute_resources'): (None, None),
6852N/A ('DEFAULT', 'compute_stats_class'): (None, None),
6852N/A ('DEFAULT', 'console_manager'): (None, None),
6852N/A ('DEFAULT', 'consoleauth_manager'): (None, None),
6852N/A ('DEFAULT', 'db_driver'): (None, None),
6852N/A ('DEFAULT', 'memcached_servers'): (None, None),
6852N/A ('DEFAULT', 'metadata_manager'): (None, None),
6852N/A ('DEFAULT', 'network_api_class'): (None, None),
6852N/A ('DEFAULT', 'network_device_mtu'): (None, None),
6852N/A ('DEFAULT', 'osapi_compute_ext_list'): (None, None),
6852N/A ('DEFAULT', 'scheduler_manager'): (None, None),
6852N/A ('DEFAULT', 'security_group_api'): (None, None),
5403N/A ('DEFAULT', 'share_dhcp_address'): (None, None),
6852N/A ('DEFAULT', 'use_syslog'): (None, None),
6852N/A ('DEFAULT', 'vendordata_driver'): (None, None),
6852N/A ('DEFAULT', 'volume_api_class'): (None, None),
6852N/A ('cells', 'manager'): (None, None),
6852N/A ('conductor', 'manager'): (None, None),
6852N/A ('conductor', 'use_local'): (None, None),
6852N/A ('glance', 'host'): (None, None),
6852N/A ('glance', 'port'): (None, None),
6852N/A ('glance', 'protocol'): (None, None),
6852N/A ('hyperv', 'force_volumeutils_v1'): (None, None),
6852N/A ('ironic', 'admin_auth_token'): (None, None),
6852N/A ('ironic', 'api_version'): (None, None),
6852N/A ('ironic', 'client_log_level'): (None, None),
6852N/A ('libvirt', 'remove_unused_kernels'): (None, None),
6852N/A ('osapi_v21', 'enabled'): (None, None),
6852N/A ('osapi_v21', 'extensions_blacklist'): (None, None),
6852N/A ('osapi_v21', 'extensions_whitelist'): (None, None),
6852N/A ('osapi_v21', 'project_id_regex'): (None, None),
6852N/A ('serial_console', 'listen'): (None, None),
6852N/A ('workarounds', 'destroy_after_evacuate'): (None, None),
6852N/A # move entries from DEFAULT.nova.virt.solariszones.driver to its own
6852N/A # section
6852N/A ('DEFAULT', 'boot_volume_type'): ('solariszones', 'boot_volume_type'),
6852N/A ('DEFAULT', 'boot_volume_az'): ('solariszones', 'boot_volume_az'),
6852N/A ('DEFAULT', 'glancecache_dirname'):
6852N/A ('solariszones', 'glancecache_dirname'),
6852N/A ('DEFAULT', 'live_migration_cipher'):
6852N/A ('solariszones', 'live_migration_cipher'),
6852N/A ('DEFAULT', 'solariszones_snapshots_directory'):
6852N/A ('solariszones', 'solariszones_snapshots_directory'),
6852N/A ('DEFAULT', 'zones_suspend_path'): ('solariszones', 'zones_suspend_path'),
6852N/A ('DEFAULT', 'solariszones_boot_options'):
6852N/A ('solariszones', 'solariszones_boot_options'),
3998N/A}
3998N/A
6852N/A
6852N/AAPI_PASTE_MAPPING = {
6852N/A ('composite:osapi_compute', '/v1.1'): (None, None),
6852N/A ('composite:osapi_compute', '/v3'): (None, None),
6852N/A}
6852N/A
6852N/A
4285N/ANOVA_CONF_EXCEPTIONS = [
4285N/A ('DEFAULT', 'ec2_workers'),
4285N/A ('DEFAULT', 'osapi_compute_workers'),
4285N/A ('DEFAULT', 'metadata_workers'),
4285N/A ('DEFAULT', 'lock_path'),
4285N/A ('DEFAULT', 'novncproxy_base_url'),
6029N/A ('DEFAULT', 'ovs_bridge'),
4285N/A ('conductor', 'workers'),
4285N/A ('database', 'connection'),
4285N/A ('keystone_authtoken', 'auth_uri'),
4285N/A ('keystone_authtoken', 'signing_dir'),
4285N/A ('keystone_authtoken', 'identity_uri'),
4285N/A ('keystone_authtoken', 'admin_user'),
4285N/A ('keystone_authtoken', 'admin_password'),
4285N/A ('keystone_authtoken', 'admin_tenant_name'),
4285N/A ('neutron', 'service_metadata_proxy'),
6852N/A ('neutron', 'username'),
6852N/A ('neutron', 'password'),
6852N/A ('neutron', 'tenant_name'),
6852N/A ('neutron', 'auth_url'),
6852N/A
6852N/A
4285N/A]
3998N/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/nova'], 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
3998N/A # look for any .new files
3998N/A if glob.glob('/etc/nova/*.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/nova')
4285N/A
6852N/A modify_conf('/etc/nova/api-paste.ini', API_PASTE_MAPPING)
3998N/A modify_conf('/etc/nova/logging.conf')
4285N/A modify_conf('/etc/nova/nova.conf', NOVA_CONF_MAPPINGS,
4285N/A NOVA_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)