Remove QubesVM.is_template()
This commit is contained in:
parent
ba3b191702
commit
e08ca1ff57
@ -417,7 +417,7 @@ class Backup(object):
|
|||||||
fmt = "{{0:>{0}}} |".format(fields_to_display[1]["width"] + 1)
|
fmt = "{{0:>{0}}} |".format(fields_to_display[1]["width"] + 1)
|
||||||
if qid == 0:
|
if qid == 0:
|
||||||
s += fmt.format("User home")
|
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")
|
s += fmt.format("Template VM")
|
||||||
else:
|
else:
|
||||||
s += fmt.format("VM" + (" + Sys" if vm_info['vm'].updateable
|
s += fmt.format("VM" + (" + Sys" if vm_info['vm'].updateable
|
||||||
@ -1798,11 +1798,14 @@ class BackupRestore(object):
|
|||||||
host_template = self.app.domains[template_name]
|
host_template = self.app.domains[template_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
host_template = None
|
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?
|
# Maybe the (custom) template is in the backup?
|
||||||
if not (template_name in restore_info.keys() and
|
if not (template_name in restore_info.keys() and
|
||||||
restore_info[template_name].good_to_go 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 \
|
if self.options.use_default_template and \
|
||||||
self.app.default_template:
|
self.app.default_template:
|
||||||
if vm_info.orig_template is None:
|
if vm_info.orig_template is None:
|
||||||
@ -1940,13 +1943,13 @@ class BackupRestore(object):
|
|||||||
fields = {
|
fields = {
|
||||||
"qid": {"func": "vm.qid"},
|
"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 '')\
|
+ ('{' if vm.is_netvm() else '')\
|
||||||
+ vm.name \
|
+ vm.name \
|
||||||
+ (']' if vm.is_template() else '')\
|
+ (']' if isinstance(vm, qubes.vm.templatevm.TemplateVM) else '')\
|
||||||
+ ('}' if vm.is_netvm() 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 \
|
'App' if isinstance(vm, qubes.vm.appvm.AppVM) else \
|
||||||
vm.__class__.__name__.replace('VM','')"},
|
vm.__class__.__name__.replace('VM','')"},
|
||||||
|
|
||||||
@ -2113,7 +2116,8 @@ class BackupRestore(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# First load templates, then other VMs
|
# 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):
|
reverse=True):
|
||||||
if self.canceled:
|
if self.canceled:
|
||||||
# only break the loop to save qubes.xml
|
# only break the loop to save qubes.xml
|
||||||
|
@ -211,7 +211,9 @@ class FilePool(Pool):
|
|||||||
string (str) absolute path to the directory where the vm files
|
string (str) absolute path to the directory where the vm files
|
||||||
are stored
|
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'
|
subdir = 'vm-templates'
|
||||||
elif vm.is_disposablevm():
|
elif vm.is_disposablevm():
|
||||||
subdir = 'appvms'
|
subdir = 'appvms'
|
||||||
|
@ -330,7 +330,7 @@ class TC_02_QvmPrefs(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
|||||||
@unittest.skip('test not converted to core3 API')
|
@unittest.skip('test not converted to core3 API')
|
||||||
def test_006_template(self):
|
def test_006_template(self):
|
||||||
templates = [tpl for tpl in self.app.domains.values() if
|
templates = [tpl for tpl in self.app.domains.values() if
|
||||||
tpl.is_template()]
|
isinstance(tpl, qubes.vm.templatevm.TemplateVM)]
|
||||||
if not templates:
|
if not templates:
|
||||||
self.skipTest("No templates installed")
|
self.skipTest("No templates installed")
|
||||||
some_template = templates[0].name
|
some_template = templates[0].name
|
||||||
|
@ -386,12 +386,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
return os.path.join(self.dir_path, 'libvirt.xml')
|
return os.path.join(self.dir_path, 'libvirt.xml')
|
||||||
|
|
||||||
# XXX I don't know what to do with these; probably should be isinstance(...)
|
# 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):
|
def is_appvm(self):
|
||||||
warnings.warn('vm.is_appvm() is deprecated, use isinstance()',
|
warnings.warn('vm.is_appvm() is deprecated, use isinstance()',
|
||||||
DeprecationWarning)
|
DeprecationWarning)
|
||||||
@ -1495,7 +1489,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
|
|
||||||
return used_dmdev != current_dmdev
|
return used_dmdev != current_dmdev
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# helper methods
|
# helper methods
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user