Net::ISC::DHCPd::Config - Parse and create ISC DHCPd config
use Net::ISC::DHCPd::Config; my $config = Net::ISC::DHCPd::Config->new( file => '/etc/dhcpd3/dhcpd.conf', ); # parse the config $config->parse; # parsing includes are lazy for my $include ($config->includes) { $include->parse; } print $config->includes->[0]->hosts->[0]->dump; $config->add_host({ name => 'foo', filenames => [{ file => 'pxelinux.0' }], }); if($config->find_hosts({ name => 'foo' })) { say "Found host by name='foo'"; } if($config->remove_includes({ file => 'some/file' })) { say "Removed included file by file='some/file'"; } print $config->generate;
An object constructed from this class represents the config for a given dhcpd server. The config file passed on to the construted can either be read or written to. As shown in the "SYNOPSIS", the object has the method parse, which will read the config (line by line) and create the appropriate objects representing each part of the config. The result is an object graph where the objects has pointer back to the "parent" and any number of children of different types. (Ex: "hosts", "subnets", ...)
parse
It is also possible to start from scratch with an empty object, and use any of the add_foo methods to create the object graph. After creating/modifying the graph, the actual config text can be retrieved using "generate".
add_foo
This class does the role Net::ISC::DHCPd::Config::Root.
Config |- Config::Authoritative |- Config::Class |- Config::SubClass |- Config::Include |- Config::Conditional |- Config::FailoverPeer |- Config::Subnet | |- Config::Option | |- Config::Declaration | |- Config::Range | |- Config::Host | | |- ... | |- Config::Filename | '- Config::Pool | |- Option | |- Range | '- KeyValue | |- Config::SharedNetwork | |- Config::Subnet | | |- ... | |- Config::Declaration | '- Config::KeyValue | |- Config::Group | |- Config::Host | | |- ... | |- Config::Option | |- Config::Declaration | '- Config::KeyValue | |- Config::Host | |- Config::Option | |- Config::Filename | |- Config::Declaration | '- Config::KeyValue | |- Config::OptionSpace |- Config::OptionCode | |- Config::Option |- Config::Declaration * |- Config::Function |- Config::KeyValue '- Config::Single *
See "regex" in Net::ISC::DHCPd::Config::Role.
See "file" in Net::ISC::DHCPd::Config::Root.
See "parent" in Net::ISC::DHCPd::Config::Role.
See "root" in Net::ISC::DHCPd::Config::Role.
This attribute is different from "parent" in Net::ISC::DHCPd::Config::Role: It holds an undefined value, which is used to indicate that this object is the top node in the tree. See Net::ISC::DHCPd::Config::Include if you want a different behavior.
See "children" in Net::ISC::DHCPd::Config::Role.
List of parsed Net::ISC::DHCPd::Config::Host objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::Subnet objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::SharedNetwork objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::Function objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::OptionSpace objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::Option objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::Include objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::Class objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::SubClass objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
List of parsed Net::ISC::DHCPd::Config::KeyValue objects. See "children" in Net::ISC::DHCPd::Config::Role for details on how to add, update or remove these objects.
See "parse" in Net::ISC::DHCPd::Config::Role.
See "generate" in Net::ISC::DHCPd::Config::Root.
See Net::ISC::DHCPd.
To install Net::ISC::DHCPd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::ISC::DHCPd
CPAN shell
perl -MCPAN -e shell install Net::ISC::DHCPd
For more information on module installation, please visit the detailed CPAN module installation guide.