diff --git a/qubes/backup.py b/qubes/backup.py index 57ab6a19..770ba8b6 100644 --- a/qubes/backup.py +++ b/qubes/backup.py @@ -417,7 +417,7 @@ class Backup(object): fmt = "{{0:>{0}}} |".format(fields_to_display[1]["width"] + 1) if qid == 0: s += fmt.format("User home") - elif vm_info['vm'].is_template(): + elif isinstance(vm_info['vm'], qubes.vm.templatevm.TemplateVM): s += fmt.format("Template VM") else: s += fmt.format("VM" + (" + Sys" if vm_info['vm'].updateable @@ -1798,11 +1798,14 @@ class BackupRestore(object): host_template = self.app.domains[template_name] except KeyError: host_template = None - if not host_template or not host_template.is_template(): + if not host_template \ + or not isinstance(host_template, + qubes.vm.templatevm.TemplateVM): # Maybe the (custom) template is in the backup? if not (template_name in restore_info.keys() and restore_info[template_name].good_to_go and - restore_info[template_name].vm.is_template()): + isinstance(restore_info[template_name].vm, + qubes.vm.templatevm.TemplateVM)): if self.options.use_default_template and \ self.app.default_template: if vm_info.orig_template is None: @@ -1940,13 +1943,13 @@ class BackupRestore(object): fields = { "qid": {"func": "vm.qid"}, - "name": {"func": "('[' if vm.is_template() else '')\ + "name": {"func": "('[' if isinstance(vm, qubes.vm.templatevm.TemplateVM) else '')\ + ('{' if vm.is_netvm() else '')\ + vm.name \ - + (']' if vm.is_template() else '')\ + + (']' if isinstance(vm, qubes.vm.templatevm.TemplateVM) else '')\ + ('}' if vm.is_netvm() else '')"}, - "type": {"func": "'Tpl' if vm.is_template() else \ + "type": {"func": "'Tpl' if isinstance(vm, qubes.vm.templatevm.TemplateVM) else \ 'App' if isinstance(vm, qubes.vm.appvm.AppVM) else \ vm.__class__.__name__.replace('VM','')"}, @@ -2113,7 +2116,8 @@ class BackupRestore(object): return # First load templates, then other VMs - for vm in sorted(vms.values(), key=lambda x: x.is_template(), + for vm in sorted(vms.values(), + key=lambda x: isinstance(x, qubes.vm.templatevm.TemplateVM), reverse=True): if self.canceled: # only break the loop to save qubes.xml diff --git a/qubes/storage/file.py b/qubes/storage/file.py index 5b5e04db..78a63771 100644 --- a/qubes/storage/file.py +++ b/qubes/storage/file.py @@ -211,7 +211,9 @@ class FilePool(Pool): string (str) absolute path to the directory where the vm files are stored """ - if vm.is_template(): + # FIX Remove this if we drop the file backend + import qubes.vm.templatevm # nopep8 + if isinstance(vm, qubes.vm.templatevm.TemplateVM): subdir = 'vm-templates' elif vm.is_disposablevm(): subdir = 'appvms' diff --git a/qubes/tests/int/basic.py b/qubes/tests/int/basic.py index cd265fc6..4cfe154f 100644 --- a/qubes/tests/int/basic.py +++ b/qubes/tests/int/basic.py @@ -330,7 +330,7 @@ class TC_02_QvmPrefs(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase): @unittest.skip('test not converted to core3 API') def test_006_template(self): templates = [tpl for tpl in self.app.domains.values() if - tpl.is_template()] + isinstance(tpl, qubes.vm.templatevm.TemplateVM)] if not templates: self.skipTest("No templates installed") some_template = templates[0].name diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index b39f2306..d75988e4 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -386,12 +386,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): return os.path.join(self.dir_path, 'libvirt.xml') # XXX I don't know what to do with these; probably should be isinstance(...) - def is_template(self): - warnings.warn('vm.is_template() is deprecated, use isinstance()', - DeprecationWarning) - import qubes.vm.templatevm # pylint: disable=redefined-outer-name - return isinstance(self, qubes.vm.templatevm.TemplateVM) - def is_appvm(self): warnings.warn('vm.is_appvm() is deprecated, use isinstance()', DeprecationWarning) @@ -1495,7 +1489,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): return used_dmdev != current_dmdev - # # helper methods #