Guys

I'm trying to retrieve the local state of the dhcp server using the above module.
however, I can't get it to work using he below code

#! /usr/bin/perl use Net::ISC::DHCPd::OMAPI; my $omapi = Net::ISC::DHCPd::OMAPI->new( key => 'omkey ' . 'xxxxxx +' ); $omapi->connect or die "Could not connect to server: ".$omapi->err +str."\n"; # as per cpan page # my $failover = $omapi->new_object("failover",(name => 'st1_dhcpb' +)); # omapi cpan page # my $failover = $omapi->new_object(failover=>(name => 'st1_dhcpb', +)); # as per POD # my %failover_hash = ( 'name' => 'st1_dhcpb'); # my $failover = $omapi->new_object("failover" => %failover_hash); # as per github example my $failover = $omapi->new_object('failover') or die "Could not create failover: ".$omapi->errstr." +\n"; $failover->name('st1_dhcpb'); # Try to get info (equiv to cli 'open' cmd) $failover->read or die "Could not read failover: ".$omapi->errstr +."\n";
As you can see, I've tried various methods.

Setting debug on (DHCP_OMAPI_DEBUG=1) at the shell level gives

$ port 7911 $ server 127.0.0.1 $ key omkey xxxxxx $ connect obj: <null> $ new failover obj: failover $ open can't open object: not found obj: failover $ close obj: <null> Could not read failover:
Using omshell interactively
omshell > server localhost > port 7911 > key omkey "xxxxxx" > connect obj: <null> > new failover-state obj: failover-state > set name = "st1_dhcpb" obj: failover-state name = "st1_dhcpb" > open obj: failover-state name = "st1_dhcpb" partner-address = 00:00:71:02:00:00:00:00 . . . partner-state = 00:00:00:02 local-state = 00:00:00:02 .
works fine as you can see.
Has anybody got this to work?

Cheers
Chris


In reply to Howto use Net::ISC::DHCPd::OMAPI to get failover state by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.