Example #1
0
 def _load_metadata_file(self, path, force_reload, overwrite=True):
     reloaded, data = fileutils.read_cached_file(path,
                                                 force_reload=force_reload)
     if reloaded or not self.current_adapter.is_loaded() or not overwrite:
         if data == None or data == "":
             LOG.info("Empty metadata file: %(path)s", {'path': path})
             return False
         json_metadata = jsonutils.loads(data)
         LOG.info("Reloaded metadata file: %(path)s", {'path': path})
         if json_metadata == None or not json_metadata.has_key(
                 'current-policy'):
             return False
         if not json_metadata.has_key(json_metadata['current-policy']):
             return False
         self.current_policy['name'] = json_metadata.get(
             'current-policy', None)
         if self.current_policy['name'] == None:
             return False
         self.current_policy = json_metadata[
             json_metadata['current-policy']]
         if self.current_policy['type'] == None:
             return False
     else:
         LOG.info("No need to reload metadata file: %(path)s",
                  {'path': path})
     return True
Example #2
0
 def _load_policy_file(self, path, force_reload, overwrite=True):
     reloaded, data = fileutils.read_cached_file(
         path, force_reload=force_reload)
     if reloaded or not self.is_loaded() or not overwrite:
         # Edited by Yang Luo.
         self.set_policy(data, None, overwrite=overwrite, use_conf=True)
         LOG.info("Reloaded policy file: %(path)s", {'path': path})
     else:
         LOG.info("No need to reload policy file: %(path)s", {'path': path})
Example #3
0
 def _load_policy_file(self, path, force_reload, overwrite=True):
     reloaded, data = fileutils.read_cached_file(path,
                                                 force_reload=force_reload)
     if reloaded or not self.is_loaded() or not overwrite:
         # Edited by Yang Luo.
         self.set_policy(data, None, overwrite=overwrite, use_conf=True)
         LOG.info("Reloaded policy file: %(path)s", {'path': path})
     else:
         LOG.info("No need to reload policy file: %(path)s", {'path': path})
Example #4
0
    def _cell_data_sync(self, force=False):
        """Update cell status for all cells from the backing data store
        when necessary.

        :param force: If True, cell status will be updated regardless
                      of whether it's time to do so.
        """
        reloaded, data = fileutils.read_cached_file(self.cells_config_path,
                                                    force_reload=force)

        if reloaded:
            LOG.debug("Updating cell cache from config file.")
            self.cells_config_data = jsonutils.loads(data)
            self._refresh_cells_from_dict(self.cells_config_data)

        if force or self._time_to_sync():
            self.last_cell_db_check = timeutils.utcnow()
            self._update_our_capacity()
Example #5
0
    def _cell_data_sync(self, force=False):
        """Update cell status for all cells from the backing data store
        when necessary.

        :param force: If True, cell status will be updated regardless
                      of whether it's time to do so.
        """
        reloaded, data = fileutils.read_cached_file(self.cells_config_path,
                                                    force_reload=force)

        if reloaded:
            LOG.debug("Updating cell cache from config file.")
            self.cells_config_data = jsonutils.loads(data)
            self._refresh_cells_from_dict(self.cells_config_data)

        if force or self._time_to_sync():
            self.last_cell_db_check = timeutils.utcnow()
            self._update_our_capacity()
Example #6
0
 def _load_metadata_file(self, path, force_reload, overwrite=True):
     reloaded, data = fileutils.read_cached_file(
         path, force_reload=force_reload)
     if reloaded or not self.current_adapter.is_loaded() or not overwrite:
         if data == None or data == "":
             LOG.info("Empty metadata file: %(path)s", {'path': path})
             return False
         json_metadata = jsonutils.loads(data)
         LOG.info("Reloaded metadata file: %(path)s", {'path': path})
         if json_metadata == None or not json_metadata.has_key('current-policy'):
             return False
         if not json_metadata.has_key(json_metadata['current-policy']):
             return False
         self.current_policy['name'] = json_metadata.get('current-policy', None)
         if self.current_policy['name'] == None:
             return False
         self.current_policy = json_metadata[json_metadata['current-policy']]
         if self.current_policy['type'] == None:
             return False
     else:
         LOG.info("No need to reload metadata file: %(path)s", {'path': path})
     return True