mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Resolving Coverity Issues. (#28056)
This commit is contained in:
parent
8f4bc8150f
commit
ffd701c8d1
1 changed files with 75 additions and 87 deletions
|
@ -359,7 +359,7 @@ def interfaceLevel2Config(
|
||||||
retVal = "Error-234"
|
retVal = "Error-234"
|
||||||
return retVal
|
return retVal
|
||||||
else:
|
else:
|
||||||
command = command # None is taken care here
|
command = command.strip() # None is taken care here
|
||||||
|
|
||||||
elif(interfaceL2Arg2 == "neighbor"):
|
elif(interfaceL2Arg2 == "neighbor"):
|
||||||
command = command + interfaceL2Arg2 + " src-ip "
|
command = command + interfaceL2Arg2 + " src-ip "
|
||||||
|
@ -414,7 +414,7 @@ def interfaceLevel2Config(
|
||||||
# debugOutput("bridge-port")
|
# debugOutput("bridge-port")
|
||||||
command = interfaceL2Arg1 + " "
|
command = interfaceL2Arg1 + " "
|
||||||
if(interfaceL2Arg2 is None):
|
if(interfaceL2Arg2 is None):
|
||||||
command = command
|
command = command.strip()
|
||||||
elif(interfaceL2Arg2 == "access"):
|
elif(interfaceL2Arg2 == "access"):
|
||||||
command = command + interfaceL2Arg2 + " vlan "
|
command = command + interfaceL2Arg2 + " vlan "
|
||||||
value = checkSanityofVariable(
|
value = checkSanityofVariable(
|
||||||
|
@ -542,8 +542,6 @@ def interfaceLevel2Config(
|
||||||
command = command + interfaceL2Arg4 + " "
|
command = command + interfaceL2Arg4 + " "
|
||||||
if(interfaceL2Arg5 == "secondary"):
|
if(interfaceL2Arg5 == "secondary"):
|
||||||
command = command + interfaceL2Arg5
|
command = command + interfaceL2Arg5
|
||||||
elif(interfaceL2Arg5 is None):
|
|
||||||
command = command + interfaceL2Arg5
|
|
||||||
else:
|
else:
|
||||||
retVal = "Error-278"
|
retVal = "Error-278"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -559,7 +557,7 @@ def interfaceLevel2Config(
|
||||||
if(interfaceL2Arg4 == "secondary"):
|
if(interfaceL2Arg4 == "secondary"):
|
||||||
command = command + interfaceL2Arg4
|
command = command + interfaceL2Arg4
|
||||||
elif(interfaceL2Arg4 is None):
|
elif(interfaceL2Arg4 is None):
|
||||||
command = command + interfaceL2Arg4
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
retVal = "Error-278"
|
retVal = "Error-278"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -696,8 +694,7 @@ def interfaceLevel2Config(
|
||||||
if(value == "ok"):
|
if(value == "ok"):
|
||||||
command = command + interfaceL2Arg3 + " "
|
command = command + interfaceL2Arg3 + " "
|
||||||
if(interfaceL2Arg4 == "anycast" or
|
if(interfaceL2Arg4 == "anycast" or
|
||||||
interfaceL2Arg4 == "secondary" or
|
interfaceL2Arg4 == "secondary"):
|
||||||
interfaceL2Arg4 is None):
|
|
||||||
command = command + interfaceL2Arg4
|
command = command + interfaceL2Arg4
|
||||||
else:
|
else:
|
||||||
retVal = "Error-276"
|
retVal = "Error-276"
|
||||||
|
@ -814,7 +811,7 @@ def interfaceLevel2Config(
|
||||||
if(interfaceL2Arg2 == "receive" or
|
if(interfaceL2Arg2 == "receive" or
|
||||||
interfaceL2Arg2 == "trap-notification" or
|
interfaceL2Arg2 == "trap-notification" or
|
||||||
interfaceL2Arg2 == "transmit"):
|
interfaceL2Arg2 == "transmit"):
|
||||||
command = command
|
command = command.strip()
|
||||||
elif(interfaceL2Arg2 == "tlv-select"):
|
elif(interfaceL2Arg2 == "tlv-select"):
|
||||||
value = checkSanityofVariable(
|
value = checkSanityofVariable(
|
||||||
deviceType, "lldp_tlv_options", interfaceL2Arg3)
|
deviceType, "lldp_tlv_options", interfaceL2Arg3)
|
||||||
|
@ -1300,7 +1297,7 @@ def bgpNeighborAFConfig(
|
||||||
if(bgpNeighborAFArg3 is not None):
|
if(bgpNeighborAFArg3 is not None):
|
||||||
command = command + bgpNeighborAFArg3
|
command = command + bgpNeighborAFArg3
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
retVal = "Error-326"
|
retVal = "Error-326"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -1461,11 +1458,11 @@ def bgpNeighborConfig(
|
||||||
bgpNeighborArg5 == "dual-as"):
|
bgpNeighborArg5 == "dual-as"):
|
||||||
command = command + bgpNeighborArg5
|
command = command + bgpNeighborArg5
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
retVal = "Error-312"
|
retVal = "Error-312"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -1598,17 +1595,12 @@ def bgpAFConfig(
|
||||||
value = checkSanityofVariable(
|
value = checkSanityofVariable(
|
||||||
deviceType, "bgp_aggregate_prefix", bgpAFArg2)
|
deviceType, "bgp_aggregate_prefix", bgpAFArg2)
|
||||||
if(value == "ok"):
|
if(value == "ok"):
|
||||||
command = command + bgpAFArg2 + " "
|
|
||||||
if(bgpAFArg2 is None):
|
if(bgpAFArg2 is None):
|
||||||
command = command
|
command = command.strip()
|
||||||
elif(bgpAFArg2 == "as-set" or bgpAFArg2 == "summary-only"):
|
elif(bgpAFArg2 == "as-set" or bgpAFArg2 == "summary-only"):
|
||||||
command = command + bgpAFArg2 + " "
|
command = command + bgpAFArg2 + " "
|
||||||
if(bgpAFArg3 is None):
|
if((bgpAFArg3 is not None) and (bgpAFArg2 == "as-set")):
|
||||||
command = command
|
|
||||||
elif(bgpAFArg2 == "as-set"):
|
|
||||||
command = command + "summary-only"
|
command = command + "summary-only"
|
||||||
else:
|
|
||||||
command = command + "as-set"
|
|
||||||
else:
|
else:
|
||||||
retVal = "Error-297"
|
retVal = "Error-297"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -1655,7 +1647,7 @@ def bgpAFConfig(
|
||||||
retVal = "Error-295"
|
retVal = "Error-295"
|
||||||
return retVal
|
return retVal
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
retVal = "Error-294"
|
retVal = "Error-294"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -1725,7 +1717,7 @@ def bgpAFConfig(
|
||||||
retVal = "Error-196"
|
retVal = "Error-196"
|
||||||
return retVal
|
return retVal
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
value = checkSanityofVariable(
|
value = checkSanityofVariable(
|
||||||
deviceType, "network_ip_prefix_value", bgpAFArg2)
|
deviceType, "network_ip_prefix_value", bgpAFArg2)
|
||||||
|
@ -1758,7 +1750,7 @@ def bgpAFConfig(
|
||||||
retVal = "Error-299"
|
retVal = "Error-299"
|
||||||
return retVal
|
return retVal
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command.strip()
|
||||||
else:
|
else:
|
||||||
retVal = "Error-300"
|
retVal = "Error-300"
|
||||||
return retVal
|
return retVal
|
||||||
|
@ -1784,9 +1776,8 @@ def bgpAFConfig(
|
||||||
value = checkSanityofVariable(
|
value = checkSanityofVariable(
|
||||||
deviceType, "addrfamily_redistribute_option", bgpAFArg2)
|
deviceType, "addrfamily_redistribute_option", bgpAFArg2)
|
||||||
if(value == "ok"):
|
if(value == "ok"):
|
||||||
command = command + bgpAFArg2 + " "
|
|
||||||
if(bgpAFArg2 is not None):
|
if(bgpAFArg2 is not None):
|
||||||
command = command + "route-map "
|
command = command + bgpAFArg2 + " " + "route-map "
|
||||||
value = checkSanityofVariable(
|
value = checkSanityofVariable(
|
||||||
deviceType, "addrfamily_routemap_name", bgpAFArg3)
|
deviceType, "addrfamily_routemap_name", bgpAFArg3)
|
||||||
if(value == "ok"):
|
if(value == "ok"):
|
||||||
|
@ -2129,8 +2120,6 @@ def vlanConfig(
|
||||||
return retVal
|
return retVal
|
||||||
retVal = "Error-133"
|
retVal = "Error-133"
|
||||||
return retVal
|
return retVal
|
||||||
retVal = "Error-134"
|
|
||||||
return retVal
|
|
||||||
|
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
command = command + "\n"
|
command = command + "\n"
|
||||||
|
@ -2243,7 +2232,7 @@ def createVlan(
|
||||||
# debugOutput("vlanArg3")
|
# debugOutput("vlanArg3")
|
||||||
if(vlanArg3 is None or vlanArg3 == ""):
|
if(vlanArg3 is None or vlanArg3 == ""):
|
||||||
# debugOutput("None or empty")
|
# debugOutput("None or empty")
|
||||||
command = command
|
command = command.strip()
|
||||||
elif(vlanArg3 == "fast-leave"):
|
elif(vlanArg3 == "fast-leave"):
|
||||||
# debugOutput("fast-leave")
|
# debugOutput("fast-leave")
|
||||||
command = command + vlanArg3
|
command = command + vlanArg3
|
||||||
|
@ -2583,23 +2572,22 @@ def doStartupConfigBackUp(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) & (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# config backup command happens here
|
# config backup command happens here
|
||||||
if(protocol == "ftp"):
|
if(protocol == "ftp"):
|
||||||
command = "cp startup-config " + protocol + " " + protocol + "://" + \
|
command = "cp startup-config " + protocol + " " + protocol + "://" + \
|
||||||
username + "@" + server + "/" + path + " vrf management\n"
|
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
||||||
elif(protocol == "tftp"):
|
elif(protocol == "tftp"):
|
||||||
command = "cp startup-config " + protocol + " " + protocol + \
|
command = "cp startup-config " + protocol + " " + protocol + \
|
||||||
"://" + server + "/" + path + " vrf management\n"
|
"://" + server + "/" + confPath + " vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
|
||||||
else:
|
else:
|
||||||
|
@ -2625,15 +2613,14 @@ def doSecureStartupConfigBackUp(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) and (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# config backup command happens here
|
# config backup command happens here
|
||||||
command = "cp startup-config " + protocol + " " + protocol + "://" + \
|
command = "cp startup-config " + protocol + " " + protocol + "://" + \
|
||||||
username + "@" + server + "/" + path + " vrf management\n"
|
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
||||||
if(response.lower().find("error-101")):
|
if(response.lower().find("error-101")):
|
||||||
|
@ -2680,16 +2667,15 @@ def doStartUpConfigRollback(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) & (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# config backup command happens here
|
# config backup command happens here
|
||||||
if(protocol == "ftp"):
|
if(protocol == "ftp"):
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + \
|
command = "cp " + protocol + " " + protocol + "://" + username + \
|
||||||
"@" + server + "/" + path + " startup-config vrf management\n"
|
"@" + server + "/" + confPath + " startup-config vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
|
@ -2698,7 +2684,7 @@ def doStartUpConfigRollback(
|
||||||
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
||||||
elif(protocol == "tftp"):
|
elif(protocol == "tftp"):
|
||||||
command = "cp " + protocol + " " + protocol + "://" + \
|
command = "cp " + protocol + " " + protocol + "://" + \
|
||||||
server + "/" + path + " startup-config vrf management\n"
|
server + "/" + confPath + " startup-config vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
|
retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
|
||||||
command = "y\n"
|
command = "y\n"
|
||||||
|
@ -2726,9 +2712,8 @@ def doSecureStartUpConfigRollback(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) and (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
|
@ -2737,7 +2722,7 @@ def doSecureStartUpConfigRollback(
|
||||||
# cp sftp sftp://root@10.241.106.118/cnos_config/running_config.conf
|
# cp sftp sftp://root@10.241.106.118/cnos_config/running_config.conf
|
||||||
# startup-config vrf management
|
# startup-config vrf management
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + \
|
command = "cp " + protocol + " " + protocol + "://" + username + \
|
||||||
"@" + server + "/" + path + " startup-config vrf management \n"
|
"@" + server + "/" + confPath + " startup-config vrf management \n"
|
||||||
|
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
||||||
|
@ -2789,23 +2774,22 @@ def doRunningConfigBackUp(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) & (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# config backup command happens here
|
# config backup command happens here
|
||||||
if(protocol == "ftp"):
|
if(protocol == "ftp"):
|
||||||
command = "cp running-config " + protocol + " " + protocol + "://" + \
|
command = "cp running-config " + protocol + " " + protocol + "://" + \
|
||||||
username + "@" + server + "/" + path + " vrf management\n"
|
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
||||||
elif(protocol == "tftp"):
|
elif(protocol == "tftp"):
|
||||||
command = "cp running-config " + protocol + " " + protocol + \
|
command = "cp running-config " + protocol + " " + protocol + \
|
||||||
"://" + server + "/" + path + " vrf management\n"
|
"://" + server + "/" + confPath + " vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
|
||||||
else:
|
else:
|
||||||
|
@ -2830,15 +2814,14 @@ def doSecureRunningConfigBackUp(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) and (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# config backup command happens here
|
# config backup command happens here
|
||||||
command = "cp running-config " + protocol + " " + protocol + "://" + \
|
command = "cp running-config " + protocol + " " + protocol + "://" + \
|
||||||
username + "@" + server + "/" + path + " vrf management\n"
|
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
||||||
if(response.lower().find("error-101")):
|
if(response.lower().find("error-101")):
|
||||||
|
@ -2885,23 +2868,22 @@ def doRunningConfigRollback(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) & (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# config backup command happens here
|
# config backup command happens here
|
||||||
if(protocol == "ftp"):
|
if(protocol == "ftp"):
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + \
|
command = "cp " + protocol + " " + protocol + "://" + username + \
|
||||||
"@" + server + "/" + path + " running-config vrf management\n"
|
"@" + server + "/" + confPath + " running-config vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
||||||
elif(protocol == "tftp"):
|
elif(protocol == "tftp"):
|
||||||
command = "cp " + protocol + " " + protocol + "://" + \
|
command = "cp " + protocol + " " + protocol + "://" + \
|
||||||
server + "/" + path + " running-config vrf management\n"
|
server + "/" + confPath + " running-config vrf management\n"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
|
retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
|
||||||
else:
|
else:
|
||||||
|
@ -2927,9 +2909,8 @@ def doSecureRunningConfigRollback(
|
||||||
# password = "Lab4man1"
|
# password = "Lab4man1"
|
||||||
password = confServerPwd
|
password = confServerPwd
|
||||||
|
|
||||||
path = "cnos_config"
|
if((confPath is None) or (confPath is "")):
|
||||||
if((confPath is not None) and (confPath != "")):
|
confPath = "cnos_config"
|
||||||
path = confPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
|
@ -2938,7 +2919,7 @@ def doSecureRunningConfigRollback(
|
||||||
# cp sftp sftp://root@10.241.106.118/cnos_config/running_config.conf
|
# cp sftp sftp://root@10.241.106.118/cnos_config/running_config.conf
|
||||||
# running-config vrf management
|
# running-config vrf management
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + \
|
command = "cp " + protocol + " " + protocol + "://" + username + \
|
||||||
"@" + server + "/" + path + " running-config vrf management \n"
|
"@" + server + "/" + confPath + " running-config vrf management \n"
|
||||||
|
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
||||||
|
@ -2989,20 +2970,19 @@ def doImageTransfer(
|
||||||
if(imgType is not None):
|
if(imgType is not None):
|
||||||
type = imgType.lower()
|
type = imgType.lower()
|
||||||
|
|
||||||
path = "cnos_images"
|
if((imgPath is None) or (imgPath is "")):
|
||||||
if((imgPath is not None) and (imgPath != "")):
|
imgPath = "cnos_images"
|
||||||
path = imgPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# Image transfer command happens here
|
# Image transfer command happens here
|
||||||
if(protocol == "ftp"):
|
if(protocol == "ftp"):
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + \
|
command = "cp " + protocol + " " + protocol + "://" + username + \
|
||||||
"@" + server + "/" + path + " system-image " + type + \
|
"@" + server + "/" + imgPath + " system-image " + type + \
|
||||||
" vrf management\n"
|
" vrf management\n"
|
||||||
elif(protocol == "tftp"):
|
elif(protocol == "tftp"):
|
||||||
command = "cp " + protocol + " " + protocol + "://" + server + \
|
command = "cp " + protocol + " " + protocol + "://" + server + \
|
||||||
"/" + path + " system-image " + type + " vrf management\n"
|
"/" + imgPath + " system-image " + type + " vrf management\n"
|
||||||
else:
|
else:
|
||||||
return "Error-110"
|
return "Error-110"
|
||||||
# debugOutput(command)
|
# debugOutput(command)
|
||||||
|
@ -3045,15 +3025,14 @@ def doSecureImageTransfer(
|
||||||
if(imgType is not None):
|
if(imgType is not None):
|
||||||
type = imgType.lower()
|
type = imgType.lower()
|
||||||
|
|
||||||
path = "cnos_images"
|
if((imgPath is None) or (imgPath is "")):
|
||||||
if((imgPath is not None) and(imgPath != "")):
|
imgPath = "cnos_images"
|
||||||
path = imgPath
|
|
||||||
|
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
# Image transfer command happens here
|
# Image transfer command happens here
|
||||||
command = "cp " + protocol + " " + protocol + "://" + username + "@" + \
|
command = "cp " + protocol + " " + protocol + "://" + username + "@" + \
|
||||||
server + "/" + path + " 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)
|
retVal = retVal + waitForDeviceResponse(command, "[n]", 3, obj)
|
||||||
# Confirmation command happens here
|
# Confirmation command happens here
|
||||||
|
@ -3088,7 +3067,7 @@ def doSecureImageTransfer(
|
||||||
return retVal
|
return retVal
|
||||||
# EOM
|
# EOM
|
||||||
|
|
||||||
# Method for enter enable mnode
|
# Method Method for enter enable mode
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
@ -3144,7 +3123,7 @@ def enterEnableModeForDevice(enablePassword, timeout, obj):
|
||||||
return retVal
|
return retVal
|
||||||
# EOM
|
# EOM
|
||||||
|
|
||||||
# Method for device response wait for a time delay
|
# Method for device response than time delay
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
@ -3226,14 +3205,15 @@ def checkSanityofVariable(deviceType, variableId, variableValue):
|
||||||
def getRuleStringForVariable(deviceType, ruleFile, variableId):
|
def getRuleStringForVariable(deviceType, ruleFile, variableId):
|
||||||
retVal = ""
|
retVal = ""
|
||||||
try:
|
try:
|
||||||
with open(ruleFile, 'r') as f:
|
# with open(ruleFile, 'r') as f:
|
||||||
for line in f:
|
f = open(ruleFile, 'r')
|
||||||
# debugOutput(line)
|
for line in f:
|
||||||
if(':' in line):
|
# debugOutput(line)
|
||||||
data = line.split(':')
|
if(':' in line):
|
||||||
# debugOutput(data[0])
|
data = line.split(':')
|
||||||
if(data[0].strip() == variableId):
|
# debugOutput(data[0])
|
||||||
retVal = line
|
if(data[0].strip() == variableId):
|
||||||
|
retVal = line
|
||||||
except Exception:
|
except Exception:
|
||||||
ruleString = cnos_devicerules.getRuleString(deviceType, variableId)
|
ruleString = cnos_devicerules.getRuleString(deviceType, variableId)
|
||||||
retVal = ruleString.strip()
|
retVal = ruleString.strip()
|
||||||
|
@ -3310,7 +3290,7 @@ def validateValueAgainstRule(ruleString, variableValue):
|
||||||
return "Error-115"
|
return "Error-115"
|
||||||
|
|
||||||
elif(variableType == "LONG"):
|
elif(variableType == "LONG"):
|
||||||
result = checkInteger(variableValue)
|
result = checkLong(variableValue)
|
||||||
if(result is True):
|
if(result is True):
|
||||||
return "ok"
|
return "ok"
|
||||||
else:
|
else:
|
||||||
|
@ -3319,7 +3299,7 @@ def validateValueAgainstRule(ruleString, variableValue):
|
||||||
elif(variableType == "LONG_VALUE"):
|
elif(variableType == "LONG_VALUE"):
|
||||||
long_range = varRange.split('-')
|
long_range = varRange.split('-')
|
||||||
r = range(int(long_range[0].strip()), int(long_range[1].strip()))
|
r = range(int(long_range[0].strip()), int(long_range[1].strip()))
|
||||||
if(checkInteger(variableValue) is not True):
|
if(checkLong(variableValue) is not True):
|
||||||
# debugOutput(variableValue)
|
# debugOutput(variableValue)
|
||||||
return "Error-116"
|
return "Error-116"
|
||||||
result = int(variableValue) in r
|
result = int(variableValue) in r
|
||||||
|
@ -3332,8 +3312,8 @@ def validateValueAgainstRule(ruleString, variableValue):
|
||||||
long_range = varRange.split('-')
|
long_range = varRange.split('-')
|
||||||
r = range(int(long_range[0].strip()), int(long_range[1].strip()))
|
r = range(int(long_range[0].strip()), int(long_range[1].strip()))
|
||||||
val_range = variableValue.split('-')
|
val_range = variableValue.split('-')
|
||||||
if((checkInteger(val_range[0]) is not True) or
|
if((checkLong(val_range[0]) is not True) or
|
||||||
(checkInteger(val_range[1]) is not True)):
|
(checkLong(val_range[1]) is not True)):
|
||||||
return "Error-117"
|
return "Error-117"
|
||||||
result = (val_range[0] in r) and (
|
result = (val_range[0] in r) and (
|
||||||
val_range[1] in r) and (val_range[0] < val_range[1])
|
val_range[1] in r) and (val_range[0] < val_range[1])
|
||||||
|
@ -3343,7 +3323,7 @@ def validateValueAgainstRule(ruleString, variableValue):
|
||||||
return "Error-113"
|
return "Error-113"
|
||||||
elif(variableType == "LONG_OPTIONS"):
|
elif(variableType == "LONG_OPTIONS"):
|
||||||
long_options = varRange.split(',')
|
long_options = varRange.split(',')
|
||||||
if(checkInteger(variableValue) is not True):
|
if(checkLong(variableValue) is not True):
|
||||||
return "Error-116"
|
return "Error-116"
|
||||||
for opt in long_options:
|
for opt in long_options:
|
||||||
if(opt.strip() == variableValue):
|
if(opt.strip() == variableValue):
|
||||||
|
@ -3499,6 +3479,14 @@ def checkFloat(s):
|
||||||
# EOM
|
# EOM
|
||||||
|
|
||||||
|
|
||||||
|
def checkLong(s):
|
||||||
|
try:
|
||||||
|
int(s)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def debugOutput(command):
|
def debugOutput(command):
|
||||||
f = open('debugOuput.txt', 'a')
|
f = open('debugOuput.txt', 'a')
|
||||||
f.write(str(command)) # python will convert \n to os.linesep
|
f.write(str(command)) # python will convert \n to os.linesep
|
||||||
|
|
Loading…
Reference in a new issue