add release_allocation
This commit is contained in:
parent
2a829396c2
commit
63af20c44b
16
app.py
16
app.py
@ -154,5 +154,21 @@ def get_image():
|
||||
|
||||
return send_file(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||
|
||||
@app.route("/api/release_allocation", methods=['POST'])
|
||||
def release_allocation():
|
||||
try:
|
||||
name = db.get_conf_image(request.headers['name'])
|
||||
if name is None or name == "":
|
||||
return jsonify(message="400")
|
||||
except:
|
||||
pass
|
||||
id_allocation = db.get_conf_id_name(name)
|
||||
if id_allocation is not None:
|
||||
db.del_image_allocation_id(id_allocation)
|
||||
else:
|
||||
return jsonify(message="400")
|
||||
|
||||
return jsonify(message="200")
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0")
|
@ -4,3 +4,4 @@ user="praktyki"
|
||||
password="2a7driUITXFy73tO"
|
||||
port="5432"
|
||||
default_file = "default.squashfs"
|
||||
webssh_port = "8000"
|
11
db.py
11
db.py
@ -85,6 +85,17 @@ def get_conf_id(token):
|
||||
except:
|
||||
return None
|
||||
|
||||
def get_conf_id_name(name):
|
||||
connect()
|
||||
with get_cur() as cur:
|
||||
cur.execute("""
|
||||
SELECT id FROM image WHERE image_name = %s
|
||||
""",(name+".squashfs",))
|
||||
try:
|
||||
return cur.fetchone()[0]
|
||||
except:
|
||||
return None
|
||||
|
||||
def add_user(username, password):
|
||||
connect()
|
||||
with get_cur() as cur:
|
||||
|
3
utils.py
3
utils.py
@ -8,6 +8,7 @@ import subprocess
|
||||
import threading
|
||||
from time import sleep
|
||||
import db
|
||||
import config
|
||||
|
||||
def generate_random_string(length):
|
||||
letters = string.ascii_letters
|
||||
@ -31,7 +32,7 @@ def ping_client(ip):
|
||||
|
||||
|
||||
def ssh_thread_function():
|
||||
subprocess.run(['wssh','--fbidhttp=False'])
|
||||
subprocess.run(['wssh','--fbidhttp=False', '--port='+config.webssh_port])
|
||||
|
||||
def check_allocation_thread_function():
|
||||
while True:
|
||||
|
Loading…
Reference in New Issue
Block a user