|
4#
楼主 |
发表于 2011-1-24 13:57:27
|
只看该作者
def int_vlan_conf_list1(deviceName,vlanid)
#获取交换机数据
rs = get_commands_info(deviceName,"dis vlan #{vlanid}")
#定义公用参数
vlanlist = []
#字符串处理
st = rs.index(/VID\s+Type\s+Ports/).to_i
ed = rs.index(/VID\s+Status\s+Property/).to_i
rs1 = rs[st..ed]
rs1 = rs1.split("\n")
s = ''
rs1.each{|item|
vlanid = ''
vlantype = ''
status = ''
#if /(\d+)\s+(\w+)\s+(enable|disable)\s+default/i.match(item) && $1 !=nil
if item == ""
next
end
if /(\d+)\s+(\w+)\s*/.match(item)
vlanid = $1
vlantype = $2
end
if vlanid == ""
next
end
rs.each_line{|item2|
if /(#{vlanid})\s+(enable|disable)\s+default/i.match(item2)
status = $2
end
}
ds = get_commands_info(deviceName,"vlan #{vlanid}
dis th")
if /description\s+(\S+)/mi.match(ds)
description = $1
end
if description == nil
description = "VLAN" + change_vlanid(vlanid)
end
list = "接口列表"
s = vlanid+vlantype+"Vlan"+status+description+list
vlanlist << s
}
#返回数据
return vlanlist
end |
|