From ec29fe40fd74f105f28dc22a7c0b39fa81686c92 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 21 Sep 2007 14:59:56 +0000
Subject: [PATCH] Change class hierarchy in objects.py

It makes sense to make the TaggableObject a child of the ConfigObject,
since in this case we can derive the Instance, Node and Cluster objects
only from the TaggableObject and have a cleaner hierarchy.

For consistency child classes will have to declare their slots by adding
their parents on top.

Reviewed-by: imsnah,ultrotter
---
 lib/objects.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/objects.py b/lib/objects.py
index 1314e8872..d1235a731 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -148,11 +148,11 @@ class ConfigObject(object):
     return ConfigObject.Load(StringIO(data))
 
 
-class TaggableObject(object):
+class TaggableObject(ConfigObject):
   """An generic class supporting tags.
 
   """
-  __slots__ = []
+  __slots__ = ConfigObject.__slots__ + ["tags"]
 
   @staticmethod
   def ValidateTag(tag):
@@ -287,9 +287,9 @@ class Disk(ConfigObject):
     return result
 
 
-class Instance(ConfigObject, TaggableObject):
+class Instance(TaggableObject):
   """Config object representing an instance."""
-  __slots__ = [
+  __slots__ = TaggableObject.__slots__ + [
     "name",
     "primary_node",
     "os",
@@ -299,7 +299,6 @@ class Instance(ConfigObject, TaggableObject):
     "nics",
     "disks",
     "disk_template",
-    "tags",
     ]
 
   def _ComputeSecondaryNodes(self):
@@ -407,14 +406,18 @@ class OS(ConfigObject):
     ]
 
 
-class Node(ConfigObject, TaggableObject):
+class Node(TaggableObject):
   """Config object representing a node."""
-  __slots__ = ["name", "primary_ip", "secondary_ip", "tags"]
+  __slots__ = TaggableObject.__slots__ + [
+    "name",
+    "primary_ip",
+    "secondary_ip",
+    ]
 
 
-class Cluster(ConfigObject, TaggableObject):
+class Cluster(TaggableObject):
   """Config object representing the cluster."""
-  __slots__ = [
+  __slots__ = TaggableObject.__slots__ + [
     "config_version",
     "serial_no",
     "rsahostkeypub",
@@ -423,7 +426,6 @@ class Cluster(ConfigObject, TaggableObject):
     "mac_prefix",
     "volume_group_name",
     "default_bridge",
-    "tags",
     ]
 
 
-- 
GitLab