保存在配置文件中
1 def Main(): 2 buf = '' 3 f = open('pw.cfg','w') 4 for i in range(2016): 5 pwid = str(102 + i) 6 buf += "interface gigabitethernet 0/1/2/7."+pwid + ' ' 7 buf += "l2transport " 8 buf += 'mpls l2-circuit pw' +pwid + ' ' + pwid + ' 2.2.2.2 control-word bfd encapsulation raw ' 9 buf += 'exit ' 10 f.writelines(buf) 11 f.close() 12 13 def create_bfd(): 14 15 buf = '' 16 f = open('bfd.cfg','w') 17 for i in range(2016): 18 pwid = str(102 + i) 19 # mpls static-bfd pw-name pw21 local-discriminator 3 remote-discriminator 3 bind-bfd tp1 20 buf += 'mpls static-bfd pw-name pw'+pwid+' local-discriminator '+pwid + ' remote-discriminator ' + pwid +' ' 21 22 f.writelines(buf) 23 f.close() 24 if __name__ == '__main__': 25 create_bfd() 26 Main()