Created
June 27, 2018 21:19
-
-
Save lanbugs/e40712b37d51c91ef01f8234c7467c8b to your computer and use it in GitHub Desktop.
Backup Cisco configuration by write event to external server - Example for Flask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# write config to file with cisco archive command | |
# see more in blog article: https://lanbugs.de/netzwerktechnik/hersteller/cisco/cisco-python-backup-der-konfiguration-bei-write-event-auf-externen-server/ | |
from flask import Flask | |
from flask import request | |
app = Flask(__name__) | |
@app.route("/put/<cfg>", methods=['PUT']) | |
def get_config(cfg): | |
with open('/opt/cisco_config/incoming_configs/%s' % cfg, "wb") as f: | |
f.write(request.data) | |
return "ok" | |
if __name__ == "__main__": | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment