restore.py: sort into three tiers in _templates_first()
This commit is contained in:
parent
01ce5387d3
commit
68c8b7fafc
@ -1664,18 +1664,19 @@ class BackupRestore(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _templates_first(vms):
|
def _templates_first(vms):
|
||||||
'''Sort templates befor other VM types (AppVM etc)'''
|
'''Sort templates before other VM types'''
|
||||||
def key_function(instance):
|
def key_function(instance):
|
||||||
'''Key function for :py:func:`sorted`'''
|
'''Key function for :py:func:`sorted`'''
|
||||||
if isinstance(instance, BackupVM):
|
if isinstance(instance, BackupVM):
|
||||||
return instance.klass == 'TemplateVM'
|
if instance.klass == 'TemplateVM':
|
||||||
|
return 0
|
||||||
|
elif instance.properties.get('template_for_dispvms', False):
|
||||||
|
return 1
|
||||||
|
return 2
|
||||||
elif hasattr(instance, 'vm'):
|
elif hasattr(instance, 'vm'):
|
||||||
return key_function(instance.vm)
|
return key_function(instance.vm)
|
||||||
return 0
|
return 9
|
||||||
return sorted(vms,
|
return sorted(vms, key=key_function)
|
||||||
key=key_function,
|
|
||||||
reverse=True)
|
|
||||||
|
|
||||||
|
|
||||||
def _handle_dom0(self, stream):
|
def _handle_dom0(self, stream):
|
||||||
'''Extract dom0 home'''
|
'''Extract dom0 home'''
|
||||||
|
Loading…
Reference in New Issue
Block a user