目前项目要求解析被采集的设备上的配置文件,文件格式如下
interfaces {
ge-1/0/1 {
description pT:CQ-GYQ-WLD-BAS-2.MAN.ME60-X16.163:1GE::ETH-8/1/2;
vlan-tagging;
mtu 9192;
hold-time up 60000 down 0;
link-mode full-duplex;
gigether-options {
no-auto-negotiation;
}
unit 2 {
vlan-id 2;
family inet {
address 58.43.34.105/30;
}
}
unit 3 {
vlan-id 3;
family inet {
address 172.1.1.33/30;
}
}
}
}
大概想得到的内容格式就是设备->端口->单元->组,ip
{:interfaces => {:port_1 =>{:unit_1 => "address_1" ,:unit_2 => "address_2" }}}
不知道有木有简便一点的方法,怎么样才能按 { } 的层次解析出想要的信息呢