Make CommitTemporaryIPs call out to WConfD
authorKlaus Aehlig <aehlig@google.com>
Thu, 8 Oct 2015 11:32:24 +0000 (13:32 +0200)
committerKlaus Aehlig <aehlig@google.com>
Mon, 12 Oct 2015 11:42:16 +0000 (13:42 +0200)
...instead of only doing changes locally. Doing changes
locally used to be fine---and even necessary---as long
as all calls to CommitTemporaryIPs used to be under
full configuration synchronisation.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Lisa Velden <velden@google.com>

lib/config/__init__.py

index 7b6187f..b1b4e97 100644 (file)
@@ -620,34 +620,8 @@ class ConfigWriter(object):
 
   @ConfigSync(shared=1)
   def CommitTemporaryIps(self, _ec_id):
-    """A simple wrapper around L{_UnlockedCommitTemporaryIps}"""
-    self._UnlockedCommitTemporaryIps(_ec_id)
-
-  def _UnlockedCommitTemporaryIps(self, _ec_id):
-    """Commit all reserved IP address to their respective pools
-
-    """
-    if self._offline:
-      raise errors.ProgrammerError("Can't call CommitTemporaryIps"
-                                   " in offline mode")
-    ips = self._wconfd.ListReservedIps(self._GetWConfdContext())
-    for action, address, net_uuid in ips:
-      self._UnlockedCommitIp(action, net_uuid, address)
-
-  def _UnlockedCommitIp(self, action, net_uuid, address):
-    """Commit a reserved IP address to an IP pool.
-
-    The IP address is taken from the network's IP pool and marked as free.
-
-    """
-    nobj = self._UnlockedGetNetwork(net_uuid)
-    if nobj is None:
-      raise errors.ProgrammerError("Network '%s' not found" % (net_uuid, ))
-    pool = network.AddressPool(nobj)
-    if action == constants.RESERVE_ACTION:
-      pool.Reserve(address)
-    elif action == constants.RELEASE_ACTION:
-      pool.Release(address)
+    """Tell WConfD to commit all temporary ids"""
+    self._wconfd.CommitTemporaryIps(self._GetWConfdContext())
 
   def ReleaseIp(self, net_uuid, address, _ec_id):
     """Give a specific IP address back to an IP pool.