###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### PSGConf::Action::GenerateFile::hosts - action to generate /etc/hosts
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Action::GenerateFile::hosts;
use strict;
use PSGConf::Action::GenerateFile;
our @ISA = qw(PSGConf::Action::GenerateFile);
###############################################################################
### generate method
###############################################################################
sub generate
{
my ($self, $fh, $psgconf) = @_;
map {
print $fh "$_\t";
print $fh join("\t", @{$self->{ip_addrs}->{$_}});
print $fh "\n";
} sort keys %{$self->{ip_addrs}};
return 1;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Action::GenerateFile::hosts - generate /etc/hosts file
=head1 SYNOPSIS
use PSGConf::Action::GenerateFile::hosts;
$psgconf->register_actions(
PSGConf::Action::GenerateFile::hosts->new(
'name' => '/etc/hosts',
'ip_addrs' => {
'A.B.C.D' => [ ... ],
...
},
...
),
...
);
=head1 DESCRIPTION
The B<PSGConf::Action::GenerateFile::hosts> module provides a B<PSGConf>
action class for generating the F</etc/hosts> table.
The B<PSGConf::Action::GenerateFile::hosts> class is derived from the
B<PSGConf::Action::GenerateFile> class, but it defines/overrides the
following methods:
=over 4
=item generate()
Generates the F</etc/hosts> table.
=back
In addition to the attributes supported by
the B<PSGConf::Action::GenerateFile> class, the
B<PSGConf::Action::GenerateFile::hosts> class supports the following
attributes:
=over 4
=item I<ip_addrs>
A hash mapping IP addresses to a list of host names.
=back
=head1 SEE ALSO
L<perl>
L<PSGConf>
L<PSGConf::Action::GenerateFile>
=cut
syntax highlighted by Code2HTML, v. 0.9.1