Adding VM edition and screenshot
This commit is contained in:
1 parent
b6ece56080
commit
2f113ad01b
13 files changed
+36
-4
No files matched your search
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.
@@ -0,0 +1,33 @@
|
||||
from config import *
|
||||
import base64
|
||||
|
||||
#memory = Memory in Mo
|
||||
def set_memory(vm_name,memory_new):
|
||||
dom = conn.lookupByName(vm_name)
|
||||
dom.setMemory(memory_new)
|
||||
|
||||
def set_vcpu(vm_name,vcpu_new):
|
||||
dom = conn.lookupByName(vm_name)
|
||||
dom.setVcpus(vcpu_new)
|
||||
|
||||
def get_info_vm(vm_name):
|
||||
dom = conn.lookupByName(vm_name)
|
||||
state, maxmem, mem, cpus, cput = dom.info()
|
||||
return state, maxmem, mem, cpus, cput
|
||||
|
||||
def get_screenshot(vm_name):
|
||||
dom = conn.lookupByName(vm_name)
|
||||
stream = conn.newStream()
|
||||
imageType = dom.screenshot(stream,0)
|
||||
file = "tmp_screen_" + dom.name()
|
||||
fileHandler = open(file, 'wb')
|
||||
streamBytes = stream.recv(262120)
|
||||
while streamBytes != b'':
|
||||
fileHandler.write(streamBytes)
|
||||
streamBytes = stream.recv(262120)
|
||||
fileHandler.close()
|
||||
stream.finish()
|
||||
with open(file, "rb") as f:
|
||||
data = base64.b64encode(f.read())
|
||||
os.remove(file)
|
||||
return data
|
||||
Reference in new issue
Block a user