def save_topology(name):
"""Save a topology layout in a file.
This method get a json topology from request and puts this in a file.
Parameters:
name (string): name of the topology to be saved or loaded.
Returns:
topology (string): topology using json format.
"""
if not request.is_json:
return json.dumps('{"error": "gt was not a JSON request"}'), 400
topology = request.get_json()
with open(join(settings.TOPOLOGY_DIR, name + '.json'), 'w') as outfile:
json.dump(topology, outfile)
return json.dumps({'response': 'Saved'}), 201
评论列表
文章目录