components/openstack/nova/files/nova-upgrade
branchs11u3-sru
changeset 6035 c9748fcc32de
parent 4625 18adb92d4193
equal deleted inserted replaced
6016:a477397bba8b 6035:c9748fcc32de
     1 #!/usr/bin/python2.7
     1 #!/usr/bin/python2.7
     2 
     2 
     3 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     3 # Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     4 #
     4 #
     5 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
     5 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
     6 #    not use this file except in compliance with the License. You may obtain
     6 #    not use this file except in compliance with the License. You may obtain
     7 #    a copy of the License at
     7 #    a copy of the License at
     8 #
     8 #
    25 import sqlalchemy
    25 import sqlalchemy
    26 
    26 
    27 from openstack_common import alter_mysql_tables, create_backups, modify_conf, \
    27 from openstack_common import alter_mysql_tables, create_backups, modify_conf, \
    28     move_conf
    28     move_conf
    29 
    29 
    30 
       
    31 NOVA_CONF_MAPPINGS = {
    30 NOVA_CONF_MAPPINGS = {
    32     # Deprecated group/name
    31     # Deprecated group/name for Kilo
    33     ('DEFAULT', 'rabbit_durable_queues'): ('DEFAULT', 'amqp_durable_queues'),
    32     ('DEFAULT', 'network_device_mtu'): (None, None),
    34     ('rpc_notifier2', 'topics'): ('DEFAULT', 'notification_topics'),
    33     ('DEFAULT', 'log-format'): (None, None),
    35     ('DEFAULT', 'quota_injected_file_path_bytes'):
    34     ('DEFAULT', 'use-syslog'): (None, None),
    36         ('DEFAULT', 'quota_injected_file_path_length'),
    35     ('cinder', 'http_timeout'): ('cinder', 'timeout'),
    37     ('DEFAULT', 'log_config'): ('DEFAULT', 'log_config_append'),
    36     ('ironic', 'client_log_level'): (None, None),
    38     ('DEFAULT', 'logfile'): ('DEFAULT', 'log_file'),
    37     ('DEFAULT', 'amqp_durable_queues'):
    39     ('DEFAULT', 'logdir'): ('DEFAULT', 'log_dir'),
    38         ('oslo_messaging_qpid', 'amqp_durable_queues'),
    40     ('DEFAULT', 'cinder_catalog_info'): ('cinder', 'catalog_info'),
    39     ('DEFAULT', 'amqp_auto_delete'):
    41     ('DEFAULT', 'cinder_endpoint_template'): ('cinder', 'endpoint_template'),
    40         ('oslo_messaging_qpid', 'amqp_auto_delete'),
    42     ('DEFAULT', 'os_region_name'): ('cinder', 'os_region_name'),
    41     ('DEFAULT', 'rpc_conn_pool_size'):
    43     ('DEFAULT', 'cinder_ca_certificates_file'):
    42         ('oslo_messaging_qpid', 'rpc_conn_pool_size'),
    44         ('cinder', 'ca_certificates_file'),
    43     ('DEFAULT', 'qpid_hostname'):
    45     ('DEFAULT', 'cinder_http_retries'): ('cinder', 'http_retries'),
    44         ('oslo_messaging_qpid', 'qpid_hostname'),
    46     ('DEFAULT', 'cinder_http_timeout'): ('cinder', 'http_timeout'),
    45     ('DEFAULT', 'qpid_port'):
    47     ('DEFAULT', 'cinder_api_insecure'): ('cinder', 'api_insecure'),
    46         ('oslo_messaging_qpid', 'qpid_port'),
    48     ('DEFAULT', 'cinder_cross_az_attach'): ('cinder', 'cross_az_attach'),
    47     ('DEFAULT', 'qpid_hosts'):
    49     ('DEFAULT', 'db_backend'): ('database', 'backend'),
    48         ('oslo_messaging_qpid', 'qpid_hosts'),
    50     ('DEFAULT', 'sql_connection'): ('database', 'connection'),
    49     ('DEFAULT', 'qpid_username'):
    51     ('sql', 'connection'): ('database', 'connection'),
    50         ('oslo_messaging_qpid', 'qpid_username'),
    52     ('DEFAULT', 'sql_idle_timeout'): ('database', 'idle_timeout'),
    51     ('DEFAULT', 'qpid_password'):
    53     ('DATABASE', 'sql_idle_timeout'): ('database', 'idle_timeout'),
    52         ('oslo_messaging_qpid', 'qpid_password'),
    54     ('sql', 'idle_timeout'): ('database', 'idle_timeout'),
    53     ('DEFAULT', 'qpid_sasl_mechanisms'):
    55     ('DEFAULT', 'sql_min_pool_size'): ('database', 'min_pool_size'),
    54         ('oslo_messaging_qpid', 'qpid_sasl_mechanisms'),
    56     ('DATABASE', 'sql_min_pool_size'): ('database', 'min_pool_size'),
    55     ('DEFAULT', 'qpid_heartbeat'):
    57     ('DEFAULT', 'sql_max_pool_size'): ('database', 'max_pool_size'),
    56         ('oslo_messaging_qpid', 'qpid_heartbeat'),
    58     ('DATABASE', 'sql_max_pool_size'): ('database', 'max_pool_size'),
    57     ('DEFAULT', 'qpid_protocol'):
    59     ('DEFAULT', 'sql_max_retries'): ('database', 'max_retries'),
    58         ('oslo_messaging_qpid', 'qpid_protocol'),
    60     ('DATABASE', 'sql_max_retries'): ('database', 'max_retries'),
    59     ('DEFAULT', 'qpid_tcp_nodelay'):
    61     ('DEFAULT', 'sql_retry_interval'): ('database', 'retry_interval'),
    60         ('oslo_messaging_qpid', 'qpid_tcp_nodelay'),
    62     ('DATABASE', 'reconnect_interval'): ('database', 'retry_interval'),
    61     ('DEFAULT', 'qpid_receiver_capacity'):
    63     ('DEFAULT', 'sql_max_overflow'): ('database', 'max_overflow'),
    62         ('oslo_messaging_qpid', 'qpid_receiver_capacity'),
    64     ('DATABASE', 'sqlalchemy_max_overflow'): ('database', 'max_overflow'),
    63     ('DEFAULT', 'qpid_topology_version'):
    65     ('DEFAULT', 'sql_connection_debug'): ('database', 'connection_debug'),
    64         ('oslo_messaging_qpid', 'qpid_topology_version'),
    66     ('DEFAULT', 'sql_connection_trace'): ('database', 'connection_trace'),
    65     ('DEFAULT', 'kombu_ssl_version'):
    67     ('DATABASE', 'sqlalchemy_pool_timeout'): ('database', 'pool_timeout'),
    66         ('oslo_messaging_rabbit', 'kombu_ssl_version'),
    68     ('DEFAULT', 'glance_host'): ('glance', 'host'),
    67     ('DEFAULT', 'kombu_ssl_keyfile'):
    69     ('DEFAULT', 'glance_port'): ('glance', 'port'),
    68         ('oslo_messaging_rabbit', 'kombu_ssl_keyfile'),
    70     ('DEFAULT', 'glance_protocol'): ('glance', 'protocol'),
    69     ('DEFAULT', 'kombu_ssl_certfile'):
    71     ('DEFAULT', 'glance_api_servers'): ('glance', 'api_servers'),
    70         ('oslo_messaging_rabbit', 'kombu_ssl_certfile'),
    72     ('DEFAULT', 'glance_api_insecure'): ('glance', 'api_insecure'),
    71     ('DEFAULT', 'kombu_ssl_ca_certs'):
    73     ('DEFAULT', 'glance_num_retries'): ('glance', 'num_retries'),
    72         ('oslo_messaging_rabbit', 'kombu_ssl_ca_certs'),
    74     ('DEFAULT', 'memcache_servers'):
    73     ('DEFAULT', 'kombu_reconnect_delay'):
    75         ('keystone_authtoken', 'memcached_servers'),
    74         ('oslo_messaging_rabbit', 'kombu_reconnect_delay'),
    76     ('DEFAULT', 'matchmaker_ringfile'): ('matchmaker_ring', 'ringfile'),
    75     ('DEFAULT', 'rabbit_host'):
    77     ('DEFAULT', 'service_neutron_metadata_proxy'):
    76         ('oslo_messaging_rabbit', 'rabbit_host'),
    78         ('neutron', 'service_metadata_proxy'),
    77     ('DEFAULT', 'rabbit_port'):
    79     ('DEFAULT', 'neutron_metadata_proxy_shared_secret'):
    78         ('oslo_messaging_rabbit', 'rabbit_port'),
    80         ('neutron', 'metadata_proxy_shared_secret'),
    79     ('DEFAULT', 'rabbit_hosts'):
    81     ('DEFAULT', 'neutron_url'): ('neutron', 'url'),
    80         ('oslo_messaging_rabbit', 'rabbit_hosts'),
    82     ('DEFAULT', 'neutron_url_timeout'): ('neutron', 'url_timeout'),
    81     ('DEFAULT', 'rabbit_use_ssl'):
    83     ('DEFAULT', 'neutron_admin_username'): ('neutron', 'admin_username'),
    82         ('oslo_messaging_rabbit', 'rabbit_use_ssl'),
    84     ('DEFAULT', 'neutron_admin_password'): ('neutron', 'admin_password'),
    83     ('DEFAULT', 'rabbit_userid'):
    85     ('DEFAULT', 'neutron_admin_tenant_id'): ('neutron', 'admin_tenant_id'),
    84         ('oslo_messaging_rabbit', 'rabbit_userid'),
    86     ('DEFAULT', 'neutron_admin_tenant_name'): ('neutron', 'admin_tenant_name'),
    85     ('DEFAULT', 'rabbit_password'):
    87     ('DEFAULT', 'neutron_region_name'): ('neutron', 'region_name'),
    86         ('oslo_messaging_rabbit', 'rabbit_password'),
    88     ('DEFAULT', 'neutron_admin_auth_url'): ('neutron', 'admin_auth_url'),
    87     ('DEFAULT', 'rabbit_login_method'):
    89     ('DEFAULT', 'neutron_api_insecure'): ('neutron', 'api_insecure'),
    88         ('oslo_messaging_rabbit', 'rabbit_login_method'),
    90     ('DEFAULT', 'neutron_auth_strategy'): ('neutron', 'auth_strategy'),
    89     ('DEFAULT', 'rabbit_virtual_host'):
    91     ('DEFAULT', 'neutron_ovs_bridge'): ('neutron', 'ovs_bridge'),
    90         ('oslo_messaging_rabbit', 'rabbit_virtual_host'),
    92     ('DEFAULT', 'neutron_extension_sync_interval'):
    91     ('DEFAULT', 'rabbit_retry_backoff'):
    93         ('neutron', 'extension_sync_interval'),
    92         ('oslo_messaging_rabbit', 'rabbit_retry_backoff'),
    94     ('DEFAULT', 'neutron_ca_certificates_file'):
    93     ('DEFAULT', 'rabbit_max_retries'):
    95         ('neutron', 'ca_certificates_file'),
    94         ('oslo_messaging_rabbit', 'rabbit_max_retries'),
    96     ('DEFAULT', 'spicehtml5proxy_host'): ('spice', 'html5proxy_host'),
    95     ('DEFAULT', 'rabbit_ha_queues'):
    97     ('DEFAULT', 'spicehtml5proxy_port'): ('spice', 'html5proxy_port'),
    96         ('oslo_messaging_rabbit', 'rabbit_ha_queues'),
       
    97     ('DEFAULT', 'fake_rabbit'):
       
    98         ('oslo_messaging_rabbit', 'fake_rabbit'),
       
    99     ('DEFAULT', 'osapi_max_request_body_size'):
       
   100         ('oslo_middleware', 'max_request_body_size'),
       
   101     ('neutron', 'ca_certificates_file'): ('neutron', 'cafile'),
       
   102     ('neutron', 'admin_user_id'): (None, None),
       
   103     ('neutron', 'admin_tenant_id'): (None, None),
       
   104     ('DEFAULT', 'log_format'): (None, None),
       
   105     ('cinder', 'api_insecure'): ('cinder', 'insecure'),
       
   106     ('DEFAULT', 'share_dhcp_address'): (None, None),
       
   107     ('neutron', 'api_insecure'): ('neutron', 'insecure'),
       
   108     ('cinder', 'ca_certificates_file'): ('cinder', 'cafile'),
       
   109     ('neutron', 'url_timeout'): ('neutron', 'timeout'),
       
   110     ('neutron', 'allow_duplicate_networks'): (None, None),
    98 }
   111 }
    99 
   112 
   100 NOVA_CONF_EXCEPTIONS = [
   113 NOVA_CONF_EXCEPTIONS = [
   101     ('DEFAULT', 'ec2_workers'),
   114     ('DEFAULT', 'ec2_workers'),
   102     ('DEFAULT', 'osapi_compute_workers'),
   115     ('DEFAULT', 'osapi_compute_workers'),
   112     ('keystone_authtoken', 'admin_password'),
   125     ('keystone_authtoken', 'admin_password'),
   113     ('keystone_authtoken', 'admin_tenant_name'),
   126     ('keystone_authtoken', 'admin_tenant_name'),
   114     ('neutron', 'service_metadata_proxy'),
   127     ('neutron', 'service_metadata_proxy'),
   115 ]
   128 ]
   116 
   129 
   117 NOVA_MOVE_CONFIG = {
       
   118     ('filter:authtoken', 'auth_uri'): ('keystone_authtoken', 'auth_uri'),
       
   119     ('filter:authtoken', 'identity_uri'):
       
   120         ('keystone_authtoken', 'identity_uri'),
       
   121     ('filter:authtoken', 'admin_tenant_name'):
       
   122         ('keystone_authtoken', 'admin_tenant_name'),
       
   123     ('filter:authtoken', 'admin_user'): ('keystone_authtoken', 'admin_user'),
       
   124     ('filter:authtoken', 'admin_password'):
       
   125         ('keystone_authtoken', 'admin_password'),
       
   126     ('filter:authtoken', 'signing_dir'): ('keystone_authtoken', 'signing_dir'),
       
   127     ('filter:authtoken', 'auth_version'):
       
   128         ('keystone_authtoken', 'auth_version'),
       
   129 }
       
   130 
       
   131 
   130 
   132 def start():
   131 def start():
   133     # pull out the current version of config/upgrade-id
   132     # pull out the current version of config/upgrade-id
   134     p = Popen(['/usr/bin/svcprop', '-p', 'config/upgrade-id',
   133     p = Popen(['/usr/bin/svcprop', '-p', 'config/upgrade-id',
   135                os.environ['SMF_FMRI']], stdout=PIPE, stderr=PIPE)
   134                os.environ['SMF_FMRI']], stdout=PIPE, stderr=PIPE)
   177                 ('sql', 'connection'),
   176                 ('sql', 'connection'),
   178                 ('database', 'connection'),
   177                 ('database', 'connection'),
   179                 ('DEFAULT', 'sql_connection')
   178                 ('DEFAULT', 'sql_connection')
   180             ]
   179             ]
   181             test = lambda x: old.has_section(x[0]) and \
   180             test = lambda x: old.has_section(x[0]) and \
   182                     old.has_option(x[0], x[1])
   181                 old.has_option(x[0], x[1])
   183 
   182 
   184             if not any(map(test, options)):
   183             if not any(map(test, options)):
   185                 if old.has_option('DEFAULT', 'state_path'):
   184                 if old.has_option('DEFAULT', 'state_path'):
   186                     state_path = old.get('DEFAULT', 'state_path')
   185                     state_path = old.get('DEFAULT', 'state_path')
   187                 else:
   186                 else:
   195                 new.set('database', 'connection',
   194                 new.set('database', 'connection',
   196                         'sqlite:///%s/%s' % (state_path, sqlite_db))
   195                         'sqlite:///%s/%s' % (state_path, sqlite_db))
   197 
   196 
   198                 with open('/etc/nova/nova.conf.new', 'w+') as fh:
   197                 with open('/etc/nova/nova.conf.new', 'w+') as fh:
   199                     new.write(fh)
   198                     new.write(fh)
   200 
       
   201         # before modifying nova.conf, move the [filter:authtoken] entries from
       
   202         # the updated api-paste.ini to the old nova.conf
       
   203         move_conf('/etc/nova/api-paste.ini', '/etc/nova/nova.conf',
       
   204                   NOVA_MOVE_CONFIG)
       
   205 
   199 
   206         modify_conf('/etc/nova/nova.conf', NOVA_CONF_MAPPINGS,
   200         modify_conf('/etc/nova/nova.conf', NOVA_CONF_MAPPINGS,
   207                     NOVA_CONF_EXCEPTIONS)
   201                     NOVA_CONF_EXCEPTIONS)
   208 
   202 
   209     config = iniparse.RawConfigParser()
   203     config = iniparse.RawConfigParser()