Update CNOS.py to fix error in image download on devices (#28589)

* Update CNOS.py to fix error in image download on devices

* Fixing Bug on Swaping of character indexes of error strings
pull/28693/head
Anil Kumar Muraleedharan 7 years ago committed by Nathaniel Case
parent 550c00a745
commit eee6da857f

@ -2986,13 +2986,15 @@ def doImageTransfer(
else:
return "Error-110"
# debugOutput(command)
retVal = retVal + waitForDeviceResponse(command, "[n]", 3, obj)
response = waitForDeviceResponse(command, "[n]", 3, obj)
if(response.lower().find("error-101")):
retVal = retVal
else:
retVal = retVal + response
# Confirmation command happens here
command = "y\n"
# debugOutput(command)
# retVal = retVal+ waitForDeviceResponse(command, "(yes/no)?", 3, obj)
# command = "Yes \n"
# debugOutput(command)
if(protocol == "ftp"):
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
# Password entry happens here Only for FTP
@ -3034,12 +3036,20 @@ def doSecureImageTransfer(
command = "cp " + protocol + " " + protocol + "://" + username + "@" + \
server + "/" + imgPath + " system-image " + type + " vrf management \n"
# debugOutput(command)
retVal = retVal + waitForDeviceResponse(command, "[n]", 3, obj)
response = waitForDeviceResponse(command, "[n]", 3, obj)
if(response.lower().find("error-101")):
retVal = retVal
else:
retVal = retVal + response
# Confirmation command happens here
if(protocol == "scp"):
command = "y\n"
# debugOutput(command)
retVal = retVal + waitForDeviceResponse(command, "(yes/no)?", 3, obj)
response = waitForDeviceResponse(command, "(yes/no)?", 3, obj)
if(response.lower().find("error-101")):
retVal = retVal
else:
retVal = retVal + response
command = "Yes\n"
# debugOutput(command)
retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
@ -3049,7 +3059,12 @@ def doSecureImageTransfer(
elif(protocol == "sftp"):
command = "y\n"
# debugOutput(command)
retVal = retVal + waitForDeviceResponse(command, "(yes/no)?", 3, obj)
response = waitForDeviceResponse(command, "(yes/no)?", 3, obj)
if(response.lower().find("error-101")):
retVal = retVal
else:
retVal = retVal + response
command = "Yes\n"
# debugOutput(command)
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
@ -3160,13 +3175,16 @@ def checkOutputForError(output):
index = output.lower().find("invalid")
startIndex = index + 8
if(index == -1):
index = output.lower().find("incorrect")
startIndex = index + 9
index = output.lower().find("Cannot be enabled in L2 Interface")
startIndex = index + 34
if(index == -1):
index = output.lower().find("failure")
startIndex = index + 8
index = output.lower().find("incorrect")
startIndex = index + 10
if(index == -1):
return None
index = output.lower().find("failure")
startIndex = index + 8
if(index == -1):
return None
endIndex = startIndex + 3
errorCode = output[startIndex:endIndex]

Loading…
Cancel
Save