Revision 2d90608c
b/lib/config.py | ||
---|---|---|
1052 | 1052 |
not hasattr(data.cluster, 'rsahostkeypub')): |
1053 | 1053 |
raise errors.ConfigurationError("Incomplete configuration" |
1054 | 1054 |
" (missing cluster.rsahostkeypub)") |
1055 |
|
|
1056 |
# Upgrade configuration if needed |
|
1057 |
data.UpgradeConfig() |
|
1058 |
|
|
1055 | 1059 |
self._config_data = data |
1056 | 1060 |
# reset the last serial as -1 so that the next write will cause |
1057 | 1061 |
# ssconf update |
b/lib/objects.py | ||
---|---|---|
58 | 58 |
def __init__(self, **kwargs): |
59 | 59 |
for k, v in kwargs.iteritems(): |
60 | 60 |
setattr(self, k, v) |
61 |
self.UpgradeConfig() |
|
62 | 61 |
|
63 | 62 |
def __getattr__(self, name): |
64 | 63 |
if name not in self.__slots__: |
... | ... | |
169 | 168 |
def UpgradeConfig(self): |
170 | 169 |
"""Fill defaults for missing configuration values. |
171 | 170 |
|
172 |
This method will be called at object init time, and its implementation will
|
|
173 |
be object dependent. |
|
171 |
This method will be called at configuration load time, and its
|
|
172 |
implementation will be object dependent.
|
|
174 | 173 |
|
175 | 174 |
""" |
176 | 175 |
pass |
... | ... | |
283 | 282 |
obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance) |
284 | 283 |
return obj |
285 | 284 |
|
285 |
def UpgradeConfig(self): |
|
286 |
"""Fill defaults for missing configuration values. |
|
287 |
|
|
288 |
""" |
|
289 |
self.cluster.UpgradeConfig() |
|
290 |
for node in self.nodes.values(): |
|
291 |
node.UpgradeConfig() |
|
292 |
for instance in self.instances.values(): |
|
293 |
instance.UpgradeConfig() |
|
294 |
|
|
286 | 295 |
|
287 | 296 |
class NIC(ConfigObject): |
288 | 297 |
"""Config object representing a network card.""" |
... | ... | |
536 | 545 |
all_errors.append("Disk access mode '%s' is invalid" % (self.mode, )) |
537 | 546 |
return all_errors |
538 | 547 |
|
548 |
def UpgradeConfig(self): |
|
549 |
"""Fill defaults for missing configuration values. |
|
550 |
|
|
551 |
""" |
|
552 |
if self.children: |
|
553 |
for child in self.children: |
|
554 |
child.UpgradeConfig() |
|
555 |
# add here config upgrade for this disk |
|
556 |
|
|
539 | 557 |
|
540 | 558 |
class Instance(TaggableObject): |
541 | 559 |
"""Config object representing an instance.""" |
... | ... | |
685 | 703 |
obj.disks = cls._ContainerFromDicts(obj.disks, list, Disk) |
686 | 704 |
return obj |
687 | 705 |
|
706 |
def UpgradeConfig(self): |
|
707 |
"""Fill defaults for missing configuration values. |
|
708 |
|
|
709 |
""" |
|
710 |
for nic in self.nics: |
|
711 |
nic.UpgradeConfig() |
|
712 |
for disk in self.disks: |
|
713 |
disk.UpgradeConfig() |
|
714 |
|
|
688 | 715 |
|
689 | 716 |
class OS(ConfigObject): |
690 | 717 |
"""Config object representing an operating system.""" |
Also available in: Unified diff