From 0fbee4dc1036703bdfb7517cbcd2044012581c6e Mon Sep 17 00:00:00 2001 From: Wojtek Porczyk Date: Mon, 21 Sep 2015 22:48:19 +0200 Subject: [PATCH] core3: more fixes --- qubes/__init__.py | 4 ++-- qubes/vm/qubesvm.py | 4 ++-- qubes/vm/templatevm.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index d883e976..70476c99 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -640,7 +640,7 @@ class property(object): # pylint: disable=redefined-builtin,invalid-name if self._setter is not None: value = self._setter(instance, self, value) - if self._type is not None: # XXX what about QubesVM and other types? + if self._type not in (None, type(value)): value = self._type(value) if has_oldvalue: @@ -1333,7 +1333,7 @@ class Qubes(PropertyHolder): # then search for name for l in self.labels.values(): if l.name == label: - return label + return l # last call, if label is a number represented as str, search in indices try: diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index f201ada2..525428fb 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -158,7 +158,7 @@ class QubesVM(qubes.vm.BaseVM): ls_width=31, doc='User-specified name of the domain.') - uuid = qubes.property('uuid', type=uuid.UUID, default=None, + uuid = qubes.property('uuid', type=uuid.UUID, ls_width=36, doc='UUID from libvirt.') @@ -316,7 +316,7 @@ class QubesVM(qubes.vm.BaseVM): # XXX _update_libvirt_domain? try: - if self.uuid is not None: + if hasattr(self, 'uuid'): self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByUUID( self.uuid.bytes) else: diff --git a/qubes/vm/templatevm.py b/qubes/vm/templatevm.py index be8444dd..9be4c34b 100644 --- a/qubes/vm/templatevm.py +++ b/qubes/vm/templatevm.py @@ -19,7 +19,8 @@ class TemplateVM(qubes.vm.qubesvm.QubesVM): super(TemplateVM, self).__init__(*args, **kwargs) # Some additional checks for template based VM - assert self.root_img is not None, "Missing root_img for standalone VM!" + # TODO find better way +# assert self.root_img is not None, "Missing root_img for standalone VM!" def clone_disk_files(self, src):