diff --git a/proxstar/tasks.py b/proxstar/tasks.py index c719f90..d04caf7 100644 --- a/proxstar/tasks.py +++ b/proxstar/tasks.py @@ -245,5 +245,5 @@ def cleanup_vnc_task(): data={'token': app.config['VNC_CLEANUP_TOKEN']}, verify=False, ) - except Exception as e: # pylint: disable=W0703 + except Exception as e: # pylint: disable=W0703 print(e) diff --git a/proxstar/vm.py b/proxstar/vm.py index 7c16583..f0cde27 100644 --- a/proxstar/vm.py +++ b/proxstar/vm.py @@ -275,26 +275,26 @@ class VM: # instance. # FIXME (willnilges): Dead Code. Remove this function. # """ - # proxmox = connect_proxmox() - # config = f'args: -object secret,id=secvnc{self.id},data={self.id} -vnc - # 127.0.0.1:{int(self.id)+5900},password-secret=secvnc{self.id}' - # path = f'/etc/pve/local/qemu-server/{self.id}.conf' - # with paramiko.SSHClient() as ssh: - # ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - # ssh.connect( - # self.node, - # port=22, - # username=ssh_user, - # key_filename='proxmox_ssh_key', - # passphrase=ssh_pass, - # ) - # ssh.exec_command( - # f"if grep -- '{config}' {path}; then echo identical config found; - # else sed -i /dev/null '/-vnc/d' {path}" - # ) # YOLO - # ssh.exec_command( - # f"if grep -- '-vnc' {path}; then echo found config; else echo {config} >> {path}; fi" - # ) + # proxmox = connect_proxmox() + # config = f'args: -object secret,id=secvnc{self.id},data={self.id} -vnc + # 127.0.0.1:{int(self.id)+5900},password-secret=secvnc{self.id}' + # path = f'/etc/pve/local/qemu-server/{self.id}.conf' + # with paramiko.SSHClient() as ssh: + # ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + # ssh.connect( + # self.node, + # port=22, + # username=ssh_user, + # key_filename='proxmox_ssh_key', + # passphrase=ssh_pass, + # ) + # ssh.exec_command( + # f"if grep -- '{config}' {path}; then echo identical config found; + # else sed -i /dev/null '/-vnc/d' {path}" + # ) # YOLO + # ssh.exec_command( + # f"if grep -- '-vnc' {path}; then echo found config; else echo {config} >> {path}; fi" + # ) @retry(wait=wait_fixed(2), stop=stop_after_attempt(5)) def eject_iso(self): diff --git a/proxstar/vnc.py b/proxstar/vnc.py index 7832f83..6773d78 100644 --- a/proxstar/vnc.py +++ b/proxstar/vnc.py @@ -21,7 +21,9 @@ def stop_websockify(): time.sleep(1) if subprocess.run(['pgrep', 'websockify'], stdout=subprocess.PIPE, check=False).stdout: time.sleep(5) - if subprocess.run(['pgrep', 'websockify'], stdout=subprocess.PIPE, check=False).stdout: + if subprocess.run( + ['pgrep', 'websockify'], stdout=subprocess.PIPE, check=False + ).stdout: logging.info("websockify didn't stop, killing forcefully") subprocess.run(['kill', '-9', pid], stdout=subprocess.PIPE, check=False) @@ -125,16 +127,16 @@ def start_ssh_tunnel(node, port): # # Tear down the SSH tunnel and VNC target entry for a given VM # print(f'This code is useless') # pass - # port = 5900 + int(vmid) - # tunnel = next((tunnel for tunnel in ssh_tunnels if tunnel.local_bind_port == port), None) - # if tunnel: - # logging.info('tearing down SSH tunnel for VM %s', vmid) - # try: - # tunnel.stop() - # except: - # pass - # ssh_tunnels.remove(tunnel) - # delete_vnc_target(port) +# port = 5900 + int(vmid) +# tunnel = next((tunnel for tunnel in ssh_tunnels if tunnel.local_bind_port == port), None) +# if tunnel: +# logging.info('tearing down SSH tunnel for VM %s', vmid) +# try: +# tunnel.stop() +# except: +# pass +# ssh_tunnels.remove(tunnel) +# delete_vnc_target(port) # def send_stop_ssh_tunnel(vmid):