mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-14 22:11:51 +00:00
remove SSH tunnel and VNC stuff for deleted VMs
This commit is contained in:
parent
e608c0dc10
commit
3f03d9ab69
2 changed files with 14 additions and 2 deletions
|
@ -365,6 +365,18 @@ def delete(vmid):
|
||||||
user = User(session['userinfo']['preferred_username'])
|
user = User(session['userinfo']['preferred_username'])
|
||||||
proxmox = connect_proxmox()
|
proxmox = connect_proxmox()
|
||||||
if user.rtp or int(vmid) in user.allowed_vms:
|
if user.rtp or int(vmid) in user.allowed_vms:
|
||||||
|
# Tear down the SSH tunnel and VNC stuff for the VM
|
||||||
|
port = 5900 + int(vmid)
|
||||||
|
tunnel = next((tunnel for tunnel in ssh_tunnels
|
||||||
|
if tunnel.local_bind_port == port), None)
|
||||||
|
if tunnel:
|
||||||
|
try:
|
||||||
|
tunnel.stop()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
ssh_tunnels.remove(tunnel)
|
||||||
|
delete_vnc_target(port)
|
||||||
|
# Submit the delete VM task to RQ
|
||||||
q.enqueue(delete_vm_task, vmid)
|
q.enqueue(delete_vm_task, vmid)
|
||||||
return '', 200
|
return '', 200
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -62,8 +62,8 @@ def add_vnc_target(port):
|
||||||
|
|
||||||
def delete_vnc_target(port):
|
def delete_vnc_target(port):
|
||||||
targets = get_vnc_targets()
|
targets = get_vnc_targets()
|
||||||
target = next((target for target in targets if target['port'] == port),
|
target = next(
|
||||||
None)
|
(target for target in targets if target['port'] == str(port)), None)
|
||||||
if target:
|
if target:
|
||||||
targets.remove(target)
|
targets.remove(target)
|
||||||
target_file = open(app.config['WEBSOCKIFY_TARGET_FILE'], 'w')
|
target_file = open(app.config['WEBSOCKIFY_TARGET_FILE'], 'w')
|
||||||
|
|
Loading…
Reference in a new issue