ASCII Configuration Generator (ACG) for Nortel Switches
There was one problem though… the SNMP OID has yet to be documented in the Nortel SNMP MIBS. I had to run a packet trace against Nortel’s Device Manager to determine the OID that Device Manager was using to initiate the manual config upload. I found that the OID was ”
1.3.6.1.4.1.45.1.6.4.4.19.0″
I took my existing script and created a new subroutine and had everything working within about 30 minutes.
Here’s some of the code I wrote;
############################################################################
# Subroutine baystack_tftp_config_ascii
#
# Purpose: use SNMP to instruct BayStack switches to TFTP upload their
# ASCII configuration file to the central TFTP server
############################################################################
sub baystack_tftp_config_ascii {
#s5AgSysTftpServerAddress
#s5AgSysAsciiConfigFilename
#s5AgSysAsciiConfigManualUpload (NOT IN THE MIBS) USE 1.3.6.1.4.1.45.1.6.4.4.19.0
# snmpset -v2c -cprivate 10.1.1.100 1.3.6.1.4.1.45.1.6.4.4.19.0 i 4
# Declare Local Variables
my $setresult;
$filename = "ascii/".$filename;
my $sess = new SNMP::Session ( DestHost => $snmphost,
Community => $community,
Version => SNMPVER );
my $vars = new SNMP::VarList(
['s5AgSysTftpServerAddress', 0, "10.1.1.20",],
['s5AgSysAsciiConfigFilename', 0, $filename,] );
my $go = new SNMP::VarList(
['.1.3.6.1.4.1.45.1.6.4.4.19', 0, 4, 'INTEGER'] );
&check_filename($filename);
# Set TFTP source and destination strings
$setresult = $sess->set($vars);
if ( $sess->{ErrorStr} ) {
print "ERROR: {BayStack} problem setting the TFTP parameters (TFTP IP, FILENAME) for $snmphost\n";
print "ERROR: {BayStack} sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# Start TFTP copy
$setresult = $sess->set($go);
if ( $sess->{ErrorStr} ) {
print "ERROR: {BayStack} problem setting the TFTP action bit for $snmphost\n";
print "ERROR: {BayStack} sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# Pause while the TFTP copy completes
sleep $PAUSE;
# Check to see if the TFTP copy completed
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
if ( $sess->{ErrorStr} ) {
print "ERROR: problem checking the TFTP result for $snmphost\n";
print "ERROR: sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# If TFTP failed output error message
if ($setresult != 1) {
while ($setresult == 2) {
print "DEBUG: config upload status = $setresult (waiting)\n" if (DEBUG);
sleep $PAUSE;
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
} #end while
} #end if $test ne "success"
# If the upload command failed let's try again
if ($setresult == 3) {
print "DEBUG: initial command returned $setresult\n" if (DEBUG);
print "DEBUG: lets try the upload command again\n" if (DEBUG);
# Let's pause here for a few seconds since the previous command failed
sleep $PAUSE;
# Start TFTP copy
$setresult = $sess->set($go);
if ( $sess->{ErrorStr} ) {
print "ERROR: problem setting the TFTP action bit for $snmphost\n";
print "ERROR: sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# Pause while the TFTP copy completes
sleep $PAUSE;
# Check to see if the TFTP copy completed
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
if ( $sess->{ErrorStr} ) {
print "ERROR: problem checking the TFTP result for $snmphost\n";
print "ERROR: sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# If TFTP failed output error message
if ($setresult != 1) {
while ($setresult == 2) {
print "DEBUG: config upload status = $setresult (waiting)\n" if (DEBUG);
sleep $PAUSE;
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
} #end while
} #end if
} #end if
if ($setresult != 1) {
print "DEBUG: $snmphost config upload *FAILED*!\n";
print SENDMAIL "ERROR:$snmphost ($sysObjectID) config (ASCII) upload *FAILED*!
\n";
} elsif ($setresult == 1) {
print SENDMAIL "$snmphost ($sysObjectID) was successful (ASCII)
\n";
print "DEBUG: $snmphost ($sysObjectID) was successful (ASCII)\n";
} else {
print "DEBUG: unknown error return = $setresult (ASCII)" if (DEBUG);
} #end if
print "DEBUG: upload config file results = $setresult (ASCII)\n" if (DEBUG);
return 1;
} #end sub baystack_tftp_config_ascii
Cheers!
posted in Scripting | 4 Comments | 434 views

