Logo Search packages:      
Sourcecode: ganeti version File versions  Download package

def lib::config::ConfigWriter::_OpenConfig (   self  )  [private]

Read the config data from disk.

In case we already have configuration data and the config file has
the same mtime as when we read it, we skip the parsing of the
file, since de-serialisation could be slow.

Definition at line 460 of file config.py.

00460                        :
    """Read the config data from disk.

    In case we already have configuration data and the config file has
    the same mtime as when we read it, we skip the parsing of the
    file, since de-serialisation could be slow.

    """
    try:
      st = os.stat(self._cfg_file)
    except OSError, err:
      raise errors.ConfigurationError("Can't stat config file: %s" % err)
    if (self._config_data is not None and
        self._config_time is not None and
        self._config_time == st.st_mtime and
        self._config_size == st.st_size and
        self._config_inode == st.st_ino):
      # data is current, so skip loading of config file
      return
    f = open(self._cfg_file, 'r')
    try:
      try:
        data = objects.ConfigData.Load(f)
      except Exception, err:
        raise errors.ConfigurationError(err)
    finally:
      f.close()
    if (not hasattr(data, 'cluster') or
        not hasattr(data.cluster, 'config_version')):
      raise errors.ConfigurationError("Incomplete configuration"
                                      " (missing cluster.config_version)")
    if data.cluster.config_version != constants.CONFIG_VERSION:
      raise errors.ConfigurationError("Cluster configuration version"
                                      " mismatch, got %s instead of %s" %
                                      (data.cluster.config_version,
                                       constants.CONFIG_VERSION))
    self._config_data = data
    self._config_time = st.st_mtime
    self._config_size = st.st_size
    self._config_inode = st.st_ino

  def _ReleaseLock(self):


Generated by  Doxygen 1.6.0   Back to index