NAME

Net::Autoconfig - Perl extension for provisioning or reconfiguring network devices.

SYNOPSIS

use Net::Autoconfig::Device;

my $default_device = Net::Autoconfig::Device->new();
my $preconfigured_device = Net::Autoconfig::Device->new(@key_value_pairs);

$default_device->hostname("Device 1");
$default_device->ip_addr("192.168.0.1", "/24");
$default_device->ip_addr("192.168.0.1", "255.255.255.0");
$default_device->set_attributes(@key_value_pairs);

print "Hostname: " . $preconfigured_device->ip_addr();

my ($ip_addr, $netmask, $prefix) = $preconfigured_device->ip_addr();
print "IP info: $ip_addr$prefix ($netmask)";

my $something   = $preconfigured_device->get_attrib("somthing");
my %device_data = $preconfigured_device->get_attrib();

DESCRIPTION

Net::Autoconfig was created to fill the void of having a utility to configured / provision devices in an automated way. The reason for its existence came about from having to deploy 150 new switches that were almost identically configured, except for the names, ip addresses and vlans. The devices had to be unpacked, firmware upgraded, given an initial configuration, and then given their final configuration. This process is error-prone and takes a long time. Using this module enabled one person to configure all 150 switches within a week.

Methods

Public Methods

new()
Create a new Net::Autoconfig::Device object.
Additional info can be configured after the object has been created.
Pass an array with ( key1 => value1, key2 => value2, ...) to initialize
the object with those key values.
$device->new();
Returns a Net::Autoconfig::Device object with default values.
$device->new(@key_value_array);
Returns a Net::Autoconfig::Device object with user defined values.
hostname()
Either returns or sets the hostname of the device depending on if
a parameter is passed or not.
$device->hostname();

returns the hostname

$device->hostname("some_host");

sets the hostname and returns undef

$device->hostname(non string and not undef);

Error!, returns true

ip_addr()
Either sets the ip address or returns the ip addresses (and subnet and
prefix if requested).
$device->ip_addr()
$ip_address = $device->ip_addr();
($ip_address, $netmask, $prefix) = $device->ip_addr();
$device->ip_addr("192.168.10.1");
Sets the ip address

returns undef if successful

returns TRUE if failure
$device->ip_addr("192.168.10.1", "255.255.255.0");
$device->ip_addr("192.168.10.1", "/24");
Sets the ip address and the subnet/netmask.  The method will
add both prefix and netmask to the device.  Send either the
netmask or the prefix.  Whichever you prefer. The method will
calculate the other one for you.

The prefix must be in the form "/\d\d?".  I.e., it needs the
starting forward slash and must be followed by one or two
digits.

returns undef for success

returns TRUE for failure
get_attrib()

Get the value of the specified attribute, or get a hash ref of all of the attribute => value pairings. This provides a mechanism for getting attributes that are either part of the module, or that you have defined. Returns undef if an attribute does not exist.

$favorite_color = $device->get_param("fav_color");
$my_attributes = $device->get_param();
E.g.

$my_attritubes = {
	hostname	=>	"",
	ip_addr		=>	"",
	...
	fav_color	=>	"green",
}
set_attrib()

Set the value of an attribute. If the attribute does not yet exist, create it.

This method is used by passing an array to the method. The method then adds/overwrites existing key => value pairs to the object.

$device->set_attrib("model", "hp2600");
@attribs = ( model => "hp2600", vendor => "hp" );

Returns undef for success Returns TRUE for failure

SEE ALSO

Net::Autoconfig

AUTHOR

Kevin Ehlers <kevin@uoregon.edu>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Kevin Ehlers, University of Oregon.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 665:

You forgot a '=back' before '=head1'