Got it

Save configuration with Netmiko

Created: Jan 19, 2021 09:19:01Latest reply: Jan 20, 2021 10:07:15 3136 32 1 0 0
  Rewarded HiCoins: 0 (problem resolved)

Hi all

I configured some swithes with python using netmiko

but comand (Save) for save configuration doesnt work

any help ?

All Answers
I think the Issue that (config_commands) send command in system view mode
while (Save) should be execute in user view mode
View more
  • x
  • convention:

Posted by aboyasir at 2021-01-20 06:45 I think the Issue that (config_commands) send command in system view modewhile (Save) should be exec ...
No, I don't agree with that.
When you type 'return', the system returns to view mode, then the 'save' command can be executed normally, as you pasted the result previously. The problem is after typing the 'save', 'y' or 'n' should be followed, and will you please try the config_commands below:
config_commands = [ 'int loop 1',
'ip add 1.1.1.1 255.255.255.0',
'return',
'save',
'y',]
View more
  • x
  • convention:

same error

on cisco switches it works because i can save config with command (do wr ) in configuration mode
no need to return to user mode
View more
  • x
  • convention:

Posted by aboyasir at 2021-01-20 06:58 same erroron cisco switches it works because i can save config with command (do wr ) in configuratio ...
Hi,
I found an alternative way to save the configuration. Please refer to the code below:
config_commands=[
'int loop0',
'ip add 10.2.1.1 32',
'return',
]
output=net_connect.send_config_set(config_commands)
net_connect.save_config('save') //save the configuration after sending the commands.
View more
  • x
  • convention:

config_commands=['int loop0',

                 'ip add 10.2.1.1 32',

                 'return',

                ]

output=net_connect.send_config_set(config_commands)

net_connect.save_config('save')



View more
  • x
  • convention:

print(output)
View more
  • x
  • convention:

result



system-view

Enter system view, return user view with Ctrl+Z.

[BLD2-1ST-B2]int loop0

[BLD2-1ST-B2-LoopBack0]ip add 10.2.1.1 32

[BLD2-1ST-B2-LoopBack0]return

<BLD2-1ST-B2>


but idont know if it saved or not 

save command not print out

View more
  • x
  • convention:

finally its work


config_commands=['int loop0',

                 'ip add 10.2.1.1 32',

                 'return',

                ]

output=net_connect.send_config_set(config_commands)

output=net_connect.save_config('save')




View more
  • x
  • convention:

print(output0
View more
  • x
  • convention:

print(output)
View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.