我正在尝试从我的输出中获取 csv 文件。
use Net::Cisco::ISE;
use Data::Dumper;
use Text::CSV;
my $ise = Net::Cisco::ISE->new(hostname=>'hostname', username=>'user', password=>'user');
$ise->namespace3;
$ise->namespace5;
my $networkdevices = $ise->networkdevices;
for my $name (keys %{$networkdevices})
{
print Dumper $ise->networkdevices("id" => $networkdevices->{$name}->id);
}
输出:
$VAR1 = bless( {
'NetworkDeviceGroupList' => {
'NetworkDeviceGroup' => [
'Device Type#All Device Types',
'IPSEC#Is IPSEC Device#No',
'Location#All Locations'
]
},
'tacacsSettings' => {
'previousSharedSecretExpiry' => '0',
'connectModeOptions' => 'OFF',
'sharedSecret' => '******'
},
'NetworkDeviceIPList' => {
'NetworkDeviceIP' => {
'mask' => '24',
'ipaddress' => '10.66.0.0'
}
},
'name' => 'LAB-Distri',
'coaPort' => '1700',
'authenticationSettings' => {
'radiusSharedSecret' => '******',
'keyInputFormat' => 'ASCII',
'enableKeyWrap' => 'false',
'networkProtocol' => 'RADIUS'
},
'profileName' => 'Cisco',
'id' => '3d21e200-a534-11e3-82cc-00505694f123'
}, 'Net::Cisco::ISE::NetworkDevice' );
这个脚本应该在控制台中给我我的 wiched 元素(ipadress 和名称),但它不起作用
foreach $name (keys %{$networkdevices}){
print
my $ip = $networkdevices{$name}{'ipaddress'};
my $name = $networkdevices{$name}{'name'};
}
最后,我需要一个包含设备名称和 IP 地址的 csv 文件。
现在我只使用两种方法:Name
和NetworkDeviceIPList
(只是为了清理我的输出信息)。不幸的 Net::Cisco::ISE
是,没有办法只IPs
获得ips。我可以打电话NetworkDeviceIPList
得到:
for my $name (keys %{$networkdevices}){
my $device = $ise->networkdevices("id" => $networkdevices->{$name}->id);
print Dumper $device->name;
print Dumper $device->NetworkDeviceIPList;
}
我有这个输出:
$VAR1 = 'LAB-W';
$VAR1 = {
'NetworkDeviceIP' => {
'mask' => '32',
'ipaddress' => '10.66.1.12'
}
};
但我现在不知道如何从这个输出 csv 数据中获取名称和 ips 数组。