Revision 90d726a8 lib/objects.py

b/lib/objects.py
92 92
  def __init__(self, **kwargs):
93 93
    for k, v in kwargs.iteritems():
94 94
      setattr(self, k, v)
95
    self.UpgradeConfig()
96 95

  
97 96
  def __getattr__(self, name):
98 97
    if name not in self.__slots__:
......
198 197
  def UpgradeConfig(self):
199 198
    """Fill defaults for missing configuration values.
200 199

  
201
    This method will be called at object init time, and its implementation will
202
    be object dependent.
200
    This method will be called at configuration load time, and its
201
    implementation will be object dependent.
203 202

  
204 203
    """
205 204
    pass
......
313 312
    obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
314 313
    return obj
315 314

  
315
  def UpgradeConfig(self):
316
    """Fill defaults for missing configuration values.
317

  
318
    """
319
    self.cluster.UpgradeConfig()
320
    for node in self.nodes.values():
321
      node.UpgradeConfig()
322
    for instance in self.instances.values():
323
      instance.UpgradeConfig()
324

  
316 325

  
317 326
class NIC(ConfigObject):
318 327
  """Config object representing a network card."""
......
598 607
      all_errors.append("Disk access mode '%s' is invalid" % (self.mode, ))
599 608
    return all_errors
600 609

  
610
  def UpgradeConfig(self):
611
    """Fill defaults for missing configuration values.
612

  
613
    """
614
    if self.children:
615
      for child in self.children:
616
        child.UpgradeConfig()
617
    # add here config upgrade for this disk
618

  
601 619

  
602 620
class Instance(TaggableObject):
603 621
  """Config object representing an instance."""
......
747 765
    obj.disks = cls._ContainerFromDicts(obj.disks, list, Disk)
748 766
    return obj
749 767

  
768
  def UpgradeConfig(self):
769
    """Fill defaults for missing configuration values.
770

  
771
    """
772
    for nic in self.nics:
773
      nic.UpgradeConfig()
774
    for disk in self.disks:
775
      disk.UpgradeConfig()
776

  
750 777

  
751 778
class OS(ConfigObject):
752 779
  """Config object representing an operating system."""

Also available in: Unified diff