The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::ISC::DHCPd::OMAPI - Talk to a dhcp server

SYNOPSIS

    my $omapi = Net::ISC::DHCPd::OMAPI->new(
                    key => "dhcpd secret",
                );

    # connect is lazy
    $omapi->connect

    my $lease = $omapi->new_object(lease => (
                    ip_address => "10.19.83.200",
                ));

    if($lease->read) {
        printf("Got hardware_address=%s from ip_address=%s\n",
            $lease->hardware_address,
            $lease->ip_address,
        );
    }

DESCRIPTION

This module provides an API to query and possible change the ISC DHCPd server. The module use OMAPI (Object Management API) which does not require the server to be restarted for changes to apply. It does unfortunately support the protocol natively, but instead fork omshell(1) which this module read and write commands to.

OMAPI is simply a communications mechanism that allows you to manipulate objects, which is stored in the dhcpd.leases file.

See subclasses for more information about the different objects you can manipulate: Net::ISC::DHCPd::OMAPI::Failover, Net::ISC::DHCPd::OMAPI::Group, Net::ISC::DHCPd::OMAPI::Host, and Net::ISC::DHCPd::OMAPI::Lease.

ENVIRONMENT VARIABLES

  • DHCP_OMAPI_DEBUG=1

    This variable will enable debug output.

ATTRIBUTES

server

This attribute is read-only and holds a string describing the remote dhcpd server address. Default value is "127.0.0.1".

port

This attribute is read-only and holds an integer representing the remote dhcpd server port. Default value is "7911".

key

This attribute is read-only and holds a string representing the server secret key. It is in the format $name $secret and the default value is an empty string. An empty string is used for servers without a secret to log in.

errstr

Holds the last know error as a plain string.

METHODS

connect

    $bool = $self->connect;

Will open a connection to the dhcp server. Check "errstr" on failure. A connection means starting the program omshell(1) and trying to log in, if the dhcpd "key" is set.

disconnect

    $bool = $self->disconnect;

Will disconnect from the server. This means killing the omshell(1) program, which then actually will make sure the connection is shut down.

new_object

    $object = $self->new_object($type => %constructor_args);

This method will create a new OMAPI object, which can be used to query and/or manipulate the running dhcpd server.

$type can be "group", "host", or "lease". Will return a new config object.

Example, with $type='host':

 Net::ISC::DHCPd::Config::Host->new(%constructor_args);

COPYRIGHT & LICENSE

AUTHOR

See Net::ISC::DHCPd.