Revision d8aee57e lib/config.py
b/lib/config.py | ||
---|---|---|
125 | 125 |
class ConfigWriter: |
126 | 126 |
"""The interface to the cluster configuration. |
127 | 127 |
|
128 |
@ivar _temporary_lvs: reservation manager for temporary LVs |
|
129 |
@ivar _all_rms: a list of all temporary reservation managers |
|
130 |
|
|
128 | 131 |
""" |
129 | 132 |
def __init__(self, cfg_file=None, offline=False): |
130 | 133 |
self.write_count = 0 |
... | ... | |
139 | 142 |
self._temporary_drbds = {} |
140 | 143 |
self._temporary_macs = TemporaryReservationManager() |
141 | 144 |
self._temporary_secrets = TemporaryReservationManager() |
145 |
self._temporary_lvs = TemporaryReservationManager() |
|
146 |
self._all_rms = [self._temporary_ids, self._temporary_macs, |
|
147 |
self._temporary_secrets, self._temporary_lvs] |
|
142 | 148 |
# Note: in order to prevent errors when resolving our name in |
143 | 149 |
# _DistributeConfig, we compute it here once and reuse it; it's |
144 | 150 |
# better to raise an error before starting to modify the config |
... | ... | |
191 | 197 |
self._temporary_macs.Reserve(mac, ec_id) |
192 | 198 |
|
193 | 199 |
@locking.ssynchronized(_config_lock, shared=1) |
200 |
def ReserveLV(self, lv_name, ec_id): |
|
201 |
"""Reserve an VG/LV pair for an instance. |
|
202 |
|
|
203 |
@type lv_name: string |
|
204 |
@param lv_name: the logical volume name to reserve |
|
205 |
|
|
206 |
""" |
|
207 |
all_lvs = self._AllLVs() |
|
208 |
if lv_name in all_lvs: |
|
209 |
raise errors.ReservationError("LV already in use") |
|
210 |
else: |
|
211 |
self._temporary_lvs.Reserve(lv_name, ec_id) |
|
212 |
|
|
213 |
@locking.ssynchronized(_config_lock, shared=1) |
|
194 | 214 |
def GenerateDRBDSecret(self, ec_id): |
195 | 215 |
"""Generate a DRBD secret. |
196 | 216 |
|
... | ... | |
1451 | 1471 |
"""Drop per-execution-context reservations |
1452 | 1472 |
|
1453 | 1473 |
""" |
1454 |
self._temporary_ids.DropECReservations(ec_id) |
|
1455 |
self._temporary_macs.DropECReservations(ec_id) |
|
1456 |
self._temporary_secrets.DropECReservations(ec_id) |
|
1474 |
for rm in self._all_rms: |
|
1475 |
rm.DropECReservations(ec_id) |
Also available in: Unified diff