NAME
Net::ISC::DHCPd - Interacts with ISC DHCPd
VERSION
0.09
SYNOPSIS
my $dhcpd = Net::ISC::DHCPd->new(
config => { file => "path/to/config" },
leases => { file => "path/to/leases" },
omapi => { key => "some key" },
);
$self->test('config') or die $self->errstr;
# start the dhcpd server
$dhcpd->start({
user => 'john-doe',
group => 'users',
interfaces => 'eth0',
}) or die $dhcpd->errstr;
print $dhcpd->status;
$dhcpd->restart or die $dhcpd->errstr;
print $dhcpd->status;
$dhcpd->stop or die $dhcpd->errstr;
print $dhcpd->status;
See the tests bundled to this distribution for more examples.
This module is subject for a major rewrite. Patches and comments are welcome - reason for this is that Net::ISC::DHCPd::Process does not work as expected.
DESCRIPTION
This namespace contains three semi-separate projects, which this module binds together: dhcpd.conf, dhcpd.leases and omapi. It is written with Moose which provides classes and roles to represents things like a host, a lease or any other thing.
The distribution as a whole is targeted an audience who configure and/or analyze the Internet Systems Consortium DHCP Server. If you are not familiar with the server, check out the man pages.
ATTRIBUTES
config
This attribute holds a read-only Net::ISC::DHCPd::Config object. It can be set from the constructor, using either an object or a hash-ref. The hash-ref will then be passed on to the constructor.
leases
This attribute holds a read-only Net::ISC::DHCPd::Leases object. It can be set from the constructor, using either an object or a hash-ref. The hash-ref will then be passed on to the constructor.
omapi
This attribute holds a read-only Net::ISC::DHCPd::OMAPI object. It can be set from the constructor, using either an object or a hash-ref. The hash-ref will then be passed on to the constructor.
binary
This attribute holds a Path::Class::File object to the dhcpd binary. It is read-only and the default is "dhcpd3".
pidfile
This attribute holds a Path::Class::File object to the dhcpd binary. It is read-only and the default is "/var/run/dhcp3-server/dhcpd.pid".
process
This attribute holds a read-only Net::ISC::DHCPd::Process object. It can be set from the constructor, using either an object or a hash-ref. The hash-ref will then be passed on to the constructor.
errstr
Holds the last know error as a plain string.
METHODS
start
$any = $self->start(\%args);
Will start the dhcpd server, as long as there is no existing process. See "SYNOPSIS" for example. %args
can have user
, group
and interfaces
which all points to strings. This method returns and integer or undef: "1" means "started". "0" means "already running" and undef
means failed to start the server. Check "errstr" on failure.
TODO: Enable it to start the server as a different user/group.
stop
$bool = $self->stop;
This method will stop a running server. A true return value means that the server got stopped, while false means it could not be stopped. Check errstr on failure.
restart
$bool = $self->restart;
This method will restart a running server or start a stopped server. A true return value means that the server got started, while false means it could not be started/restarted. Check errstr or failure.
status
$str = $self->status;
Returns the status of the DHCPd server: "stopped" or "running".
test
$bool = $self->test("config");
$bool = $self->test("leases");
Will test either the config or leases file. It returns a boolean value which indicates if it is valid or not: True means it is valid, while false means it is invalid. Check "errstr" on failure - it will contain a descriptive string from either this module, $!
or the exit value (integer stored as a string).
BUGS
Please report any bugs or feature requests to bug-net-isc-dhcpd at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-ISC-DHCPd. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT & LICENSE
Copyright 2007 Jan Henning Thorsen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Jan Henning Thorsen, <jhthorsen at cpan.org>
CONTRIBUTORS
Nito Martinez
Alexey Illarionov
Patrick
napetrov