Skip to content

Instantly share code, notes, and snippets.

@nielskou
Created July 9, 2019 08:11
Show Gist options
  • Save nielskou/3d2a79000d927322df464ccb29af7a0e to your computer and use it in GitHub Desktop.
Save nielskou/3d2a79000d927322df464ccb29af7a0e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from ncclient.manager import connect_ssh
# use unencrypted keys from ssh-agent or ~/.ssh keys, and rely on known_hosts
with connect_ssh("192.168.3.3", username="stuart") as manager:
assert(":url" in manager.server_capabilities)
with manager.locked("running"):
# create a new checkpoint
manager.copy_config(source="running", target="file:///new_checkpoint.conf")
# load an old checkpoint
manager.copy_config(source="file:///old_checkpoint.conf", target="running")
# dispatch a command
manager.dispatch('clear-arp-table')
# commit
manager.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment