Ok Fini
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
from flask import Flask,jsonify,request,abort, make_response,send_file
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from nornir import InitNornir
|
||||
from flask_cors import CORS
|
||||
|
||||
import os
|
||||
from werkzeug.utils import secure_filename
|
||||
import json
|
||||
|
||||
|
||||
ALLOWED_EXTENSIONS = {'conf'}
|
||||
UPLOAD_FOLDER = 'fastprod/upload_files/'
|
||||
|
||||
@@ -20,6 +23,8 @@ def allowed_file(filename):
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||
CORS(app)
|
||||
|
||||
|
||||
from services.devices import ( get_inventory, add_device,get_device_by_name,delete_device,get_device_interfaces,get_device_interfaces_ip,get_device_technical_info)
|
||||
from services.config import (get_config_by_device,run_config_from_file_by_device)
|
||||
@@ -75,7 +80,7 @@ def get_technical_info(device_name):
|
||||
if request.method == 'GET':
|
||||
device = get_device_by_name(device_name)
|
||||
technical_info = get_device_technical_info(device)
|
||||
return jsonify(interfaces_ip=technical_info)
|
||||
return jsonify(facts=technical_info)
|
||||
|
||||
@app.route("/devices/<device_name>/config", methods=['GET','POST'])
|
||||
def get_config(device_name):
|
||||
@@ -109,15 +114,13 @@ def snapshot(device_name):
|
||||
data = get_snapshots_by_device(device)
|
||||
return jsonify({
|
||||
"result": True,
|
||||
"data": data
|
||||
"snapshots": data
|
||||
})
|
||||
if request.method == 'POST':
|
||||
snapshot_path = create_snapshot_by_device(device)
|
||||
return jsonify({
|
||||
"result": True,
|
||||
"data": {
|
||||
"snapshot_path": snapshot_path
|
||||
}
|
||||
"snapshots": snapshot_path
|
||||
})
|
||||
|
||||
@app.route("/snapshots/<path:filename>", methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user