components/openstack/swift/files/swift-upgrade
changeset 4181 3ac4ce913bec
parent 4049 150852e281c4
child 4287 aba3ed31b37a
equal deleted inserted replaced
4169:287ebf81b849 4181:3ac4ce913bec
    62             section_items = default_items
    62             section_items = default_items
    63 
    63 
    64         for key, value in section_items:
    64         for key, value in section_items:
    65             # keep a copy of the old value
    65             # keep a copy of the old value
    66             oldvalue = value
    66             oldvalue = value
       
    67             oldsection = section
    67 
    68 
    68             if not new.has_section(section):
    69             if not new.has_section(section):
    69                 if section != 'DEFAULT':
    70                 if section != 'DEFAULT':
    70                     new.add_section(section)
    71                     new.add_section(section)
    71 
    72 
    85             # Only copy the old value to the new conf file if the entry doesn't
    86             # Only copy the old value to the new conf file if the entry doesn't
    86             # exist or if it contains '%SERVICE'
    87             # exist or if it contains '%SERVICE'
    87             if not new.has_option(section, key) or \
    88             if not new.has_option(section, key) or \
    88                '%SERVICE' in new.get(section, key):
    89                '%SERVICE' in new.get(section, key):
    89                 new.set(section, key, value)
    90                 new.set(section, key, value)
       
    91             section = oldsection
    90 
    92 
    91     # copy the old conf file to a backup
    93     # copy the old conf file to a backup
    92     today = datetime.now().strftime("%Y%m%d%H%M%S")
    94     today = datetime.now().strftime("%Y%m%d%H%M%S")
    93     shutil.copy2(old_file, old_file + '.' + today)
    95     shutil.copy2(old_file, old_file + '.' + today)
    94 
    96