Cisco-Conf

 view release on metacpan or  search on metacpan

lib/Cisco/Conf.pm  view on Meta::CPAN

	if ($fh->isa("IO::AtomicFile")) {
	    $fh->delete();
	}
	die "Error while writing $file: $!";
    }
    if (!$fh->close()) {
	die "Fatal error while writing $file, contents may be destroyed: $!";
    }
}

sub Add($$$) {
    my($class, $file, $attrs) = @_;
    my($config) = $class->_ReadConfigFile($file);

    if ($< != 0  ||  $> != 0) {
	die "Must be root to add new routers.\n";
    } 

    # Verify the new configuration
    my($errors) = '';
    if (!$attrs->{'name'}) {

lib/Cisco/Conf.pm  view on Meta::CPAN


=head2 Remove($configFile, $name)

(Class method) Removes configuration C<$name> from the list of configurations
in the file C<$configFile>.

Only root may add or remove configurations.

=cut

sub Remove($$$) {
    my($class, $file, $name) = @_;

    if ($< != 0  ||  $> != 0) {
	die "Must be root to remove routers.\n";
    } 

    my($config) = $class->_ReadConfigFile($file);
    if (!exists($config->{'hosts'}->{$name})) {
	die "A host $name doesn't exist.";
    }

lib/Cisco/Conf.pm  view on Meta::CPAN

configuration file. Editing takes place in the directory $tmpDir,
so that we can change the EUID to the users.

Example:

    $self->Edit('emacs', 'myrouter.conf', '/tmp');

=cut


sub _System($$) {
    my($class, $command) = @_;
    $! = 0;
    my $rc = system $command;
    if ($rc == 0xff00) {
	die "Command $command failed: " .
	    ($!  ||  "Unknown system error");
    } elsif ($rc) {
	die "Command $command exited, error status $rc";
    }
}



( run in 0.369 second using v1.01-cache-2.11-cpan-1f129e94a17 )