components/openstack/cinder/files/cinder-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 #
    28     move_conf
    28     move_conf
    29 
    29 
    30 
    30 
    31 CINDER_CONF_MAPPINGS = {
    31 CINDER_CONF_MAPPINGS = {
    32     # Deprecated group/name
    32     # Deprecated group/name
    33     ('DEFAULT', 'rabbit_durable_queues'): ('DEFAULT', 'amqp_durable_queues'),
    33     ('DEFAULT', 'eqlx_chap_password'): ('DEFAULT', 'chap_password'),
    34     ('rpc_notifier2', 'topics'): ('DEFAULT', 'notification_topics'),
    34     ('DEFAULT', 'eqlx_use_chap'): ('DEFAULT', 'use_chap_auth'),
    35     ('DEFAULT', 'osapi_compute_link_prefix'):
    35     ('DEFAULT', 'eqlx_chap_login'): ('DEFAULT', 'chap_username'),
    36         ('DEFAULT', 'osapi_volume_base_URL'),
    36     ('DEFAULT', 'host'): ('DEFAULT', 'backend_host'),
    37     ('DEFAULT', 'backup_service'): ('DEFAULT', 'backup_driver'),
       
    38     ('DEFAULT', 'pybasedir'): ('DEFAULT', 'state_path'),
       
    39     ('DEFAULT', 'log_config'): ('DEFAULT', 'log_config_append'),
       
    40     ('DEFAULT', 'logfile'): ('DEFAULT', 'log_file'),
       
    41     ('DEFAULT', 'logdir'): ('DEFAULT', 'log_dir'),
       
    42     ('DEFAULT', 'num_iscsi_scan_tries'):
       
    43         ('DEFAULT', 'num_volume_device_scan_tries'),
       
    44     ('DEFAULT', 'zfssa_host'): ('DEFAULT', 'san_ip'),
       
    45     ('DEFAULT', 'zfssa_auth_user'): ('DEFAULT', 'san_login'),
       
    46     ('DEFAULT', 'zfssa_auth_password'): ('DEFAULT', 'san_password'),
       
    47     ('DEFAULT', 'db_backend'): ('database', 'backend'),
    37     ('DEFAULT', 'db_backend'): ('database', 'backend'),
    48     ('DEFAULT', 'sql_connection'): ('database', 'connection'),
    38     ('DEFAULT', 'qpid_hostname'):
    49     ('DATABASE', 'sql_connection'): ('database', 'connection'),
    39         ('oslo_messaging_qpid', 'qpid_hostname'),
    50     ('sql', 'connection'): ('database', 'connection'),
    40     ('DEFAULT', 'qpid_port'):
    51     ('DEFAULT', 'sql_idle_timeout'): ('database', 'idle_timeout'),
    41         ('oslo_messaging_qpid', 'qpid_port'),
    52     ('DATABASE', 'sql_idle_timeout'): ('database', 'idle_timeout'),
    42     ('DEFAULT', 'qpid_hosts'):
    53     ('sql', 'idle_timeout'): ('database', 'idle_timeout'),
    43         ('oslo_messaging_qpid', 'qpid_hosts'),
    54     ('DEFAULT', 'sql_min_pool_size'): ('database', 'min_pool_size'),
    44     ('DEFAULT', 'qpid_username'):
    55     ('DATABASE', 'sql_min_pool_size'): ('database', 'min_pool_size'),
    45         ('oslo_messaging_qpid', 'qpid_username'),
    56     ('DEFAULT', 'sql_max_pool_size'): ('database', 'max_pool_size'),
    46     ('DEFAULT', 'qpid_password'):
    57     ('DATABASE', 'sql_max_pool_size'): ('database', 'max_pool_size'),
    47         ('oslo_messaging_qpid', 'qpid_password'),
    58     ('DEFAULT', 'sql_max_retries'): ('database', 'max_retries'),
    48     ('DEFAULT', 'qpid_sasl_mechanisms'):
    59     ('DATABASE', 'sql_max_retries'): ('database', 'max_retries'),
    49         ('oslo_messaging_qpid', 'qpid_sasl_mechanisms'),
    60     ('DEFAULT', 'sql_retry_interval'): ('database', 'retry_interval'),
    50     ('DEFAULT', 'qpid_heartbeat'):
    61     ('DATABASE', 'reconnect_interval'): ('database', 'retry_interval'),
    51         ('oslo_messaging_qpid', 'qpid_heartbeat'),
    62     ('DEFAULT', 'sql_max_overflow'): ('database', 'max_overflow'),
    52     ('DEFAULT', 'qpid_protocol'):
    63     ('DATABASE', 'sqlalchemy_max_overflow'): ('database', 'max_overflow'),
    53         ('oslo_messaging_qpid', 'qpid_protocol'),
    64     ('DEFAULT', 'sql_connection_debug'): ('database', 'connection_debug'),
    54     ('DEFAULT', 'qpid_tcp_nodelay'):
    65     ('DEFAULT', 'sql_connection_trace'): ('database', 'connection_trace'),
    55         ('oslo_messaging_qpid', 'qpid_tcp_nodelay'),
    66     ('DATABASE', 'sqlalchemy_pool_timeout'): ('database', 'pool_timeout'),
    56     ('DEFAULT', 'qpid_receiver_capacity'):
    67     ('DEFAULT', 'dbapi_use_tpool'): ('database', 'use_tpool'),
    57         ('oslo_messaging_qpid', 'qpid_receiver_capacity'),
    68     ('DEFAULT', 'memcache_servers'):
    58     ('DEFAULT', 'qpid_topology_version'):
    69         ('keystone_authtoken', 'memcached_servers'),
    59         ('oslo_messaging_qpid', 'qpid_topology_version'),
    70     ('DEFAULT', 'matchmaker_ringfile'): ('matchmaker_ring', 'ringfile'),
    60     ('DEFAULT', 'amqp_durable_queues'):
       
    61         ('oslo_messaging_rabbit', 'amqp_durable_queues'),
       
    62     ('DEFAULT', 'amqp_auto_delete'):
       
    63         ('oslo_messaging_rabbit', 'amqp_auto_delete'),
       
    64     ('DEFAULT', 'rpc_conn_pool_size'):
       
    65         ('oslo_messaging_rabbit', 'rpc_conn_pool_size'),
       
    66     ('DEFAULT', 'kombu_ssl_version'):
       
    67         ('oslo_messaging_rabbit', 'kombu_ssl_version'),
       
    68     ('DEFAULT', 'kombu_ssl_keyfile'):
       
    69         ('oslo_messaging_rabbit', 'kombu_ssl_keyfile'),
       
    70     ('DEFAULT', 'kombu_ssl_certfile'):
       
    71         ('oslo_messaging_rabbit', 'kombu_ssl_certfile'),
       
    72     ('DEFAULT', 'kombu_ssl_ca_certs'):
       
    73         ('oslo_messaging_rabbit', 'kombu_ssl_ca_certs'),
       
    74     ('DEFAULT', 'kombu_reconnect_delay'):
       
    75         ('oslo_messaging_rabbit', 'kombu_reconnect_delay'),
       
    76     ('DEFAULT', 'rabbit_host'):
       
    77         ('oslo_messaging_rabbit', 'rabbit_host'),
       
    78     ('DEFAULT', 'rabbit_port'):
       
    79         ('oslo_messaging_rabbit', 'rabbit_port'),
       
    80     ('DEFAULT', 'rabbit_hosts'):
       
    81         ('oslo_messaging_rabbit', 'rabbit_hosts'),
       
    82     ('DEFAULT', 'rabbit_use_ssl'):
       
    83         ('oslo_messaging_rabbit', 'rabbit_use_ssl'),
       
    84     ('DEFAULT', 'rabbit_userid'):
       
    85         ('oslo_messaging_rabbit', 'rabbit_userid'),
       
    86     ('DEFAULT', 'rabbit_password'):
       
    87         ('oslo_messaging_rabbit', 'rabbit_password'),
       
    88     ('DEFAULT', 'rabbit_login_method'):
       
    89         ('oslo_messaging_rabbit', 'rabbit_login_method'),
       
    90     ('DEFAULT', 'rabbit_virtual_host'):
       
    91         ('oslo_messaging_rabbit', 'rabbit_virtual_host'),
       
    92     ('DEFAULT', 'rabbit_retry_interval'):
       
    93         ('oslo_messaging_rabbit', 'rabbit_retry_interval'),
       
    94     ('DEFAULT', 'rabbit_retry_backoff'):
       
    95         ('oslo_messaging_rabbit', 'rabbit_retry_backoff'),
       
    96     ('DEFAULT', 'rabbit_max_retries'):
       
    97         ('oslo_messaging_rabbit', 'rabbit_max_retries'),
       
    98     ('DEFAULT', 'rabbit_ha_queues'):
       
    99         ('oslo_messaging_rabbit', 'rabbit_ha_queues'),
       
   100     ('DEFAULT', 'fake_rabbit'):
       
   101         ('oslo_messaging_rabbit', 'fake_rabbit'),
       
   102     ('DEFAULT', 'osapi_max_request_body_size'):
       
   103         ('oslo_middleware', 'max_request_body_size'),
       
   104     ('DEFAULT', 'log-format'): (None, None),
       
   105     ('DEFAULT', 'use-syslog'): (None, None),
       
   106     ('DEFAULT', 'datera_api_token'): (None, None),
       
   107     ('DEFAULT', 'enable_v1_api'): (None, None),
       
   108     ('DEFAULT', 'log_format'): (None, None),
    71 }
   109 }
    72 
   110 
    73 CINDER_CONF_EXCEPTIONS = [
   111 CINDER_CONF_EXCEPTIONS = [
    74     ('DEFAULT', 'osapi_volume_workers'),
   112     ('DEFAULT', 'osapi_volume_workers'),
    75     ('DEFAULT', 'auth_strategy'),
   113     ('DEFAULT', 'auth_strategy'),
    81     ('keystone_authtoken', 'admin_user'),
   119     ('keystone_authtoken', 'admin_user'),
    82     ('keystone_authtoken', 'admin_password'),
   120     ('keystone_authtoken', 'admin_password'),
    83     ('keystone_authtoken', 'admin_tenant_name'),
   121     ('keystone_authtoken', 'admin_tenant_name'),
    84     ('keystone_authtoken', 'signing_dir'),
   122     ('keystone_authtoken', 'signing_dir'),
    85 ]
   123 ]
    86 
       
    87 CINDER_MOVE_CONFIG = {
       
    88     ('filter:authtoken', 'auth_uri'): ('keystone_authtoken', 'auth_uri'),
       
    89     ('filter:authtoken', 'identity_uri'):
       
    90         ('keystone_authtoken', 'identity_uri'),
       
    91     ('filter:authtoken', 'admin_tenant_name'):
       
    92         ('keystone_authtoken', 'admin_tenant_name'),
       
    93     ('filter:authtoken', 'admin_user'): ('keystone_authtoken', 'admin_user'),
       
    94     ('filter:authtoken', 'admin_password'):
       
    95         ('keystone_authtoken', 'admin_password'),
       
    96     ('filter:authtoken', 'signing_dir'): ('keystone_authtoken', 'signing_dir'),
       
    97 }
       
    98 
   124 
    99 
   125 
   100 def start():
   126 def start():
   101     # pull out the current version of config/upgrade-id
   127     # pull out the current version of config/upgrade-id
   102     p = Popen(['/usr/bin/svcprop', '-p', 'config/upgrade-id',
   128     p = Popen(['/usr/bin/svcprop', '-p', 'config/upgrade-id',
   123         # backup all the old configuration files
   149         # backup all the old configuration files
   124         create_backups('/etc/cinder')
   150         create_backups('/etc/cinder')
   125 
   151 
   126         modify_conf('/etc/cinder/api-paste.ini')
   152         modify_conf('/etc/cinder/api-paste.ini')
   127 
   153 
   128         # before modifying cinder.conf, move the [filter:authtoken] entries
       
   129         # from the updated api-paste.ini to the old cinder.conf
       
   130         move_conf('/etc/cinder/api-paste.ini', '/etc/cinder/cinder.conf',
       
   131                   CINDER_MOVE_CONFIG)
       
   132 
       
   133         modify_conf('/etc/cinder/cinder.conf', CINDER_CONF_MAPPINGS,
   154         modify_conf('/etc/cinder/cinder.conf', CINDER_CONF_MAPPINGS,
   134                     CINDER_CONF_EXCEPTIONS)
   155                     CINDER_CONF_EXCEPTIONS)
   135         modify_conf('/etc/cinder/logging.conf')
       
   136 
   156 
   137     config = iniparse.RawConfigParser()
   157     config = iniparse.RawConfigParser()
   138     config.read('/etc/cinder/cinder.conf')
   158     config.read('/etc/cinder/cinder.conf')
   139     # In certain cases the database section does not exist and the
   159     # In certain cases the database section does not exist and the
   140     # default database chosen is sqlite.
   160     # default database chosen is sqlite.