etherswitch.py revision 11776:ed89cb178ecd
1def upgrader(cpt): 2 for sec in cpt.sections(): 3 if sec == "system": 4 options = cpt.items(sec) 5 for it in options: 6 opt_split = it[0].split('.') 7 if len(opt_split) < 2: continue 8 new_sec_name = opt_split[1] 9 old_opt_name = opt_split[len(opt_split) - 1] 10 if "outputFifo" in new_sec_name: 11 new_sec_name = new_sec_name.rstrip("outputFifo") 12 new_sec_name += ".outputFifo" 13 new_sec_name = "system.system.%s" %(new_sec_name) 14 if not cpt.has_section(new_sec_name): 15 cpt.add_section(new_sec_name) 16 if old_opt_name == "size": 17 cpt.set(new_sec_name, "_size", it[1]) 18 elif old_opt_name == "packets": 19 cpt.set(new_sec_name, "fifosize", it[1]) 20 else: 21 cpt.set(new_sec_name, old_opt_name, it[1]) 22 cpt.remove_option(sec, it[0]) 23