Revision 1b209a17 lib/config.py
b/lib/config.py | ||
---|---|---|
340 | 340 |
""" |
341 | 341 |
nobj = self._UnlockedGetNetwork(net_uuid) |
342 | 342 |
pool = network.AddressPool(nobj) |
343 |
if action == 'reserve':
|
|
343 |
if action == constants.RESERVE_ACTION:
|
|
344 | 344 |
pool.Reserve(address) |
345 |
elif action == 'release':
|
|
345 |
elif action == constants.RELEASE_ACTION:
|
|
346 | 346 |
pool.Release(address) |
347 | 347 |
|
348 | 348 |
def _UnlockedReleaseIp(self, net_uuid, address, ec_id): |
... | ... | |
352 | 352 |
as reserved. |
353 | 353 |
|
354 | 354 |
""" |
355 |
self._temporary_ips.Reserve(ec_id, ('release', address, net_uuid)) |
|
355 |
self._temporary_ips.Reserve(ec_id, |
|
356 |
(constants.RELEASE_ACTION, address, net_uuid)) |
|
356 | 357 |
|
357 | 358 |
@locking.ssynchronized(_config_lock, shared=1) |
358 | 359 |
def ReleaseIp(self, net, address, ec_id): |
... | ... | |
380 | 381 |
ip = gen_free() |
381 | 382 |
except StopIteration: |
382 | 383 |
raise errors.ReservationError("Cannot generate IP. Network is full") |
383 |
return ("reserve", ip, net_uuid)
|
|
384 |
return (constants.RESERVE_ACTION, ip, net_uuid)
|
|
384 | 385 |
|
385 | 386 |
_, address, _ = self._temporary_ips.Generate([], gen_one, ec_id) |
386 | 387 |
return address |
... | ... | |
398 | 399 |
if isreserved: |
399 | 400 |
raise errors.ReservationError("IP address already in use") |
400 | 401 |
|
401 |
return self._temporary_ips.Reserve(ec_id, ('reserve', address, net_uuid)) |
|
402 |
return self._temporary_ips.Reserve(ec_id, |
|
403 |
(constants.RESERVE_ACTION, |
|
404 |
address, net_uuid)) |
|
402 | 405 |
|
403 | 406 |
@locking.ssynchronized(_config_lock, shared=1) |
404 | 407 |
def ReserveIp(self, net, address, ec_id): |
... | ... | |
1450 | 1453 |
net_uuid = self._UnlockedLookupNetwork(nic.network) |
1451 | 1454 |
if net_uuid: |
1452 | 1455 |
# Return all IP addresses to the respective address pools |
1453 |
self._UnlockedCommitIp('release', net_uuid, nic.ip)
|
|
1456 |
self._UnlockedCommitIp(constants.RELEASE_ACTION, net_uuid, nic.ip)
|
|
1454 | 1457 |
|
1455 | 1458 |
del self._config_data.instances[instance_name] |
1456 | 1459 |
self._config_data.cluster.serial_no += 1 |
Also available in: Unified diff