4 # Copyright (C) 2006, 2007 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Transportable objects for Ganeti.
24 This module provides small, mostly data-only objects which are safe to
25 pass to and from external parties.
29 # pylint: disable-msg=E0203,W0201
31 # E0203: Access to member %r before its definition, since we use
32 # objects.py which doesn't explicitely initialise its members
34 # W0201: Attribute '%s' defined outside __init__
39 from cStringIO import StringIO
41 from ganeti import errors
42 from ganeti import constants
45 __all__ = ["ConfigObject", "ConfigData", "NIC", "Disk", "Instance",
46 "OS", "Node", "Cluster", "FillDict"]
48 _TIMESTAMPS = ["ctime", "mtime"]
51 def FillDict(defaults_dict, custom_dict, skip_keys=None):
52 """Basic function to apply settings on top a default dict.
54 @type defaults_dict: dict
55 @param defaults_dict: dictionary holding the default values
56 @type custom_dict: dict
57 @param custom_dict: dictionary holding customized value
59 @param skip_keys: which keys not to fill
61 @return: dict with the 'full' values
64 ret_dict = copy.deepcopy(defaults_dict)
65 ret_dict.update(custom_dict)
75 def UpgradeGroupedParams(target, defaults):
76 """Update all groups for the target parameter.
78 @type target: dict of dicts
79 @param target: {group: {parameter: value}}
81 @param defaults: default parameter values
85 target = {constants.PP_DEFAULT: defaults}
88 target[group] = FillDict(defaults, target[group])
92 class ConfigObject(object):
93 """A generic config object.
95 It has the following properties:
97 - provides somewhat safe recursive unpickling and pickling for its classes
98 - unset attributes which are defined in slots are always returned
99 as None instead of raising an error
101 Classes derived from this must always declare __slots__ (we use many
102 config objects and the memory reduction is useful)
107 def __init__(self, **kwargs):
108 for k, v in kwargs.iteritems():
111 def __getattr__(self, name):
112 if name not in self._all_slots():
113 raise AttributeError("Invalid object attribute %s.%s" %
114 (type(self).__name__, name))
117 def __setstate__(self, state):
118 slots = self._all_slots()
121 setattr(self, name, state[name])
125 """Compute the list of all declared slots for a class.
129 for parent in cls.__mro__:
130 slots.extend(getattr(parent, "__slots__", []))
134 """Convert to a dict holding only standard python types.
136 The generic routine just dumps all of this object's attributes in
137 a dict. It does not work if the class has children who are
138 ConfigObjects themselves (e.g. the nics list in an Instance), in
139 which case the object should subclass the function in order to
140 make sure all objects returned are only standard python types.
144 for name in self._all_slots():
145 value = getattr(self, name, None)
146 if value is not None:
150 __getstate__ = ToDict
153 def FromDict(cls, val):
154 """Create an object from a dictionary.
156 This generic routine takes a dict, instantiates a new instance of
157 the given class, and sets attributes based on the dict content.
159 As for `ToDict`, this does not work if the class has children
160 who are ConfigObjects themselves (e.g. the nics list in an
161 Instance), in which case the object should subclass the function
162 and alter the objects.
165 if not isinstance(val, dict):
166 raise errors.ConfigurationError("Invalid object passed to FromDict:"
167 " expected dict, got %s" % type(val))
168 val_str = dict([(str(k), v) for k, v in val.iteritems()])
169 obj = cls(**val_str) # pylint: disable-msg=W0142
173 def _ContainerToDicts(container):
174 """Convert the elements of a container to standard python types.
176 This method converts a container with elements derived from
177 ConfigData to standard python types. If the container is a dict,
178 we don't touch the keys, only the values.
181 if isinstance(container, dict):
182 ret = dict([(k, v.ToDict()) for k, v in container.iteritems()])
183 elif isinstance(container, (list, tuple, set, frozenset)):
184 ret = [elem.ToDict() for elem in container]
186 raise TypeError("Invalid type %s passed to _ContainerToDicts" %
191 def _ContainerFromDicts(source, c_type, e_type):
192 """Convert a container from standard python types.
194 This method converts a container with standard python types to
195 ConfigData objects. If the container is a dict, we don't touch the
196 keys, only the values.
199 if not isinstance(c_type, type):
200 raise TypeError("Container type %s passed to _ContainerFromDicts is"
201 " not a type" % type(c_type))
203 ret = dict([(k, e_type.FromDict(v)) for k, v in source.iteritems()])
204 elif c_type in (list, tuple, set, frozenset):
205 ret = c_type([e_type.FromDict(elem) for elem in source])
207 raise TypeError("Invalid container type %s passed to"
208 " _ContainerFromDicts" % c_type)
212 """Makes a deep copy of the current object and its children.
215 dict_form = self.ToDict()
216 clone_obj = self.__class__.FromDict(dict_form)
220 """Implement __repr__ for ConfigObjects."""
221 return repr(self.ToDict())
223 def UpgradeConfig(self):
224 """Fill defaults for missing configuration values.
226 This method will be called at configuration load time, and its
227 implementation will be object dependent.
233 class TaggableObject(ConfigObject):
234 """An generic class supporting tags.
238 VALID_TAG_RE = re.compile("^[\w.+*/:@-]+$")
241 def ValidateTag(cls, tag):
242 """Check if a tag is valid.
244 If the tag is invalid, an errors.TagError will be raised. The
245 function has no return value.
248 if not isinstance(tag, basestring):
249 raise errors.TagError("Invalid tag type (not a string)")
250 if len(tag) > constants.MAX_TAG_LEN:
251 raise errors.TagError("Tag too long (>%d characters)" %
252 constants.MAX_TAG_LEN)
254 raise errors.TagError("Tags cannot be empty")
255 if not cls.VALID_TAG_RE.match(tag):
256 raise errors.TagError("Tag contains invalid characters")
259 """Return the tags list.
262 tags = getattr(self, "tags", None)
264 tags = self.tags = set()
267 def AddTag(self, tag):
271 self.ValidateTag(tag)
272 tags = self.GetTags()
273 if len(tags) >= constants.MAX_TAGS_PER_OBJ:
274 raise errors.TagError("Too many tags")
275 self.GetTags().add(tag)
277 def RemoveTag(self, tag):
281 self.ValidateTag(tag)
282 tags = self.GetTags()
286 raise errors.TagError("Tag not found")
289 """Taggable-object-specific conversion to standard python types.
291 This replaces the tags set with a list.
294 bo = super(TaggableObject, self).ToDict()
296 tags = bo.get("tags", None)
297 if isinstance(tags, set):
298 bo["tags"] = list(tags)
302 def FromDict(cls, val):
303 """Custom function for instances.
306 obj = super(TaggableObject, cls).FromDict(val)
307 if hasattr(obj, "tags") and isinstance(obj.tags, list):
308 obj.tags = set(obj.tags)
312 class ConfigData(ConfigObject):
313 """Top-level config object."""
314 __slots__ = (["version", "cluster", "nodes", "instances", "serial_no"] +
318 """Custom function for top-level config data.
320 This just replaces the list of instances, nodes and the cluster
321 with standard python types.
324 mydict = super(ConfigData, self).ToDict()
325 mydict["cluster"] = mydict["cluster"].ToDict()
326 for key in "nodes", "instances":
327 mydict[key] = self._ContainerToDicts(mydict[key])
332 def FromDict(cls, val):
333 """Custom function for top-level config data
336 obj = super(ConfigData, cls).FromDict(val)
337 obj.cluster = Cluster.FromDict(obj.cluster)
338 obj.nodes = cls._ContainerFromDicts(obj.nodes, dict, Node)
339 obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
342 def UpgradeConfig(self):
343 """Fill defaults for missing configuration values.
346 self.cluster.UpgradeConfig()
347 for node in self.nodes.values():
349 for instance in self.instances.values():
350 instance.UpgradeConfig()
353 class NIC(ConfigObject):
354 """Config object representing a network card."""
355 __slots__ = ["mac", "ip", "bridge", "nicparams"]
358 def CheckParameterSyntax(cls, nicparams):
359 """Check the given parameters for validity.
361 @type nicparams: dict
362 @param nicparams: dictionary with parameter names/value
363 @raise errors.ConfigurationError: when a parameter is not valid
366 if nicparams[constants.NIC_MODE] not in constants.NIC_VALID_MODES:
367 err = "Invalid nic mode: %s" % nicparams[constants.NIC_MODE]
368 raise errors.ConfigurationError(err)
370 if (nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED and
371 not nicparams[constants.NIC_LINK]):
372 err = "Missing bridged nic link"
373 raise errors.ConfigurationError(err)
375 def UpgradeConfig(self):
376 """Fill defaults for missing configuration values.
379 if self.nicparams is None:
381 if self.bridge is not None:
382 self.nicparams[constants.NIC_MODE] = constants.NIC_MODE_BRIDGED
383 self.nicparams[constants.NIC_LINK] = self.bridge
384 # bridge is no longer used it 2.1. The slot is left there to support
385 # upgrading, but will be removed in 2.2
386 if self.bridge is not None:
390 class Disk(ConfigObject):
391 """Config object representing a block device."""
392 __slots__ = ["dev_type", "logical_id", "physical_id",
393 "children", "iv_name", "size", "mode"]
395 def CreateOnSecondary(self):
396 """Test if this device needs to be created on a secondary node."""
397 return self.dev_type in (constants.LD_DRBD8, constants.LD_LV)
399 def AssembleOnSecondary(self):
400 """Test if this device needs to be assembled on a secondary node."""
401 return self.dev_type in (constants.LD_DRBD8, constants.LD_LV)
403 def OpenOnSecondary(self):
404 """Test if this device needs to be opened on a secondary node."""
405 return self.dev_type in (constants.LD_LV,)
407 def StaticDevPath(self):
408 """Return the device path if this device type has a static one.
410 Some devices (LVM for example) live always at the same /dev/ path,
411 irrespective of their status. For such devices, we return this
412 path, for others we return None.
414 @warning: The path returned is not a normalized pathname; callers
415 should check that it is a valid path.
418 if self.dev_type == constants.LD_LV:
419 return "/dev/%s/%s" % (self.logical_id[0], self.logical_id[1])
422 def ChildrenNeeded(self):
423 """Compute the needed number of children for activation.
425 This method will return either -1 (all children) or a positive
426 number denoting the minimum number of children needed for
427 activation (only mirrored devices will usually return >=0).
429 Currently, only DRBD8 supports diskless activation (therefore we
430 return 0), for all other we keep the previous semantics and return
434 if self.dev_type == constants.LD_DRBD8:
438 def GetNodes(self, node):
439 """This function returns the nodes this device lives on.
441 Given the node on which the parent of the device lives on (or, in
442 case of a top-level device, the primary node of the devices'
443 instance), this function will return a list of nodes on which this
444 devices needs to (or can) be assembled.
447 if self.dev_type in [constants.LD_LV, constants.LD_FILE]:
449 elif self.dev_type in constants.LDS_DRBD:
450 result = [self.logical_id[0], self.logical_id[1]]
451 if node not in result:
452 raise errors.ConfigurationError("DRBD device passed unknown node")
454 raise errors.ProgrammerError("Unhandled device type %s" % self.dev_type)
457 def ComputeNodeTree(self, parent_node):
458 """Compute the node/disk tree for this disk and its children.
460 This method, given the node on which the parent disk lives, will
461 return the list of all (node, disk) pairs which describe the disk
462 tree in the most compact way. For example, a drbd/lvm stack
463 will be returned as (primary_node, drbd) and (secondary_node, drbd)
464 which represents all the top-level devices on the nodes.
467 my_nodes = self.GetNodes(parent_node)
468 result = [(node, self) for node in my_nodes]
469 if not self.children:
472 for node in my_nodes:
473 for child in self.children:
474 child_result = child.ComputeNodeTree(node)
475 if len(child_result) == 1:
476 # child (and all its descendants) is simple, doesn't split
477 # over multiple hosts, so we don't need to describe it, our
478 # own entry for this node describes it completely
481 # check if child nodes differ from my nodes; note that
482 # subdisk can differ from the child itself, and be instead
483 # one of its descendants
484 for subnode, subdisk in child_result:
485 if subnode not in my_nodes:
486 result.append((subnode, subdisk))
487 # otherwise child is under our own node, so we ignore this
488 # entry (but probably the other results in the list will
492 def RecordGrow(self, amount):
493 """Update the size of this disk after growth.
495 This method recurses over the disks's children and updates their
496 size correspondigly. The method needs to be kept in sync with the
497 actual algorithms from bdev.
500 if self.dev_type == constants.LD_LV or self.dev_type == constants.LD_FILE:
502 elif self.dev_type == constants.LD_DRBD8:
504 self.children[0].RecordGrow(amount)
507 raise errors.ProgrammerError("Disk.RecordGrow called for unsupported"
508 " disk type %s" % self.dev_type)
511 """Sets recursively the size to zero for the disk and its children.
515 for child in self.children:
519 def SetPhysicalID(self, target_node, nodes_ip):
520 """Convert the logical ID to the physical ID.
522 This is used only for drbd, which needs ip/port configuration.
524 The routine descends down and updates its children also, because
525 this helps when the only the top device is passed to the remote
529 - target_node: the node we wish to configure for
530 - nodes_ip: a mapping of node name to ip
532 The target_node must exist in in nodes_ip, and must be one of the
533 nodes in the logical ID for each of the DRBD devices encountered
538 for child in self.children:
539 child.SetPhysicalID(target_node, nodes_ip)
541 if self.logical_id is None and self.physical_id is not None:
543 if self.dev_type in constants.LDS_DRBD:
544 pnode, snode, port, pminor, sminor, secret = self.logical_id
545 if target_node not in (pnode, snode):
546 raise errors.ConfigurationError("DRBD device not knowing node %s" %
548 pnode_ip = nodes_ip.get(pnode, None)
549 snode_ip = nodes_ip.get(snode, None)
550 if pnode_ip is None or snode_ip is None:
551 raise errors.ConfigurationError("Can't find primary or secondary node"
552 " for %s" % str(self))
553 p_data = (pnode_ip, port)
554 s_data = (snode_ip, port)
555 if pnode == target_node:
556 self.physical_id = p_data + s_data + (pminor, secret)
557 else: # it must be secondary, we tested above
558 self.physical_id = s_data + p_data + (sminor, secret)
560 self.physical_id = self.logical_id
564 """Disk-specific conversion to standard python types.
566 This replaces the children lists of objects with lists of
567 standard python types.
570 bo = super(Disk, self).ToDict()
572 for attr in ("children",):
573 alist = bo.get(attr, None)
575 bo[attr] = self._ContainerToDicts(alist)
579 def FromDict(cls, val):
580 """Custom function for Disks
583 obj = super(Disk, cls).FromDict(val)
585 obj.children = cls._ContainerFromDicts(obj.children, list, Disk)
586 if obj.logical_id and isinstance(obj.logical_id, list):
587 obj.logical_id = tuple(obj.logical_id)
588 if obj.physical_id and isinstance(obj.physical_id, list):
589 obj.physical_id = tuple(obj.physical_id)
590 if obj.dev_type in constants.LDS_DRBD:
591 # we need a tuple of length six here
592 if len(obj.logical_id) < 6:
593 obj.logical_id += (None,) * (6 - len(obj.logical_id))
597 """Custom str() formatter for disks.
600 if self.dev_type == constants.LD_LV:
601 val = "<LogicalVolume(/dev/%s/%s" % self.logical_id
602 elif self.dev_type in constants.LDS_DRBD:
603 node_a, node_b, port, minor_a, minor_b = self.logical_id[:5]
605 if self.physical_id is None:
608 phy = ("configured as %s:%s %s:%s" %
609 (self.physical_id[0], self.physical_id[1],
610 self.physical_id[2], self.physical_id[3]))
612 val += ("hosts=%s/%d-%s/%d, port=%s, %s, " %
613 (node_a, minor_a, node_b, minor_b, port, phy))
614 if self.children and self.children.count(None) == 0:
615 val += "backend=%s, metadev=%s" % (self.children[0], self.children[1])
617 val += "no local storage"
619 val = ("<Disk(type=%s, logical_id=%s, physical_id=%s, children=%s" %
620 (self.dev_type, self.logical_id, self.physical_id, self.children))
621 if self.iv_name is None:
622 val += ", not visible"
624 val += ", visible as /dev/%s" % self.iv_name
625 if isinstance(self.size, int):
626 val += ", size=%dm)>" % self.size
628 val += ", size='%s')>" % (self.size,)
632 """Checks that this disk is correctly configured.
636 if self.mode not in constants.DISK_ACCESS_SET:
637 all_errors.append("Disk access mode '%s' is invalid" % (self.mode, ))
640 def UpgradeConfig(self):
641 """Fill defaults for missing configuration values.
645 for child in self.children:
646 child.UpgradeConfig()
647 # add here config upgrade for this disk
650 class Instance(TaggableObject):
651 """Config object representing an instance."""
665 ] + _TIMESTAMPS + _UUID
667 def _ComputeSecondaryNodes(self):
668 """Compute the list of secondary nodes.
670 This is a simple wrapper over _ComputeAllNodes.
673 all_nodes = set(self._ComputeAllNodes())
674 all_nodes.discard(self.primary_node)
675 return tuple(all_nodes)
677 secondary_nodes = property(_ComputeSecondaryNodes, None, None,
678 "List of secondary nodes")
680 def _ComputeAllNodes(self):
681 """Compute the list of all nodes.
683 Since the data is already there (in the drbd disks), keeping it as
684 a separate normal attribute is redundant and if not properly
685 synchronised can cause problems. Thus it's better to compute it
689 def _Helper(nodes, device):
690 """Recursively computes nodes given a top device."""
691 if device.dev_type in constants.LDS_DRBD:
692 nodea, nodeb = device.logical_id[:2]
696 for child in device.children:
697 _Helper(nodes, child)
700 all_nodes.add(self.primary_node)
701 for device in self.disks:
702 _Helper(all_nodes, device)
703 return tuple(all_nodes)
705 all_nodes = property(_ComputeAllNodes, None, None,
706 "List of all nodes of the instance")
708 def MapLVsByNode(self, lvmap=None, devs=None, node=None):
709 """Provide a mapping of nodes to LVs this instance owns.
711 This function figures out what logical volumes should belong on
712 which nodes, recursing through a device tree.
714 @param lvmap: optional dictionary to receive the
715 'node' : ['lv', ...] data.
717 @return: None if lvmap arg is given, otherwise, a dictionary
718 of the form { 'nodename' : ['volume1', 'volume2', ...], ... }
722 node = self.primary_node
725 lvmap = { node : [] }
728 if not node in lvmap:
736 if dev.dev_type == constants.LD_LV:
737 lvmap[node].append(dev.logical_id[1])
739 elif dev.dev_type in constants.LDS_DRBD:
741 self.MapLVsByNode(lvmap, dev.children, dev.logical_id[0])
742 self.MapLVsByNode(lvmap, dev.children, dev.logical_id[1])
745 self.MapLVsByNode(lvmap, dev.children, node)
749 def FindDisk(self, idx):
750 """Find a disk given having a specified index.
752 This is just a wrapper that does validation of the index.
755 @param idx: the disk index
757 @return: the corresponding disk
758 @raise errors.OpPrereqError: when the given index is not valid
763 return self.disks[idx]
764 except (TypeError, ValueError), err:
765 raise errors.OpPrereqError("Invalid disk index: '%s'" % str(err),
768 raise errors.OpPrereqError("Invalid disk index: %d (instace has disks"
769 " 0 to %d" % (idx, len(self.disks)),
773 """Instance-specific conversion to standard python types.
775 This replaces the children lists of objects with lists of standard
779 bo = super(Instance, self).ToDict()
781 for attr in "nics", "disks":
782 alist = bo.get(attr, None)
784 nlist = self._ContainerToDicts(alist)
791 def FromDict(cls, val):
792 """Custom function for instances.
795 obj = super(Instance, cls).FromDict(val)
796 obj.nics = cls._ContainerFromDicts(obj.nics, list, NIC)
797 obj.disks = cls._ContainerFromDicts(obj.disks, list, Disk)
800 def UpgradeConfig(self):
801 """Fill defaults for missing configuration values.
804 for nic in self.nics:
806 for disk in self.disks:
809 for key in constants.HVC_GLOBALS:
811 del self.hvparams[key]
816 class OS(ConfigObject):
817 """Config object representing an operating system."""
826 "supported_variants",
830 class Node(TaggableObject):
831 """Config object representing a node."""
840 ] + _TIMESTAMPS + _UUID
843 class Cluster(TaggableObject):
844 """Config object representing the cluster."""
853 "default_hypervisor",
859 "enabled_hypervisors",
864 "candidate_pool_size",
867 ] + _TIMESTAMPS + _UUID
869 def UpgradeConfig(self):
870 """Fill defaults for missing configuration values.
873 # pylint: disable-msg=E0203
874 # because these are "defined" via slots, not manually
875 if self.hvparams is None:
876 self.hvparams = constants.HVC_DEFAULTS
878 for hypervisor in self.hvparams:
879 self.hvparams[hypervisor] = FillDict(
880 constants.HVC_DEFAULTS[hypervisor], self.hvparams[hypervisor])
882 # TODO: Figure out if it's better to put this into OS than Cluster
883 if self.os_hvp is None:
886 self.beparams = UpgradeGroupedParams(self.beparams,
887 constants.BEC_DEFAULTS)
888 migrate_default_bridge = not self.nicparams
889 self.nicparams = UpgradeGroupedParams(self.nicparams,
890 constants.NICC_DEFAULTS)
891 if migrate_default_bridge:
892 self.nicparams[constants.PP_DEFAULT][constants.NIC_LINK] = \
895 if self.modify_etc_hosts is None:
896 self.modify_etc_hosts = True
898 if self.modify_ssh_setup is None:
899 self.modify_ssh_setup = True
901 # default_bridge is no longer used it 2.1. The slot is left there to
902 # support auto-upgrading, but will be removed in 2.2
903 if self.default_bridge is not None:
904 self.default_bridge = None
906 # default_hypervisor is just the first enabled one in 2.1
907 if self.default_hypervisor is not None:
908 self.enabled_hypervisors = ([self.default_hypervisor] +
909 [hvname for hvname in self.enabled_hypervisors
910 if hvname != self.default_hypervisor])
911 self.default_hypervisor = None
914 """Custom function for cluster.
917 mydict = super(Cluster, self).ToDict()
918 mydict["tcpudp_port_pool"] = list(self.tcpudp_port_pool)
922 def FromDict(cls, val):
923 """Custom function for cluster.
926 obj = super(Cluster, cls).FromDict(val)
927 if not isinstance(obj.tcpudp_port_pool, set):
928 obj.tcpudp_port_pool = set(obj.tcpudp_port_pool)
931 def FillHV(self, instance, skip_globals=False):
932 """Fill an instance's hvparams dict.
934 @type instance: L{objects.Instance}
935 @param instance: the instance parameter to fill
936 @type skip_globals: boolean
937 @param skip_globals: if True, the global hypervisor parameters will
940 @return: a copy of the instance's hvparams with missing keys filled from
945 skip_keys = constants.HVC_GLOBALS
949 # We fill the list from least to most important override
951 self.hvparams.get(instance.hypervisor, {}),
952 self.os_hvp.get(instance.os, {}).get(instance.hypervisor, {}),
957 for o_dict in fill_stack:
958 ret_dict = FillDict(ret_dict, o_dict, skip_keys=skip_keys)
962 def FillBE(self, instance):
963 """Fill an instance's beparams dict.
965 @type instance: L{objects.Instance}
966 @param instance: the instance parameter to fill
968 @return: a copy of the instance's beparams with missing keys filled from
972 return FillDict(self.beparams.get(constants.PP_DEFAULT, {}),
976 class BlockDevStatus(ConfigObject):
977 """Config object representing the status of a block device."""
989 class ConfdRequest(ConfigObject):
990 """Object holding a confd request.
992 @ivar protocol: confd protocol version
993 @ivar type: confd query type
994 @ivar query: query request
995 @ivar rsalt: requested reply salt
1006 class ConfdReply(ConfigObject):
1007 """Object holding a confd reply.
1009 @ivar protocol: confd protocol version
1010 @ivar status: reply status code (ok, error)
1011 @ivar answer: confd query reply
1012 @ivar serial: configuration serial number
1023 class SerializableConfigParser(ConfigParser.SafeConfigParser):
1024 """Simple wrapper over ConfigParse that allows serialization.
1026 This class is basically ConfigParser.SafeConfigParser with two
1027 additional methods that allow it to serialize/unserialize to/from a
1032 """Dump this instance and return the string representation."""
1035 return buf.getvalue()
1038 def Loads(cls, data):
1039 """Load data from a string."""
1040 buf = StringIO(data)