mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
Update cnos_backup.py (#44246)
* Update cnos_backup.py * Removing unused methods in cnos.py util file.
This commit is contained in:
parent
dafe633d02
commit
6f94f8be08
2 changed files with 74 additions and 272 deletions
|
@ -1363,101 +1363,6 @@ def portChannelConfig(module, prompt, answer):
|
|||
# EOM
|
||||
|
||||
|
||||
def doStartupConfigBackUp(
|
||||
protocol, timeout, confServerIp, confPath, confServerUser,
|
||||
confServerPwd, obj):
|
||||
# server = "10.241.105.214"
|
||||
server = confServerIp
|
||||
|
||||
# username = "pbhosale"
|
||||
username = confServerUser
|
||||
|
||||
# password = "Lab4man1"
|
||||
password = confServerPwd
|
||||
|
||||
if((confPath is None) or (confPath is "")):
|
||||
confPath = "cnos_config"
|
||||
|
||||
retVal = ""
|
||||
|
||||
# config backup command happens here
|
||||
if(protocol == "ftp"):
|
||||
command = "cp startup-config " + protocol + " " + protocol + "://" + \
|
||||
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
||||
elif(protocol == "tftp"):
|
||||
command = "cp startup-config " + protocol + " " + protocol + \
|
||||
"://" + server + "/" + confPath + " vrf management\n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
|
||||
else:
|
||||
return "Error-110"
|
||||
|
||||
return retVal
|
||||
# EOM
|
||||
|
||||
# Utility Method to back up the start up config
|
||||
# This method supports only SCP or SFTP
|
||||
# Tuning of timeout parameter is pending
|
||||
|
||||
|
||||
def doSecureStartupConfigBackUp(
|
||||
protocol, timeout, confServerIp, confPath, confServerUser,
|
||||
confServerPwd, obj):
|
||||
# server = "10.241.105.214"
|
||||
server = confServerIp
|
||||
|
||||
# username = "pbhosale"
|
||||
username = confServerUser
|
||||
|
||||
# password = "Lab4man1"
|
||||
password = confServerPwd
|
||||
|
||||
if((confPath is None) or (confPath is "")):
|
||||
confPath = "cnos_config"
|
||||
|
||||
retVal = ""
|
||||
|
||||
# config backup command happens here
|
||||
command = "cp startup-config " + protocol + " " + protocol + "://" + \
|
||||
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||
# debugOutput(command)
|
||||
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
||||
if(response.lower().find('error-101')):
|
||||
command = password + "\n"
|
||||
retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
|
||||
return retVal
|
||||
retVal = retVal + response
|
||||
if(protocol == "scp"):
|
||||
command = "yes \n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
|
||||
command = "0\n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||
elif(protocol == "sftp"):
|
||||
command = "yes \n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||
else:
|
||||
return "Error-110"
|
||||
|
||||
# Password entry happens here
|
||||
# debugOutput(command)
|
||||
command = password + "\n"
|
||||
retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
|
||||
|
||||
return retVal
|
||||
# EOM
|
||||
|
||||
# Utility Method to restore the Running config
|
||||
# This method supports only TFTP or FTP
|
||||
# Tuning of timeout parameter is pending
|
||||
|
||||
|
||||
def doStartUpConfigRollback(
|
||||
protocol, timeout, confServerIp, confPath, confServerUser,
|
||||
confServerPwd, obj):
|
||||
|
@ -1560,104 +1465,6 @@ def doSecureStartUpConfigRollback(
|
|||
return retVal
|
||||
# EOM
|
||||
|
||||
# Utility Method to back up the Running config
|
||||
# This method supports only TFTP or FTP
|
||||
# Tuning of timeout parameter is pending
|
||||
|
||||
|
||||
def doRunningConfigBackUp(
|
||||
protocol, timeout, confServerIp, confPath, confServerUser,
|
||||
confServerPwd, obj):
|
||||
# server = "10.241.105.214"
|
||||
server = confServerIp
|
||||
|
||||
# username = "pbhosale"
|
||||
username = confServerUser
|
||||
|
||||
# password = "Lab4man1"
|
||||
password = confServerPwd
|
||||
|
||||
if((confPath is None) or (confPath is "")):
|
||||
confPath = "cnos_config"
|
||||
|
||||
retVal = ""
|
||||
|
||||
# config backup command happens here
|
||||
if(protocol == "ftp"):
|
||||
command = "cp running-config " + protocol + " " + protocol + "://" + \
|
||||
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
|
||||
elif(protocol == "tftp"):
|
||||
command = "cp running-config " + protocol + " " + protocol + \
|
||||
"://" + server + "/" + confPath + " vrf management\n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
|
||||
else:
|
||||
return "Error-110"
|
||||
|
||||
return retVal
|
||||
# EOM
|
||||
|
||||
|
||||
# Utility Method to back up the running config
|
||||
# This method supports only SCP or SFTP
|
||||
# Tuning of timeout parameter is pending
|
||||
def doSecureRunningConfigBackUp(
|
||||
protocol, timeout, confServerIp, confPath, confServerUser,
|
||||
confServerPwd, obj):
|
||||
# server = "10.241.105.214"
|
||||
server = confServerIp
|
||||
|
||||
# username = "pbhosale"
|
||||
username = confServerUser
|
||||
|
||||
# password = "Lab4man1"
|
||||
password = confServerPwd
|
||||
|
||||
if((confPath is None) or (confPath is "")):
|
||||
confPath = "cnos_config"
|
||||
|
||||
retVal = ""
|
||||
|
||||
# config backup command happens here
|
||||
command = "cp running-config " + protocol + " " + protocol + "://" + \
|
||||
username + "@" + server + "/" + confPath + " vrf management\n"
|
||||
# debugOutput(command)
|
||||
response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
|
||||
if(response.lower().find('error-101')):
|
||||
command = password + "\n"
|
||||
retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
|
||||
return retVal
|
||||
retVal = retVal + response
|
||||
if(protocol == "scp"):
|
||||
command = "yes \n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
|
||||
command = "0\n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||
elif(protocol == "sftp"):
|
||||
command = "yes \n"
|
||||
# debugOutput(command)
|
||||
retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
|
||||
else:
|
||||
return "Error-110"
|
||||
|
||||
# Password entry happens here
|
||||
# debugOutput(command)
|
||||
command = password + "\n"
|
||||
retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
|
||||
|
||||
return retVal
|
||||
# EOM
|
||||
|
||||
# Utility Method to restore the Running config
|
||||
# This method supports only TFTP or FTP
|
||||
# Tuning of timeout parameter is pending
|
||||
|
||||
|
||||
def doRunningConfigRollback(
|
||||
protocol, timeout, confServerIp, confPath, confServerUser,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue