我一直在尝试编写一个 Python 脚本来完成 20 种思科配置。
到目前为止,我得到了一个脚本来处理一个配置,它解析出没有802.1x authentication*接口命令的接口。
我无法从列表中删除interface Tengig和interface vlan*。最好的方法是什么?我尝试了以下方法但没有成功。也许我只是用错了它们?
list.remove(Interface Vlan*)
for item in list(NoDot1x):
somelist.remove("Interface Vlan*")
代码:
#Int Modules
from ciscoconfparse import CiscoConfParse
#Define what to Parse
parse = CiscoConfParse("/home/jbowers/Configs/SwithConfig")
#Define all Interfaces without Authentication * commands
all_intfs = parse.find_objects(r"^interf")
NoDot1x = list()
NoDot1x = parse.find_objects_wo_child(r'^interface', r'authentication')
#Display Results
for obj in NoDot1x:
print obj.text
#Remove Uplinks
for item in list(NoDot1x):
somelist.remove("Interface Vlan*")
这里是#Display Results 的输出。
interface Port-channel1
interface FastEthernet1
interface GigabitEthernet1/1
interface TenGigabitEthernet5/1
interface TenGigabitEthernet5/2
interface TenGigabitEthernet5/3
interface TenGigabitEthernet5/4
interface TenGigabitEthernet5/5
interface TenGigabitEthernet5/6
interface TenGigabitEthernet5/7
interface TenGigabitEthernet5/8
interface TenGigabitEthernet6/1
interface TenGigabitEthernet6/2
interface TenGigabitEthernet6/3
interface TenGigabitEthernet6/4
interface TenGigabitEthernet6/5
interface TenGigabitEthernet6/6
interface TenGigabitEthernet6/7
interface TenGigabitEthernet6/8
interface GigabitEthernet7/23
interface GigabitEthernet8/17
interface GigabitEthernet9/2
interface Vlan1
白衣染霜花
相关分类