def _CloseConfig(self, save):
    if self._AddLockCount(-1) > 0:
      return # we still have the lock, do nothing
    if save:
      try:
        logging.debug("Writing configuration and unlocking it")
        self._WriteConfig(releaselock=True)
        logging.debug("Configuration write, unlock finished")
      except Exception, err:
        logging.critical("Can't write the configuration: %s", str(err))
        raise
    elif not self._offline and \
         not (self._lock_current_shared and not self._lock_forced):
      logging.debug("Unlocking configuration without writing")
      self._wconfd.UnlockConfig(self._GetWConfdContext())
      self._lock_forced = False

  # TODO: To WConfd
See ``IBlockDeviceAPI.create_volume``.
dataset/ETHPy150Open ganeti/ganeti/lib/config/__init__.py/ConfigWriter._CloseConfig--crossover with--dataset/ETHPy150Open ClusterHQ/flocker/flocker/node/agents/blockdevice.py/IBlockDeviceAsyncAPI.create_volume