mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
550c00a745
commit
eee6da857f
1 changed files with 30 additions and 12 deletions
|
@ -2986,13 +2986,15 @@ def doImageTransfer(
|
||||||
else:
|
else:
|
||||||
return "Error-110"
|
return "Error-110"
|
||||||
# debugOutput(command)
|
# 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
|
# Confirmation command happens here
|
||||||
command = "y\n"
|
command = "y\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
# retVal = retVal+ waitForDeviceResponse(command, "(yes/no)?", 3, obj)
|
|
||||||
# command = "Yes \n"
|
|
||||||
# debugOutput(command)
|
|
||||||
if(protocol == "ftp"):
|
if(protocol == "ftp"):
|
||||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||||
# Password entry happens here Only for FTP
|
# Password entry happens here Only for FTP
|
||||||
|
@ -3034,12 +3036,20 @@ def doSecureImageTransfer(
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + "@" + \
|
command = "cp " + protocol + " " + protocol + "://" + username + "@" + \
|
||||||
server + "/" + imgPath + " system-image " + type + " vrf management \n"
|
server + "/" + imgPath + " system-image " + type + " vrf management \n"
|
||||||
# debugOutput(command)
|
# 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
|
# Confirmation command happens here
|
||||||
if(protocol == "scp"):
|
if(protocol == "scp"):
|
||||||
command = "y\n"
|
command = "y\n"
|
||||||
# debugOutput(command)
|
# 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"
|
command = "Yes\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
|
||||||
|
@ -3049,7 +3059,12 @@ def doSecureImageTransfer(
|
||||||
elif(protocol == "sftp"):
|
elif(protocol == "sftp"):
|
||||||
command = "y\n"
|
command = "y\n"
|
||||||
# debugOutput(command)
|
# 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"
|
command = "Yes\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||||
|
@ -3160,13 +3175,16 @@ def checkOutputForError(output):
|
||||||
index = output.lower().find("invalid")
|
index = output.lower().find("invalid")
|
||||||
startIndex = index + 8
|
startIndex = index + 8
|
||||||
if(index == -1):
|
if(index == -1):
|
||||||
index = output.lower().find("incorrect")
|
index = output.lower().find("Cannot be enabled in L2 Interface")
|
||||||
startIndex = index + 9
|
startIndex = index + 34
|
||||||
if(index == -1):
|
if(index == -1):
|
||||||
index = output.lower().find("failure")
|
index = output.lower().find("incorrect")
|
||||||
startIndex = index + 8
|
startIndex = index + 10
|
||||||
if(index == -1):
|
if(index == -1):
|
||||||
return None
|
index = output.lower().find("failure")
|
||||||
|
startIndex = index + 8
|
||||||
|
if(index == -1):
|
||||||
|
return None
|
||||||
|
|
||||||
endIndex = startIndex + 3
|
endIndex = startIndex + 3
|
||||||
errorCode = output[startIndex:endIndex]
|
errorCode = output[startIndex:endIndex]
|
||||||
|
|
Loading…
Reference in a new issue