mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
fix template provisioning by verifying VM is provisioned before doing anything else
This commit is contained in:
parent
84f9a00735
commit
1acb84016d
5 changed files with 49 additions and 28 deletions
|
|
@ -10,12 +10,11 @@ from flask import current_app as app
|
|||
def start_websockify(websockify_path, target_file):
|
||||
result = subprocess.run(['pgrep', 'websockify'], stdout=subprocess.PIPE)
|
||||
if not result.stdout:
|
||||
subprocess.call(
|
||||
[
|
||||
websockify_path, '8081', '--token-plugin', 'TokenFile',
|
||||
'--token-source', target_file, '-D'
|
||||
],
|
||||
stdout=subprocess.PIPE)
|
||||
subprocess.call([
|
||||
websockify_path, '8081', '--token-plugin', 'TokenFile',
|
||||
'--token-source', target_file, '-D'
|
||||
],
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
|
||||
def stop_websockify():
|
||||
|
|
@ -24,11 +23,11 @@ def stop_websockify():
|
|||
pid = result.stdout.strip()
|
||||
subprocess.run(['kill', pid], stdout=subprocess.PIPE)
|
||||
time.sleep(3)
|
||||
if subprocess.run(
|
||||
['pgrep', 'websockify'], stdout=subprocess.PIPE).stdout:
|
||||
if subprocess.run(['pgrep', 'websockify'],
|
||||
stdout=subprocess.PIPE).stdout:
|
||||
time.sleep(10)
|
||||
if subprocess.run(
|
||||
['pgrep', 'websockify'], stdout=subprocess.PIPE).stdout:
|
||||
if subprocess.run(['pgrep', 'websockify'],
|
||||
stdout=subprocess.PIPE).stdout:
|
||||
print('Websockify didn\'t stop, killing forcefully.')
|
||||
subprocess.run(['kill', '-9', pid], stdout=subprocess.PIPE)
|
||||
|
||||
|
|
@ -90,8 +89,9 @@ def start_ssh_tunnel(node, port):
|
|||
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)
|
||||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue