1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

Create instances with a random generated vnc password by default

This commit is contained in:
Valentin Samir 2016-05-08 12:24:43 +02:00
parent 17cb7ace88
commit e75fc99449
3 changed files with 10 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import random
import libxml2
import libvirt
import string
def is_kvm_available(xml):
@ -29,6 +30,11 @@ def randomUUID():
return "-".join(["%02x" * 4, "%02x" * 2, "%02x" * 2, "%02x" * 2, "%02x" * 6]) % tuple(u)
def randomPasswd(length=12, alphabet=string.letters + string.digits):
"""Generate a random password"""
return ''.join([random.choice(alphabet) for i in xrange(length)])
def get_max_vcpus(conn, type=None):
"""@param conn: libvirt connection to poll for max possible vcpus
@type type: optional guest type (kvm, etc.)"""