This commit is contained in:
Marek Marczykowski-Górecki 2014-05-07 03:18:33 +02:00
commit 4c2aa8885c

View File

@ -74,6 +74,7 @@ class QubesVm(object):
hooks_remove_from_disk = [] hooks_remove_from_disk = []
hooks_start = [] hooks_start = []
hooks_verify_files = [] hooks_verify_files = []
hooks_set_attr = []
def get_attrs_config(self): def get_attrs_config(self):
""" Object attributes for serialization/deserialization """ Object attributes for serialization/deserialization
@ -129,7 +130,7 @@ class QubesVm(object):
eval(value) if value.find("[") >= 0 else eval(value) if value.find("[") >= 0 else
eval("[" + value + "]") }, eval("[" + value + "]") },
# Internal VM (not shown in qubes-manager, doesn't create appmenus entries # Internal VM (not shown in qubes-manager, doesn't create appmenus entries
"internal": { "default": False }, "internal": { "default": False, 'attr': '_internal' },
"vcpus": { "default": None }, "vcpus": { "default": None },
"uses_default_kernel": { "default": True, 'order': 30 }, "uses_default_kernel": { "default": True, 'order': 30 },
"uses_default_kernelopts": { "default": True, 'order': 30 }, "uses_default_kernelopts": { "default": True, 'order': 30 },
@ -218,6 +219,10 @@ class QubesVm(object):
attrs = hook(self, attrs) attrs = hook(self, attrs)
return attrs return attrs
def post_set_attr(self, attr, newvalue, oldvalue):
for hook in self.hooks_set_attr:
hook(self, attr, newvalue, oldvalue)
def __basic_parse_xml_attr(self, value): def __basic_parse_xml_attr(self, value):
if value is None: if value is None:
return None return None
@ -512,6 +517,16 @@ class QubesVm(object):
for hook in self.hooks_post_rename: for hook in self.hooks_post_rename:
hook(self, old_name) hook(self, old_name)
@property
def internal(self):
return self._internal
@internal.setter
def internal(self, value):
oldvalue = self._internal
self._internal = value
self.post_set_attr('internal', value, oldvalue)
@property @property
def autostart(self): def autostart(self):
return self._autostart return self._autostart