Revision 76d5d3a3
b/lib/config.py | ||
---|---|---|
175 | 175 |
existing.update(self._AllLVs()) |
176 | 176 |
existing.update(self._config_data.instances.keys()) |
177 | 177 |
existing.update(self._config_data.nodes.keys()) |
178 |
existing.update([i.uuid for i in self._AllUUIDObjects() if i.uuid]) |
|
178 | 179 |
return existing |
179 | 180 |
|
180 | 181 |
@locking.ssynchronized(_config_lock, shared=1) |
... | ... | |
1057 | 1058 |
self._config_data.serial_no += 1 |
1058 | 1059 |
self._config_data.mtime = time.time() |
1059 | 1060 |
|
1061 |
def _AllUUIDObjects(self): |
|
1062 |
"""Returns all objects with uuid attributes. |
|
1063 |
|
|
1064 |
""" |
|
1065 |
return (self._config_data.instances.values() + |
|
1066 |
self._config_data.nodes.values() + |
|
1067 |
[self._config_data.cluster]) |
|
1068 |
|
|
1060 | 1069 |
def _OpenConfig(self): |
1061 | 1070 |
"""Read the config data from disk. |
1062 | 1071 |
|
... | ... | |
1084 | 1093 |
# ssconf update |
1085 | 1094 |
self._last_cluster_serial = -1 |
1086 | 1095 |
|
1096 |
# And finally run our (custom) config upgrade sequence |
|
1097 |
self._UpgradeConfig() |
|
1098 |
|
|
1099 |
def _UpgradeConfig(self): |
|
1100 |
"""Run upgrade steps that cannot be done purely in the objects. |
|
1101 |
|
|
1102 |
This is because some data elements need uniqueness across the |
|
1103 |
whole configuration, etc. |
|
1104 |
|
|
1105 |
@warning: this function will call L{_WriteConfig()}, so it needs |
|
1106 |
to either be called with the lock held or from a safe place |
|
1107 |
(the constructor) |
|
1108 |
|
|
1109 |
""" |
|
1110 |
modified = False |
|
1111 |
for item in self._AllUUIDObjects(): |
|
1112 |
if item.uuid is None: |
|
1113 |
item.uuid = self.GenerateUniqueID() |
|
1114 |
modified = True |
|
1115 |
if modified: |
|
1116 |
self._WriteConfig() |
|
1117 |
|
|
1087 | 1118 |
def _DistributeConfig(self): |
1088 | 1119 |
"""Distribute the configuration to the other nodes. |
1089 | 1120 |
|
Also available in: Unified diff