Unix::Sysadmin::List - List base class
use Unix::Sysadmin::List::Host; use Unix::Sysadmin::List::User; use Unix::Sysadmin::List::Group; use Unix::Sysadmin::List::Automount; use Unix::Sysadmin::List::Netgroup;
$ul = Unix::Sysadmin::List::User->new(); $hl = Unix::Sysadmin::List::Host->new(); $gl = Unix::Sysadmin::List::Group->new(); $al = Unix::Sysadmin::List::Automount->new(); $nl = Unix::Sysadmin::List::Netgroup->new();
return empty List:: objects of the appropriate type
Or:
use Unix::Sysadmin::List::Host; use Unix::Sysadmin::List::User; use Unix::Sysadmin::List::Group; use Unix::Sysadmin::List::Automount; use Unix::Sysadmin::List::Netgroup;
$ul = Unix::Sysadmin::List::User->load(); $hl = Unix::Sysadmin::List::Host->load(); $gl = Unix::Sysadmin::List::Group->load(); $al = Unix::Sysadmin::List::Automount->load(); $nl = Unix::Sysadmin::List::Netgroup->load();
load lists of objects from files.
This abstract class describes generic lists of objects. Particular object types are implemented by subclasses. The subclasses currently implemented are:
The Unix::Sysadmin::List base class defines a set of methods for manipulating lists of entity objects. These methods are described first in the following section. Each derived class also implements a set of abstract methods that all List classes share. These shared methods are described briefly in the section after next. Detailed descriptions of their behavior may be found in the man page describing the specific class's programming interface. Finally, derived classes may implement methods and/or properties specific to theparticular list. These are described in their respective man pages. in the following sections, Type stands for one of Host, User, Group, Automount or Netgroup.
The following methods and properties are implemented by the List class itself and shared by all List subclasses
new()
load()
filename()
and returns the list object.
add($object)
delete($recnum)
$self->current()
is set to undef.
deleteCurrent()
$self->current()
object from the list
$self->current()
is set to the old current +1, or
undef if at the end of the list
goto($recnum)
$self->current()
to the object at index $recnum in the list
Returns the object or undef if $recnum < 0 || $recnum >= $self->numobjs()
first()
$self->goto()
the first object in the list
Returns the object or undef if $self->numobjs()
== 0
last()
$self->goto()
the last object in the list
Returns the object or undef if $self->numobjs()
== 0
prev()
$self->goto()
the previous object in the list.
Returns undef if $self->current()
== 0
next()
$self->goto()
the next object in the list.
Returns undef if $self->current()
== $self->numobjs()
-1
search( {SEARCH=>"value"})
$self->validsortorders()
. Searches of this type return only one
object and require only a single hash lookup, so they are fast
and efficient.
search( {SEARCH=>Index, VALUE=>value})
dump()
cat
ing the database file.)
save()
numobjs()
current()
current()
< $self->numobjs()
, or current()
== undef
The following methods are implemented bt each of the list subclasses. See the man pages for each specific class for details.
loadOne(FILEHANDLE)
load()
method of the List class. The subclass calls the load()
method of the entity class (e.g. Unix::Sysadmin::User) with
the FILEHANDLE passed as its parameter, and returns the new
entity object for storage in the list.
newChild()
indexer(OBJECT)
sortorder()
or sortorder(Index)
$self->validsortorders()
.
validsortorders()
$self->search()
calls with one parameter reference.
update()
genFiles({ HOST=>HostObj })
installFiles({ HOST=>HostObj })
filename()
or filename("newfilename")
The following methods are implemented by the Unix::Sysadmin::List::Automount class:
updateFrom*amtype*()
update()
method. *amtype* is one of 'amd' or 'autofs'.
SunOS. Copies the master's configuration file or files,
parses the contents and merges them with the existing list. Adds new entries
with default values. Updates existing entries with changed values.
genFiles()
method. Generates an amd.map file from the list
for host HostObj.
genAutofsMaps({ HOST=>HostObj })
genFiles()
method. Generates Automounter maps drom the list
for host HostObj.
refreshAMDLinks({ HOST=>HostObj })
installFiles()
method. Creates links for amd from the list
for host HostObj.
kickAutomounter({ HOST=>HostObj })
installFiles()
method. Restarts amd or the automounter on
host HostObj.
The following method is implemented by the Unix::Sysadmin::List::Host class:
isManageable("hostname")
The tests conducted are, in order:
o Is the host the ``canonical master''? The canonical master's configuration is used as the basis for much of the management of other hosts and cannot itself be managed. Returns ``hostname is the canonical master host'' if true.
o Is the host in the current list? Returns ``Can't find hostname in host database'' if not.
o Does the host respond to ping? Returns ``hostname not pingable'' if not.
o Is the host running a secure shell daemon? Returns "hostname not running sshd" if not.
o Will the host accept our ssh key? Returns ``hostname doesn't like our ssh key'' if not.
It might seem that these tests should live in the Host object itself, but I wanted to test to see if the host was in the list too.
Use this method like this:
$host=$list-E<gt>isManageable("hostname"); if (ref($host) eq ''){ print "error: $host\n"; die "a bloody death"; } else { do something Host-like with $host .. }
The following method is implemented by the Unix::Sysadmin::List::Netgroup class:
expand("netgroup")
The following methods are implemented by the Unix::Sysadmin::List::User class:
updateFrom*OS*()
update()
method. *OS* is one of BSD or LinuxorSolaris.
Copies the master's configuration file or files,
parses the contents and merges them with the existing list.
genBSDPwFile({ HOST=>HostObj })
genFiles()
method. Generates a BSD master.passwd file from the list
for host HostObj. Same call is used for both FreeBSD and OpenBSD.
genLinuxPwFile({ HOST=>HostObj })
genFiles()
method. Generates Linux passwd and shadow files from
the list for host HostObj.
genSunOSPwFile({ HOST=>HostObj })
genFiles()
method. Generates Solaris passwd and shadow files
from the list for host HostObj.
Man(3)
pages (programmer's docs):
the Unix::Sysadmin::Host manpage, the Unix::Sysadmin::User manpage, the Unix::Sysadmin::Automount manpage, the Unix::Sysadmin::Group manpage, the Unix::Sysadmin::Netgroup manpage, the Unix::Sysadmin::List manpage, the Unix::Sysadmin::Cmds manpage, the Unix::Sysadmin::Files manpage the Unix::Sysadmin::Utility manpage the Unix::Sysadmin::Config manpage, the Unix::Sysadmin::Scoped manpage
Man(4)
pages (file formats):
the Unix::Sysadmin::Host.list manpage, the Unix::Sysadmin::User.list manpage, the Unix::Sysadmin::Automount.list manpage, the Unix::Sysadmin::Group.list manpage, the Unix::Sysadmin::Netgroup.list manpage
Man(1m)
pages (manager's docs):
the Unix::Sysadmin manpage, the Unix::Sysadmin::Setup manpage the usasetup manpage
Howard Owen <hbo@egbok.com> =cut