mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
send vnc teardown commands to proxstar-vnc
This commit is contained in:
parent
03baef5be0
commit
8808389b46
3 changed files with 23 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import time
|
||||
import requests
|
||||
import subprocess
|
||||
from sshtunnel import SSHTunnelForwarder
|
||||
from proxstar.util import *
|
||||
|
@ -91,9 +92,18 @@ def stop_ssh_tunnel(vmid, ssh_tunnels):
|
|||
tunnel = next((tunnel for tunnel in ssh_tunnels
|
||||
if tunnel.local_bind_port == port), None)
|
||||
if tunnel:
|
||||
print("Tearing down SSH tunnel for VM {}.".format(vmid))
|
||||
try:
|
||||
tunnel.stop()
|
||||
except:
|
||||
pass
|
||||
ssh_tunnels.remove(tunnel)
|
||||
delete_vnc_target(port)
|
||||
|
||||
|
||||
def send_stop_ssh_tunnel(vmid):
|
||||
requests.post(
|
||||
"https://{}/console/vm/{}/stop".format(app.config['SERVER_NAME'],
|
||||
vmid),
|
||||
data={'token': app.config['VNC_CLEANUP_TOKEN']},
|
||||
verify=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue