Skip to content

Commit

Permalink
modification de la récupération de l'url vnc
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTheGeek committed Jan 26, 2024
1 parent 75ad4ab commit 529f980
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,10 @@ def vm_status_id(uuid):
def vm_url_id(uuid):
if not uuid:
return jsonify({'message': 'Please provide a VM ID'}), 400
vm_name = VM.query.filter_by(id=uuid, users_id=current_user.id).first().name
if vm_name:
try:
url_vnc = openstack.get_console_url(conn_openstack, vm_name)
except:
return jsonify({'message': 'ERROR URL'}), 500
url = url_vnc.rsplit('0/vnc_auto.html', 1)[-1]
# print(url)
return jsonify({"url": "https://vnc.insa-cvl.com/"+url}), 200
vm = VM.query.filter_by(id=uuid, users_id=current_user.id).first()
if vm:
token = vm.vncurl
return jsonify({"url": "https://vnc.insa-cvl.com/?path="+token}), 200
else:
return jsonify({'message': 'VM not found'}), 404

Expand All @@ -606,16 +601,10 @@ def vm_url_id(uuid):
def vm_url_template(template_id):
if not template_id:
return jsonify({'message': 'Please provide a template ID'}), 400
vm_name = VM.query.filter_by(template_id=template_id, users_id=current_user.id).first().name
if vm_name:
try:
url_vnc = openstack.get_console_url(conn_openstack, vm_name)
except:
return jsonify({'message': 'ERROR URL'}), 500
# print(url_vnc)
url = url_vnc.rsplit('0/vnc_auto.html', 1)[-1]
# print(url)
return jsonify({"url": "https://vnc.insa-cvl.com/"+url}), 200
vm = VM.query.filter_by(template_id=template_id, users_id=current_user.id).first()
if vm:
token = vm.vncurl
return jsonify({"url": "https://vnc.insa-cvl.com/?path="+token}), 200
else:
return jsonify({'message': 'Template not found'}), 404

Expand Down

0 comments on commit 529f980

Please sign in to comment.