App::Netsync::Network - methods for manipulating network structures
This module is responsible for for manipulating an internal view of a network.
use App::Netsync 'devices_interfaces'; use App::Netsync::Network; use feature 'say'; my %node; $node{'ip'} = '10.0.0.1'; $node{'hostname'} = 'host1'; $node{'session'} = App::Netsync::SNMP::Session $node{'ip'}; $node{'info'} = App::Netsync::SNMP::Info $session; my $serial2if2ifName = device_interfaces ($node{'info'}->vendor,$node{'session'}); node_initialize (\%node,$serial2if2ifName); say node_string \%node; node_dump \%node; # or device_initialize (\%node,$_,$serial2if2ifName->{$_}) foreach keys $serial2if2ifName; foreach my $serial (keys %{$node{'devices'}}) { my $device = $node{'devices'}{$serial}; say device_string $device; device_dump $device; } # or foreach my $serial (keys %serial2if2ifName) { $node->{'devices'}{$serial} = \%device; my $device = $node{'devices'}{$serial}; $device->{'node'} = $node; my $if2ifName = $serial2if2ifName{$serial}; interface_initialize ($device,$if2ifName->{$_},$_) foreach keys %$if2ifName; } foreach my $serial (keys %{$node{'devices'}}) { my $device = $node{'devices'}{$serial}; foreach my $ifName (keys %{$device->{'interfaces'}}) { my interface = device->{'interfaces'}{$ifName}; say interface_string $interface; interface_dump $interface; } } my %nodes; $nodes{'10.0.0.1'} = \%node; $nodes{'10.0.0.2'}{'ip'} = '10.0.0.2'; $nodes{'10.0.0.3'}{'ip'} = '10.0.0.3'; $nodes{'10.0.0.4'}{'ip'} = '10.0.0.4'; $nodes{'10.0.0.5'}{'ip'} = '10.0.0.5'; my $n = node_find (\%nodes,'10.0.0.5'); $n->{'ip'} == '10.0.0.5'; $n->{'devices'}{'1A2B3C4D5E6F'}{'serial'} = '1A2B3C4D5E6F'; my $d = device_find (\%nodes,'1A2B3C4D5E6F'); $d->{'serial'} == '1A2B3C4D5E6F'; $d->{'interfaces'}{'ethernet1/1/1'}{'ifName'} = ethernet1/1/1; my $i = interface_find ($n->{'devices'},'ethernet1/1/1'); $i->{'ifName'} = 'ethernet1/1/1';
initialize a new network node
Arguments
( $node , \%serial2if2ifName )
the node to initialize
$node
{ 'devices' => { $serial => $device, }, 'hostname' => SCALAR, 'info' => SNMP::Info, 'ip' => SCALAR, 'session' => SNMP::Session, }
a mapping of interfaces to devices (see App::Netsync::device_interfaces)
initialize a new network device
$device
{ 'interfaces' => { $ifName => $interface, }, 'node' => $node, 'identified' => SCALAR, 'serial' => $serial, }
( $node , $serial , \%if2ifName )
the node to add a new device to
the serial number (unique identifier) of the new device (see node_initialize)
a mapping of SNMP interface IIDs to interface names (see device_interfaces)
initialize a new network interface
$interface
{ 'device' => $device, 'ifName' => $ifName, 'IID' => SCALAR, 'info' => { $field => SCALAR, }, 'identified' => SCALAR, }
( $device , $ifName , $IID [, \%fields ] )
the device to add a new interface to
the name of the new interface
the IID of the new interface
interface-specific key-value pairs
converts $node structure(s) to strings
( @nodes )
an array of nodes to stringify
converts $device structures to strings
( @devices )
an array of devices to stringify
converts $interface structures to strings
( @interfaces )
prints a node structure
an array of nodes to print
prints a device structure
an array of devices to print
prints an interface structure
an array of interfaces to print
check for a node in a set of nodes
( \%nodes , $ip )
an array of nodes to search
the IP address of the node
check for a device in a set of nodes
( \%nodes , $serial )
a unique device identifier
check for a interface in a set of devices
( $devices , $ifName )
an array of devices to search
a unique interface identifier
David Tucker, <dmtucker at ucsc.edu>
<dmtucker at ucsc.edu>
This module should be changed to use object-orientation. Until then, all of the included functions are exported!
Please report any bugs or feature requests to bug-netsync at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Netsync. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-netsync at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc App::Netsync
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Netsync
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-Netsync
CPAN Ratings
http://cpanratings.perl.org/d/App-Netsync
Search CPAN
http://search.cpan.org/dist/App-Netsync/
Copyright 2013 David Tucker.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install App::Netsync, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Netsync
CPAN shell
perl -MCPAN -e shell install App::Netsync
For more information on module installation, please visit the detailed CPAN module installation guide.