components/openstack/neutron/files/neutron-upgrade
branchs11-update
changeset 4207 787ed839f409
parent 4072 db0cec748ec0
child 4314 96c1b7e2e45c
equal deleted inserted replaced
4203:e5795ec8c7a3 4207:787ed839f409
   141             section_items = default_items
   141             section_items = default_items
   142 
   142 
   143         for key, value in section_items:
   143         for key, value in section_items:
   144             # keep a copy of the old value
   144             # keep a copy of the old value
   145             oldvalue = value
   145             oldvalue = value
       
   146             oldsection = section
   146 
   147 
   147             if mapping is not None:
   148             if mapping is not None:
   148                 section, key = update_mapping(section, key, mapping)
   149                 section, key = update_mapping(section, key, mapping)
   149 
   150 
   150                 if section is None and key is None:
   151                 if section is None and key is None:
   171             # Only copy the old value to the new conf file if the entry doesn't
   172             # Only copy the old value to the new conf file if the entry doesn't
   172             # exist or if it contains '%SERVICE'
   173             # exist or if it contains '%SERVICE'
   173             if not new.has_option(section, key) or \
   174             if not new.has_option(section, key) or \
   174                '%SERVICE' in new.get(section, key):
   175                '%SERVICE' in new.get(section, key):
   175                 new.set(section, key, value)
   176                 new.set(section, key, value)
       
   177             section = oldsection
   176 
   178 
   177     # copy the old conf file to a backup
   179     # copy the old conf file to a backup
   178     today = datetime.now().strftime("%Y%m%d%H%M%S")
   180     today = datetime.now().strftime("%Y%m%d%H%M%S")
   179     shutil.copy2(old_file, old_file + '.' + today)
   181     shutil.copy2(old_file, old_file + '.' + today)
   180 
   182