Mercurial > hg > Applications > virsh-wrapper
changeset 51:fecd206e005f
fix randomaUUID
author | kono |
---|---|
date | Tue, 30 Jan 2018 22:22:07 +0900 |
parents | 7a02dee972c4 |
children | e45676e6b6cd |
files | newvm.py |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/newvm.py Tue Jan 30 22:13:22 2018 +0900 +++ b/newvm.py Tue Jan 30 22:22:07 2018 +0900 @@ -4,6 +4,7 @@ import sys,os,string,re from optparse import OptionParser from virtinst.util import * +from virtinst.connection import * import string if sys.version_info < (2,5): @@ -82,12 +83,12 @@ random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) -def randomUUID(): - u = [random.randint(0, 255) for ignore in range(0, 16)] - u[6] = (u[6] & 0x0F) | (4 << 4) - u[8] = (u[8] & 0x3F) | (2 << 6) - return "-".join(["%02x" * 4, "%02x" * 2, "%02x" * 2, "%02x" * 2, - "%02x" * 6]) % tuple(u) +# def randomUUID(): +# u = [random.randint(0, 255) for ignore in range(0, 16)] +# u[6] = (u[6] & 0x0F) | (4 << 4) +# u[8] = (u[8] & 0x3F) | (2 << 6) +# return "-".join(["%02x" * 4, "%02x" * 2, "%02x" * 2, "%02x" * 2, +# "%02x" * 6]) % tuple(u) def genPassword(): @@ -130,8 +131,7 @@ name.text = new_name uuid = config.find('uuid') -("qemu:///system") -uuid.text = randomUUID() +uuid.text = randomUUID(VirtualConnection("qemu:///system")) mac = config.find('devices/interface/mac') mac.attrib['address'] = randomMAC() disk = config.find('devices/disk/source')