I would like to get value of advertise-interval in vrrp-group 100. And I would like to use Perl API.
show config
interfaces {
ethernet eth0 {
address dhcp
duplex auto
hw-id 00:0c:29:8f:10:55
smp_affinity auto
speed auto
vrrp {
vrrp-group 100 {
advertise-interval 1
description test
preempt true
virtual-address 10.10.10.0/24
}
}
Work fine as I expected. But I don't need foreach part.
#!/usr/bin/perl -w
use lib '/opt/vyatta/share/perl5';
use Vyatta::Config;
$config = new Vyatta::Config;
$config->setLevel("interfaces ethernet eth0 vrrp vrrp-group 100");
my @c = $config->listNodes();
#=begin
foreach my $i ( @c ){
print $i,"\n";
}
#=end
print $config->returnValue("advertise-interval"),"\n";
Execution result.
vyos@foo# perl d.pl
advertise-interval
description
preempt
virtual-address
1
[edit]
So I enabled =begin and =end part.
use lib '/opt/vyatta/share/perl5';
use Vyatta::Config;
$config = new Vyatta::Config;
$config->setLevel("interfaces ethernet eth0 vrrp vrrp-group 100");
my @c = $config->listNodes();
=begin
foreach my $i ( @c ){
print $i,"\n";
}
=end
print $config->returnValue("advertise-interval"),"\n";
I expected it output advertise-interval value. But none of output.
vyos@foo# perl d.pl
[edit]
vyos@foo:~$ show version
Version: VyOS 1.1.0
Description: VyOS 1.1.0 (helium)
Copyright: 2014 VyOS maintainers and contributors
Built by: maintainers@vyos.net
Built on: Thu Oct 9 22:27:26 UTC 2014
Build ID: 1410092227-af6433f
I am getting the error :
calling cfgPathGetChildNodes() without config session at /opt/vyatta/share/perl5/Vyatta/Config.pm line 122
Please help me on this.
Resolved :
By using respective return statement print $config->returnEffectiveValue("host-name");