Remove QubesVM.is_template()

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2016-06-16 21:27:56 +02:00
parent ba3b191702
commit e08ca1ff57
No known key found for this signature in database
GPG Key ID: 96ED3C3BA19C3DEE
4 changed files with 15 additions and 16 deletions

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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
#