teardown ssh/vnc stuff after shutdown and reset requests

This commit is contained in:
Jordan Rodgers 2018-04-02 13:47:57 -04:00
parent 3f03d9ab69
commit 03baef5be0
2 changed files with 17 additions and 11 deletions

View file

@ -83,3 +83,17 @@ def start_ssh_tunnel(node, port):
local_bind_address=('127.0.0.1', port))
server.start()
return server
def stop_ssh_tunnel(vmid, ssh_tunnels):
# Tear down the SSH tunnel and VNC target entry for a given 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)