Skip to content

Commit 2688e15

Browse files
stratus-sscsmart
authored andcommitted
Adding the ability to get the domuuid of a specified domain
1 parent bf8164e commit 2688e15

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

plugins/modules/virt.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
VIRT_UNAVAILABLE = 2
177177

178178
ALL_COMMANDS = []
179-
VM_COMMANDS = ['create', 'define', 'destroy', 'get_xml', 'pause', 'shutdown', 'status', 'start', 'stop', 'undefine', 'unpause']
179+
VM_COMMANDS = ['create', 'define', 'destroy', 'get_xml', 'pause', 'shutdown', 'status', 'start', 'stop', 'undefine', 'unpause', 'uuid']
180180
HOST_COMMANDS = ['freemem', 'info', 'list_vms', 'nodeinfo', 'virttype']
181181
ALL_COMMANDS.extend(VM_COMMANDS)
182182
ALL_COMMANDS.extend(HOST_COMMANDS)
@@ -311,6 +311,10 @@ def set_autostart(self, vmid, val):
311311
def define_from_xml(self, xml):
312312
return self.conn.defineXML(xml)
313313

314+
def get_uuid(self, vmid):
315+
vm = self.conn.lookupByName(vmid)
316+
return vm.UUIDString()
317+
314318

315319
class Virt(object):
316320

@@ -482,6 +486,10 @@ def define(self, xml):
482486
self.__get_conn()
483487
return self.conn.define_from_xml(xml)
484488

489+
def get_uuid(self, vmid):
490+
self.__get_conn()
491+
return self.conn.get_uuid(vmid)
492+
485493

486494
# A dict of interface types (found in their `type` attribute) to the
487495
# corresponding "source" attribute name of their <source> elements
@@ -767,6 +775,9 @@ def core(module):
767775
if not isinstance(res, dict):
768776
res = {command: res}
769777

778+
elif command == 'uuid':
779+
res = {'uuid': v.get_uuid(guest)}
780+
770781
else:
771782
res = getattr(v, command)(guest)
772783
if not isinstance(res, dict):

0 commit comments

Comments
 (0)