Terminal management impove
parent
58a04d51b3
commit
cc44a3df4d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -10,6 +10,13 @@ def get_version():
|
|||
vhype = hype_version
|
||||
return vlxc, vlibvirt, vhype
|
||||
|
||||
def get_vm_infos(vm_name):
|
||||
dom = conn.lookupByName(vm_name)
|
||||
vm_info = dom.guestInfo()
|
||||
vm_infos=[]
|
||||
vm_infos=[vm_info['os.id'],vm_info['os.pretty-name'],vm_info['os.kernel-release']]
|
||||
return vm_infos
|
||||
|
||||
|
||||
def set_memory(vm_name,memory_new):
|
||||
dom = conn.lookupByName(vm_name)
|
||||
|
|
|
@ -45,7 +45,7 @@ def get_int(net_name):
|
|||
def create_vswitch_int(net_int):
|
||||
cmd="ovs-vsctl add-br "+net_int
|
||||
out = subprocess.call(cmd, shell=True)
|
||||
if out2 != 0:
|
||||
if out != 0:
|
||||
raise Exception("Error on creating interface")
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from config import *
|
||||
from xml.etree import ElementTree as ET
|
||||
from flask import request, Response
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
def get_vnc_port(vm_name):
|
||||
|
@ -12,14 +13,15 @@ def get_vnc_port(vm_name):
|
|||
return vnc_port
|
||||
|
||||
def kill_consoles():
|
||||
os.system('kill -9 $(ps -edf | grep websockify | grep -v grep | awk \'{ print $2 }\')')
|
||||
os.system('for i in $(ps -edf | grep pyxterm | grep -v grep | awk \'{ print $2 }\');do kill -9 $i;done')
|
||||
subprocess.run("pkill -9 -f 'websockify'", shell=True)
|
||||
subprocess.run("for i in $(pgrep -f 'pyxterm'); do kill -9 $i; done", shell=True)
|
||||
|
||||
def socket_connect(vm_name):
|
||||
kill_consoles()
|
||||
vm_port = get_vnc_port(vm_name)
|
||||
os.system('websockify -D --web=/usr/share/novnc/ 6080 localhost:'+vm_port)
|
||||
subprocess.run(['websockify', '-D', '--web=/usr/share/novnc/', '6080', 'localhost:' + vm_port])
|
||||
|
||||
def pyxterm_connect(path,lxc_name):
|
||||
kill_consoles()
|
||||
os.system('python3 '+path+'/pyxterm.py --command \'lxc-attach\' --cmd-args \''+lxc_name+'\' &')
|
||||
cmd = ['python3', f'{path}/pyxterm.py', '--command', 'lxc-attach', '--cmd-args', lxc_name]
|
||||
pyx_process = subprocess.Popen(cmd)
|
||||
|
|
Loading…
Reference in New Issue