- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Python script to copy NX-OS config to scp server
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2021 10:07 AM - edited 02-09-2021 10:10 AM
Hello,
My apologies if this has been answered before, I did a search and could not find anything. I’m trying to back up my configs to a SCP server. It works with IOS the issue is with NX-OS. When SCP I include the username and password in the command, however it still prompts for the password and times out. Is there a way to send the password in a different line? Here is my script.
Any help is much appreciated.
# BEGIN-SCRIPT-BLOCK
#
# Script-Filter:
# $vendor eq "Cisco"
#
#
# Script-Variables:
# $scp_user string "Network Username"
# $scp_pass password "Enter Password"
#
# Script-timeout:300
# END-SCRIPT-BLOCK
from infoblox_netmri.easy import NetMRIEasy
import re
# This values will be provided by NetMRI before execution
defaults = {
"api_url": api_url,
"http_username": http_username,
"http_password": http_password,
"job_id": job_id,
"device_id": device_id,
"batch_id": batch_id
}
# Create NetMRI context manager. It will close the session after execution
with NetMRIEasy(**defaults) as easy:
shover = easy.send_command('show version | inc IOS|Nexus')
pattern = re.compile(r'(IOS|Nexus)')
version = pattern.findall(shover)
print(version[0])
if(version[0] == 'IOS'):
easy.send_command('write memory')
easy.send_command('copy startup-config scp://{}:{}@10.0.0.1/ \r\r\r'.format(scp_user, scp_pass))
elif(version[0] == 'Nexus'):
easy.send_command('copy running-config startup-config')
easy.send_command('copy startup-config scp://{}:{}@10.0.0.1/ vrf default \r\r'.format(scp_user, scp_pass))
else:
print('This is not a switch or router')
Re: Python script to copy NX-OS config to scp server
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2021 08:06 PM - edited 05-17-2021 08:06 PM
So sorry about this late reply, I missed it
Try using this method instead
easy.send_command('copy startup-config scp://' + scp_user +':' + scp_pass + '@10.0.0.1/ \r\r\r')
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
Re: Python script to copy NX-OS config to scp server
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2021 01:30 AM
@SBaksh wrote:So sorry about this late reply, I missed it
Try using this method instead
easy.send_command('copy startup-config scp://' + scp_user +':' + scp_pass + '@10.0.0.1/ \r\r\r')
Thank you very much for the explanation.