Revision e81eef56 lib/config.py

b/lib/config.py
342 342
    """
343 343
    nobj = self._UnlockedGetNetwork(net_uuid)
344 344
    pool = network.AddressPool(nobj)
345
    if action == 'reserve':
345
    if action == constants.RESERVE_ACTION:
346 346
      pool.Reserve(address)
347
    elif action == 'release':
347
    elif action == constants.RELEASE_ACTION:
348 348
      pool.Release(address)
349 349

  
350 350
  def _UnlockedReleaseIp(self, net_uuid, address, ec_id):
......
354 354
    as reserved.
355 355

  
356 356
    """
357
    self._temporary_ips.Reserve(ec_id, ('release', address, net_uuid))
357
    self._temporary_ips.Reserve(ec_id,
358
                                (constants.RELEASE_ACTION, address, net_uuid))
358 359

  
359 360
  @locking.ssynchronized(_config_lock, shared=1)
360 361
  def ReleaseIp(self, net, address, ec_id):
......
382 383
        ip = gen_free()
383 384
      except StopIteration:
384 385
        raise errors.ReservationError("Cannot generate IP. Network is full")
385
      return ("reserve", ip, net_uuid)
386
      return (constants.RESERVE_ACTION, ip, net_uuid)
386 387

  
387 388
    _, address, _ = self._temporary_ips.Generate([], gen_one, ec_id)
388 389
    return address
......
400 401
    if isreserved:
401 402
      raise errors.ReservationError("IP address already in use")
402 403

  
403
    return self._temporary_ips.Reserve(ec_id, ('reserve', address, net_uuid))
404
    return self._temporary_ips.Reserve(ec_id,
405
                                       (constants.RESERVE_ACTION,
406
                                        address, net_uuid))
404 407

  
405 408
  @locking.ssynchronized(_config_lock, shared=1)
406 409
  def ReserveIp(self, net, address, ec_id):
......
1452 1455
        net_uuid = self._UnlockedLookupNetwork(nic.network)
1453 1456
        if net_uuid:
1454 1457
          # Return all IP addresses to the respective address pools
1455
          self._UnlockedCommitIp('release', net_uuid, nic.ip)
1458
          self._UnlockedCommitIp(constants.RELEASE_ACTION, net_uuid, nic.ip)
1456 1459

  
1457 1460
    del self._config_data.instances[instance_name]
1458 1461
    self._config_data.cluster.serial_no += 1

Also available in: Unified diff