Jan Henning Thorsen > Net-ISC-DHCPd-0.14 > Net::ISC::DHCPd::Config

Download:
Net-ISC-DHCPd-0.14.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  1
Open  1
View/Report Bugs
Source   Latest Release: Net-ISC-DHCPd-0.1703

NAME ^

Net::ISC::DHCPd::Config - Parse and create ISC DHCPd config

SYNOPSIS ^

    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;

DESCRIPTION ^

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", ...)

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".

This class does the role Net::ISC::DHCPd::Config::Root.

POSSIBLE CONFIG GRAPH ^

 Config
  |- Config::Include
  |- 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::OptionSpace::Option
  |
  |- Config::Option
  |- Config::Declaration *
  |- Config::Function
  |- Config::KeyValue
  '- Config::Single      *

ATTRIBUTES ^

file

See "file" in Net::ISC::DHCPd::Config::Root.

parent

See "parent" in Net::ISC::DHCPd::Config::Role.

root

See "root" in Net::ISC::DHCPd::Config::Role.

parent

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.

children

See "children" in Net::ISC::DHCPd::Config::Role.

hosts

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.

subnets

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.

sharednetworks

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.

functions

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.

optionspaces

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.

options

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.

includes

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.

keyvalues

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.

METHODS ^

parse

See "parse" in Net::ISC::DHCPd::Config::Role.

generate

See "generate" in Net::ISC::DHCPd::Config::Root.

COPYRIGHT & LICENSE ^

AUTHOR ^

See Net::ISC::DHCPd.

syntax highlighting: