Zane C. Bowers-Hadley

NAME

Net::DHCP::Config::Utilities::INI_loader - Loads subnet configurations from a INI file.

VERSION

Version 0.0.1

SYNOPSIS

    use Net::DHCP::Config::Utilities::INI_loader;
    use Net::DHCP::Config::Utilities;
    
    my $dhcp_util = Net::DHCP::Config::Utilities->new;
    
    my $loader = Net::DHCP::Config::Utilities::INI_loader->new( $dhcp_util );
    
    eval{
        $loader->load_file( $file );
    };
    if ( $@ ){
        # do something upon error
        die( $@ );
    }

METHODS

new

This initiates the object.

One argument is required and that is a Net::DHCP::Config::Utilities object to operate on.

    use Net::DHCP::Config::Utilities;
    
    my $dhcp_util = Net::DHCP::Config::Utilities->new;
    
    my $loader = Net::DHCP::Config::Utilities::INI_loader->new( $dhcp_util );

load_file

This loads a specific file in question.

One argument is taken and that is the path to the INI file.

If this encounter any errors, it will die.

    eval{
        $load->load_file( $file );
    };
    if ( $@ ){
        # do something upon error
        die( $@ );
    }

load_dir

This loads the specified directory.

Two arguments are taken.

The first and required is the directory to load.

The second and optional is the name glob to use. If none is specified then '*.dhcp.ini' is used.

Upon error, this will die.

    my $loaded;
    eval{
        $loaded = $load_dir->load_dir{ $dir };
    };
    if( $@ ){
        die( 'Failed to load... '.$@ );
    }else{
        print "Loaded ".$loaded." files.";
    }

INI EXPECTATIONS

Each sesction of a INI file is treated as its own subnet.

The variable/values taken must be understood by Net::DHCP::Config::Utilities::Subnet.

If the variable base is not specified, the section name is used.

Any variable matching /^range/ is added to the ranges array used when creating the subnet.

    [10.0.0.0]
    mask=255.255.0.0
    dns=10.0.0.1 , 10.0.10.1
    desc=a /16
    routers=10.0.0.1
    
    [foo]
    base=192.168.0.0
    mask=255.255.0.0
    dns=10.0.0.1 , 10.0.10.1
    routers=192.168.0.1
    range=192.168.0.100 192.168.0.200

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

Please report any bugs or feature requests to bug-net-dhcp-config-utilities at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-DHCP-Config-Utilities. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Net::DHCP::Config::Utilities

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2019 by Zane C. Bowers-Hadley.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)