Pārlūkot izejas kodu

Merge branch 'master' of http://git.woju.eu/qubes/core-admin

Marek Marczykowski-Górecki 10 gadi atpakaļ
vecāks
revīzija
4c2aa8885c
1 mainītis faili ar 16 papildinājumiem un 1 dzēšanām
  1. 16 1
      core-modules/000QubesVm.py

+ 16 - 1
core-modules/000QubesVm.py

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