Cisco-CopyConfig
view release on metacpan or search on metacpan
CopyConfig.pm view on Meta::CPAN
1;
}
### -- OIDs taken from CISCO-CONFIG-COPY-MIB-V1SMI.my
###
sub ccCopyProtocol {
('1.3.6.1.4.1.9.9.96.1.1.1.1.2.' . $_[0]->{'rand'}, INTEGER, $_[1])
}
sub ccCopySourceFileType {
('1.3.6.1.4.1.9.9.96.1.1.1.1.3.' . $_[0]->{'rand'}, INTEGER, $_[1])
}
sub ccCopyDestFileType {
('1.3.6.1.4.1.9.9.96.1.1.1.1.4.' . $_[0]->{'rand'}, INTEGER, $_[1])
}
sub ccCopyServerAddress {
('1.3.6.1.4.1.9.9.96.1.1.1.1.5.' . $_[0]->{'rand'}, IPADDRESS, $_[1])
}
sub ccCopyFileName {
('1.3.6.1.4.1.9.9.96.1.1.1.1.6.' . $_[0]->{'rand'}, OCTET_STRING, $_[1])
}
sub ccCopyEntryRowStatus {
('1.3.6.1.4.1.9.9.96.1.1.1.1.14.' . $_[0]->{'rand'}, INTEGER, $_[1])
}
sub ccCopyState {
'1.3.6.1.4.1.9.9.96.1.1.1.1.10.' . $_[0]->{'rand'}
}
sub ccCopyFailCause {
'1.3.6.1.4.1.9.9.96.1.1.1.1.13.' . $_[0]->{'rand'}
}
1; ## - Needed for module
__END__
=head1 NAME
Cisco::CopyConfig - IOS running-config manipulation
=head1 SYNOPSIS
use Cisco::CopyConfig ();
see METHODS section below
=head1 DESCRIPTION
Cisco::CopyConfig provides methods for manipulating the running-config of
devices running IOS via SNMP directed TFTP. This module is essentially a
wrapper for Net::SNMP and the CISCO-CONFIG-COPY-MIB-V1SMI.my MIB schema.
=head1 PREPERATION
A read-write SNMP community needs to be defined on each device, which allows
the setting of parameters to copy or merge a running-config. Below is an
example configuration that attempts to restrict read-write access to only the
10.0.1.3 host (a less guessable community than 'public' would be wise):
access-list 10 permit host 10.0.1.3
access-list 10 deny any
!
snmp-server tftp-server-list 10
snmp-server view backup ciscoMgmt.96.1.1.1.1 included
snmp-server community public view backup RW 10
end
=head1 METHODS
=over 8
=item I<new>
Create a new Cisco::CopyConfig object.
$config = Cisco::CopyConfig->new(
Host => $ios_device_hostname,
Comm => $community_string,
[ Tmout => $snmp_timeout_in_seconds, ]
[ Retry => $snmp_retries_on_failure, ]
);
=item I<copy>
Copy the running-config to a file via TFTP:
$config->copy($tftp_address, $tftp_file);
=item I<merge>
Merge a configuration file into the running-config via TFTP:
$config->merge($tftp_address, $tftp_file);
=item I<error>
Return the last error message, if any. This is a convenience method
that simply returns the value of $config->{'err'}:
$config->error();
=back
=head1 EXAMPLE
Using 10.0.1.3 as a TFTP server, the following example merges a
configuration file into the running-config of lab-router-a, and
then copies the entire config of lab-router-a to a file:
use Cisco::CopyConfig;
$| = 1; # autoflush output
$tftp = '10.0.1.3';
$merge_f = 'new-config.upload';
$copy_f = 'lab-router-a.config';
$host = 'lab-router-a';
$comm = 'public';
$config = Cisco::CopyConfig->new(
Host => $host,
Comm => $comm
);
$path = "/tftpboot/${copy_f}";
open(COPY_FH, "> $path") || die $!;
close(COPY_FH); chmod 0666, $path || die $!;
( run in 2.872 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )