Revision e00fb268 lib/config.py
b/lib/config.py | ||
---|---|---|
297 | 297 |
if not isinstance(instance, objects.Instance): |
298 | 298 |
raise errors.ProgrammerError("Invalid type passed to AddInstance") |
299 | 299 |
|
300 |
all_lvs = instance.MapLVsByNode() |
|
301 |
logger.Info("Instance '%s' DISK_LAYOUT: %s" % (instance.name, all_lvs)) |
|
300 |
if instance.disk_template != constants.DT_DISKLESS: |
|
301 |
all_lvs = instance.MapLVsByNode() |
|
302 |
logger.Info("Instance '%s' DISK_LAYOUT: %s" % (instance.name, all_lvs)) |
|
302 | 303 |
|
303 | 304 |
self._OpenConfig() |
304 | 305 |
self._config_data.instances[instance.name] = instance |
... | ... | |
624 | 625 |
self._ReleaseLock() |
625 | 626 |
|
626 | 627 |
return self._config_data.cluster |
628 |
|
|
629 |
def Update(self, target): |
|
630 |
"""Notify function to be called after updates. |
|
631 |
|
|
632 |
This function must be called when an object (as returned by |
|
633 |
GetInstanceInfo, GetNodeInfo, GetCluster) has been updated and the |
|
634 |
caller wants the modifications saved to the backing store. Note |
|
635 |
that all modified objects will be saved, but the target argument |
|
636 |
is the one the caller wants to ensure that it's saved. |
|
637 |
|
|
638 |
""" |
|
639 |
if self._config_data is None: |
|
640 |
raise errors.ProgrammerError, ("Configuration file not read," |
|
641 |
" cannot save.") |
|
642 |
if isinstance(target, objects.Cluster): |
|
643 |
test = target == self._config_data.cluster |
|
644 |
elif isinstance(target, objects.Node): |
|
645 |
test = target in self._config_data.nodes.values() |
|
646 |
elif isinstance(target, objects.Instance): |
|
647 |
test = target in self._config_data.instances.values() |
|
648 |
else: |
|
649 |
raise errors.ProgrammerError, ("Invalid object type (%s) passed to" |
|
650 |
" ConfigWriter.Update" % type(target)) |
|
651 |
if not test: |
|
652 |
raise errors.ConfigurationError, ("Configuration updated since object" |
|
653 |
" has been read or unknown object") |
|
654 |
self._WriteConfig() |
Also available in: Unified diff