Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xiangchu0/bc4d9a9358a7c0f1e014024b92a9aa34 to your computer and use it in GitHub Desktop.

Select an option

Save xiangchu0/bc4d9a9358a7c0f1e014024b92a9aa34 to your computer and use it in GitHub Desktop.

Revisions

  1. @hiroyuki-sato hiroyuki-sato revised this gist Nov 14, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile3.pl
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,9 @@
    my @c = $config->listNodes();

    #=begin
    foreach my $i ( @c ){
    print $i,"\n";
    }
    #foreach my $i ( @c ){
    # print $i,"\n";
    #}
    #=end

    print $config->returnValue("advertise-interval"),"\n";
  2. @hiroyuki-sato hiroyuki-sato revised this gist Nov 14, 2014. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions gistfile3.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/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";
  3. @hiroyuki-sato hiroyuki-sato renamed this gist Nov 14, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @hiroyuki-sato hiroyuki-sato revised this gist Nov 14, 2014. No changes.
  5. @hiroyuki-sato hiroyuki-sato revised this gist Nov 14, 2014. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions Work code
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/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();

    foreach my $i ( @c ){
    print $i,"\n";
    }

    print $config->returnValue("advertise-interval"),"\n";
  6. @hiroyuki-sato hiroyuki-sato revised this gist Nov 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -79,7 +79,7 @@ So I enabled =begin and =end part.
    I expected it output advertise-interval value.
    But none of output.

    vyos@foo# vi d.pl
    vyos@foo# perl d.pl
    [edit]

    ### show version
  7. @hiroyuki-sato hiroyuki-sato revised this gist Nov 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ### Goal

    I would like to get value of "advertise-interval" in vrrp-group 100.
    I would like to get value of **advertise-interval** in vrrp-group 100.
    And I would like to use Perl API.

    show config
  8. @hiroyuki-sato hiroyuki-sato created this gist Nov 14, 2014.
    94 changes: 94 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@


    ### Goal

    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
    }
    }

    ### Sample script1.

    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]

    ### Sample script 2

    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# vi d.pl
    [edit]

    ### show version

    vyos@foo:~$ show version
    Version: VyOS 1.1.0
    Description: VyOS 1.1.0 (helium)
    Copyright: 2014 VyOS maintainers and contributors
    Built by: [email protected]
    Built on: Thu Oct 9 22:27:26 UTC 2014
    Build ID: 1410092227-af6433f