Revision e3fd65a4 lib/config.py

b/lib/config.py
335 335
    """
336 336
    nobj = self._UnlockedGetNetwork(net_uuid)
337 337
    pool = network.AddressPool(nobj)
338
    if action == 'reserve':
338
    if action == constants.RESERVE_ACTION:
339 339
      pool.Reserve(address)
340
    elif action == 'release':
340
    elif action == constants.RELEASE_ACTION:
341 341
      pool.Release(address)
342 342

  
343 343
  def _UnlockedReleaseIp(self, net_uuid, address, ec_id):
......
347 347
    as reserved.
348 348

  
349 349
    """
350
    nobj = self._UnlockedGetNetwork(net_uuid)
351
    pool = network.AddressPool(nobj)
352
    self._temporary_ips.Reserve(ec_id, ('release', address, net_uuid))
350
    self._temporary_ips.Reserve(ec_id,
351
                                (constants.RELEASE_ACTION, address, net_uuid))
353 352

  
354 353
  @locking.ssynchronized(_config_lock, shared=1)
355 354
  def ReleaseIp(self, network, address, ec_id):
......
377 376
        ip = gen_free()
378 377
      except StopIteration:
379 378
        raise errors.ReservationError("Cannot generate IP. Network is full")
380
      return ("reserve", ip, net_uuid)
379
      return (constants.RESERVE_ACTION, ip, net_uuid)
381 380

  
382 381
    _ ,address, _ = self._temporary_ips.Generate([], gen_one, ec_id)
383 382
    return address
......
395 394
    if isreserved:
396 395
      raise errors.ReservationError("IP address already in use")
397 396

  
398
    return self._temporary_ips.Reserve(ec_id, ('reserve', address, net_uuid))
397
    return self._temporary_ips.Reserve(ec_id,
398
                                       (constants.RESERVE_ACTION,
399
                                        address, net_uuid))
399 400

  
400 401

  
401 402
  @locking.ssynchronized(_config_lock, shared=1)
......
1449 1450
        net_uuid = self._UnlockedLookupNetwork(nic.network)
1450 1451
        if net_uuid:
1451 1452
          # Return all IP addresses to the respective address pools
1452
          self._UnlockedCommitIp('release', net_uuid, nic.ip)
1453
          self._UnlockedCommitIp(constants.RELEASE_ACTION, net_uuid, nic.ip)
1453 1454

  
1454 1455

  
1455 1456
    del self._config_data.instances[instance_name]

Also available in: Unified diff