NAME
Cisco::CopyConfig - IOS running-config manipulation
SYNOPSIS
use Cisco::CopyConfig ();
see METHODS section below
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.
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:
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 2dcf0eeca916a5 view backup RW 10
end
METHODS
- 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, ] );
- copy
-
Copy the running-config to a TFTP server file. This is a convenient means of backing up a device configuration.
$config->copy($tftp_address, $tftp_file);
- merge
-
Modify or "merge" the current running config with a TFTP server file. This is a conveient means of altering device configuration.
$config->copy($tftp_address, $tftp_file);
- error
-
Return the last error message, if any. It may be more convenient to reference the error variable directly, $config->{err}
$config->error();
EXAMPLE
Using 10.0.1.3 as a TFTP server, the following example copies the running-config of lab-router-a:
$tftp_a = '10.0.1.3';
$tftp_f = '/tftpboot/lab-router-a.config';
$host_a = 'lab-router-a';
$comm_s = '2dcf0eeca916a5';
$config = Cisco::CopyConfig->new(
Host => $host_a,
Comm => $comm_s
);
if ($config->copy($tftp_a, $tftp_f)) {
print "${host_a}:running-config -> ${tftp_a}:${tftp_f}\n";
}
else {
print "$config->{err}\n";
}
PREREQUISITES
This module requires the Net::SNMP and Socket modules.
BUGS
Local file creation and permissions checking are not performed, as TFTP file destinations can be somewhere other than the local system.
Only SNMP v1 and v2 are currently supported in this module. SNMP v3 is on the TODO list.
AUTHORS
Aaron Scarisbrick <aaronsca@cpan.org>
DISCLAIMER
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.