Exemplo n.º 1
0
    def DeleteFiles(self):
        # nothing to do?
        if not self.default_files_var:
            return 1

        machines = self.config.var('MACHINES')

        defaults = self.config.var(self.default_files_var)

        # build a list of files from the defaults
        fileParamList = []
        for param in defaults.keys():
            var_path = (self.base_map_var, self.name, param)
            if self.config.has_var(
                    var_path) and self.config.var(var_path) != None:
                fileParamList.append(var_path)

        # get a list of config dirs
        dirList = self.GetDirList()

        success = 1

        # remove the files on all machines
        for fileParam in fileParamList:
            success = self.config.del_file_var_content(fileParam) and success

        # remove the directories on all machines
        if len(dirList) > 0:
            success = E.rmall(machines, string.join(dirList, " ")) and success

        return success
Exemplo n.º 2
0
  def DeleteFiles(self):
    # nothing to do?
    if not self.default_files_var:
      return 1

    machines = self.config.var('MACHINES')

    defaults = self.config.var(self.default_files_var)

    # build a list of files from the defaults
    fileParamList = []
    for param in defaults.keys():
      var_path = (self.base_map_var, self.name, param)
      if self.config.has_var(var_path) and self.config.var(var_path) != None:
        fileParamList.append(var_path)

    # get a list of config dirs
    dirList = self.GetDirList()

    success = 1

    # remove the files on all machines
    for fileParam in fileParamList:
      success = self.config.del_file_var_content(fileParam) and success

    # remove the directories on all machines
    if len(dirList) > 0:
      success = E.rmall(machines, string.join(dirList, " ")) and success

    return success
Exemplo n.º 3
0
  def sanitizeMap(self, partition_dir, apache_dir, click_dir):
    """Sanitize the map and remove unused directories due to abandoned
    collections. Note that this is a little bit expensive, so it should
    not be called liberally. collect_logs cron job is the only caller
    right now.
    Return true if this has made some changes in the map."""

    removed_dirs = {}
    for dirname in self.dirnames:
      partitioned_subdir = os.path.join(partition_dir, dirname)
      apache_subdir = os.path.join(apache_dir, dirname)
      click_subdir = os.path.join(click_dir, dirname)

      if os.path.exists(partitioned_subdir) and \
         not self.hasFileInSubdirs(partitioned_subdir):
        E.rmall([E.LOCALHOST], partitioned_subdir)

      if os.path.exists(apache_subdir) and \
         not self.hasFileInSubdirs(apache_subdir):
        E.rmall([E.LOCALHOST], apache_subdir)

      if os.path.exists(click_subdir) and \
         not self.hasFileInSubdirs(click_subdir):
        E.rmall([E.LOCALHOST], click_subdir)

      if not os.path.exists(apache_subdir) and \
         not os.path.exists(click_subdir) and \
         not os.path.exists(partitioned_subdir):
        removed_dirs[dirname] = 1
        logging.info("Remove directory: %s" % dirname)

    for coll in self.collection_dir_map.keys():
      dirlist = self.collection_dir_map[coll]
      for i in range(len(dirlist) - 1, -1, -1):
        if removed_dirs.has_key(dirlist[i]):
          del dirlist[i]
      if len(dirlist) == 0:
        del self.collection_dir_map[coll]
        logging.info("Remove collection: %s" % coll)

    if removed_dirs:
      self.changed = true
    return self.changed
Exemplo n.º 4
0
    def sanitizeMap(self, partition_dir, apache_dir, click_dir):
        """Sanitize the map and remove unused directories due to abandoned
    collections. Note that this is a little bit expensive, so it should
    not be called liberally. collect_logs cron job is the only caller
    right now.
    Return true if this has made some changes in the map."""

        removed_dirs = {}
        for dirname in self.dirnames:
            partitioned_subdir = os.path.join(partition_dir, dirname)
            apache_subdir = os.path.join(apache_dir, dirname)
            click_subdir = os.path.join(click_dir, dirname)

            if os.path.exists(partitioned_subdir) and \
               not self.hasFileInSubdirs(partitioned_subdir):
                E.rmall([E.LOCALHOST], partitioned_subdir)

            if os.path.exists(apache_subdir) and \
               not self.hasFileInSubdirs(apache_subdir):
                E.rmall([E.LOCALHOST], apache_subdir)

            if os.path.exists(click_subdir) and \
               not self.hasFileInSubdirs(click_subdir):
                E.rmall([E.LOCALHOST], click_subdir)

            if not os.path.exists(apache_subdir) and \
               not os.path.exists(click_subdir) and \
               not os.path.exists(partitioned_subdir):
                removed_dirs[dirname] = 1
                logging.info("Remove directory: %s" % dirname)

        for coll in self.collection_dir_map.keys():
            dirlist = self.collection_dir_map[coll]
            for i in range(len(dirlist) - 1, -1, -1):
                if removed_dirs.has_key(dirlist[i]):
                    del dirlist[i]
            if len(dirlist) == 0:
                del self.collection_dir_map[coll]
                logging.info("Remove collection: %s" % coll)

        if removed_dirs:
            self.changed = true
        return self.changed