def _get_cluster_id(self): cluster_id_file = os.path.join(FLAGS.state_path, 'cluster_id') if not os.path.exists(cluster_id_file): return None cid = utils.read_file_as_root(cluster_id_file) cid = cid.strip() self.cluster_id = cid return self.cluster_id
def get_cluster_id(self): """ Cache and return the cluster id. If the local copy is not yet set, read it from the cluster_id file, and then cache and return it, else just return the cached copy. :return: the cluster id found in /opt/stack/data/vsm/cluster_id. """ if not self._cluster_id: cluster_id_file = os.path.join(FLAGS.state_path, 'cluster_id') if os.path.exists(cluster_id_file): self._cluster_id = utils.read_file_as_root(cluster_id_file).strip() return self._cluster_id
def get_cluster_id(self): """ Cache and return the cluster id. If the local copy is not yet set, read it from the cluster_id file, and then cache and return it, else just return the cached copy. :return: the cluster id found in /opt/stack/data/vsm/cluster_id. """ if not self._cluster_id: cluster_id_file = os.path.join(FLAGS.state_path, 'cluster_id') if os.path.exists(cluster_id_file): self._cluster_id = utils.read_file_as_root( cluster_id_file).strip() return self._cluster_id
def index(self, req): """Return vsm-controller's info and configures.""" try: self._get_keyring_admin_from_db() if self._have_write_cluter_into_db == False: self._store_cluster_info_to_db() except: LOG.error('Write DB error occurs in agents.index()') if req.environ['vsm.context']: LOG.info('context is not None') self._cluster_info['etc_hosts'] = \ utils.read_file_as_root(FLAGS.etc_hosts) storage_group, storage_class = self._get_storage_group_and_class_list() self._cluster_info['storage_class'] = storage_class self._cluster_info['storage_group'] = storage_group return self._cluster_info
def index(self, req): """Return vsm-controller's info and configures.""" try: self._get_keyring_admin_from_db() if self._have_write_cluter_into_db == False: self._store_cluster_info_to_db() except: LOG.error('Write DB error occurs in agents.index()') if req.environ['vsm.context']: LOG.info('context is not None') self._cluster_info['etc_hosts'] = \ utils.read_file_as_root(FLAGS.etc_hosts) storage_group , storage_class = self._get_storage_group_and_class_list() self._cluster_info['storage_class'] = storage_class self._cluster_info['storage_group'] = storage_group return self._cluster_info
def __init__(self, fp, sync): """ Read the file into a memory buffer. If sync is True, also read the file's meta data. If the file doesn't exist just return an empty string for the file contents, but don't throw an exception. :param fp: the file path to read from. File content is stripped as it's read in so that md5 check sums for empty files will match that of empty content from the database. :param sync: if true, read the file last write timestamp and generate an md5 checksum on the data. """ ConfigInfo.__init__(self) try: self._content = utils.read_file_as_root(fp).strip() if sync: statbuf = os.stat(fp) self._luts = int(statbuf.st_mtime) self._md5sum = hashlib.md5(self._content).hexdigest() except (exception.FileNotFound, os.error): pass