Table of Contents

esmith::NetworksDB

esmith::NetworksDB(3) User Contributed Perl Documentationesmith::NetworksDB(3)

if you want the latest documentation, do

perldoc -U esmith::NetworksDB

NAME

     esmith::NetworksDB - interface to esmith networks database

SYNOPSIS

         use esmith::NetworksDB;
         my $c = esmith::NetworksDB->open;
         # everything else works just like esmith::DB::db

DESCRIPTION

This module provides an abstracted interface to the esmith networks database.

Unless otherwise noted, esmith::NetworksDB acts like esmith::DB::db.

Original network database methods

open

Like esmith::DB→open, but if given no $file it will try to open the file in the ESMITH_NETWORKS_DB environment variable or networks.

open_ro

Like esmith::DB→open_ro, but if given no $file it will try to open the file in the ESMITH_NETWORKS_DB environment variable or networks.

networks

Return a list of all objects of type “network”.

local_access_spec ([$access])

Compute the network/netmask entries which are to treated as local access.

There is also an optional access parameter which can further restrict the values returned. If “access” is “localhost”, this routine will only return a single value, equating to access from localhost only.

If called in scalar context, the returned string is suitable for use in /etc/hosts.allow, smb.conf and httpd.conf, for example:

         127.0.0.1 192.168.1.1/255.255.255.0

Note: The elements are space separated, which is suitable for use in hosts.allow, smb.conf and httpd.conf. httpd.conf does not permit comma separated lists in “allow from” directives. Each element is either an IP address, or a network/netmask string.

If called in list context, returns the array of addresses and network/netmask strings. It’s trivial, of course, to convert an array to a comma separated list :-)

my $ndb = esmith::NetworksDB->open_ro;
my @access = $ndb->local_access_spec;

then

my $access = join ( ",", @access);

Network interfaces methods

interfaces

             my @interfaces = $interfaces->interfaces;

Returns a list of all interface records in the database.

zones

             my @zones = $interfaces->zones;

Returns a list of all records of type ’zone’.

ethernets

             my @interfaces = $interfaces->ethernets;

Returns a list of all interfaces of type ’ethernet’.

bridges

             my @interfaces = $interfaces->bridges;

Returns a list of all interfaces of type ’bridges’.

bonds

             my @interfaces = $interfaces->bonds;

Returns a list of all interfaces of type ’bond’.

aliases

             my @interfaces = $interfaces->aliases;

Returns a list of all interfaces of type ’aliases’.

ipsecs

             my @interfaces = $interfaces->ipsecs;

Returns a list of all interfaces of type ’ipsecs’.

get_by_role

             my @interfaces = $interfaces->get_by_role('myrole');

Returns the interface(s) with the given role, if exsists. Returns undef, otherwise.

The return type is context sensible. In array context a list is returned, in scalar context a Record is returned, if at least one exists.

green

Returns the interface(s) with green role.

orange

Returns the interface(s) with orange role.

blue

Returns the interface(s) with blue role.

yellow

Returns the interface(s) with yellowe role.

red

Returns the interface(s) with red role.

AUTHOR

     Giacomo Sanchietti - Nethesis <support@nethesis.it>

SEE ALSO

     esmith::ConfigDB

perl v5.10.1 2015-05-20 esmith::NetworksDB(3) (END)