Skip to content
Snippets Groups Projects
Commit 24a3707f authored by Guido Trotter's avatar Guido Trotter
Browse files

Add a new NodeGroup config object


The "members" slot of this object is not serialized, and is discarded
when deserializing, initializing it explicitly to [].

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 84a5b33c
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ from socket import AF_INET
__all__ = ["ConfigObject", "ConfigData", "NIC", "Disk", "Instance",
"OS", "Node", "Cluster", "FillDict"]
"OS", "Node", "NodeGroup", "Cluster", "FillDict"]
_TIMESTAMPS = ["ctime", "mtime"]
_UUID = ["uuid"]
......@@ -891,6 +891,35 @@ class Node(TaggableObject):
] + _TIMESTAMPS + _UUID
class NodeGroup(ConfigObject):
"""Config object representing a node group."""
__slots__ = [
"name",
"members",
] + _TIMESTAMPS + _UUID
def ToDict(self):
"""Custom function for nodegroup.
This discards the members object, which gets recalculated and is only kept in memory.
"""
mydict = super(NodeGroup, self).ToDict()
del mydict["members"]
return mydict
@classmethod
def FromDict(cls, val):
"""Custom function for nodegroup.
The members slot is initialized to an empty list, upon deserialization.
"""
obj = super(NodeGroup, cls).FromDict(val)
obj.members = []
return obj
class Cluster(TaggableObject):
"""Config object representing the cluster."""
__slots__ = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment