def restore_backup():
'''
POST:
Receive a backup file and load it into the system
'''
with tempfile.NamedTemporaryFile(suffix='.nft', delete=False) as tf:
backup = request.files['file'].read()
tf.write(backup)
cmd = nft_utils.nft_command('-f ' + tf.name)
cmd_result = cmd.wait()
if cmd_result == 0:
nft_utils.close_nft_command(cmd)
os.remove(tf.name)
return make_response('Backup restored')
else:
return abort(500, NFTError(Error(cmd.stdout.read())))
评论列表
文章目录