def setUp(self): self.ip_parser = SoSIPParser(config={}) self.mac_parser = SoSMacParser(config={}) self.host_parser = SoSHostnameParser(config={}, opt_domains='foobar.com') self.kw_parser = SoSKeywordParser(config={}, keywords=['foobar']) self.kw_parser_none = SoSKeywordParser(config={}) self.kw_parser.generate_item_regexes()
def __init__(self, parser=None, args=None, cmdline=None, in_place=False, hook_commons=None): if not in_place: # we are running `sos clean` directly super(SoSCleaner, self).__init__(parser, args, cmdline) self.from_cmdline = True else: # we are being hooked by either SoSReport or SoSCollector, don't # re-init everything as that will cause issues, but instead load # the needed bits from the calling component self.opts = hook_commons['options'] self.tmpdir = hook_commons['tmpdir'] self.sys_tmp = hook_commons['sys_tmp'] self.policy = hook_commons['policy'] self.manifest = hook_commons['manifest'] self.from_cmdline = False if not hasattr(self.opts, 'jobs'): self.opts.jobs = 4 self.opts.archive_type = 'auto' self.soslog = logging.getLogger('sos') self.ui_log = logging.getLogger('sos_ui') # create the tmp subdir here to avoid a potential race condition # when obfuscating a SoSCollector run during archive extraction os.makedirs(os.path.join(self.tmpdir, 'cleaner'), exist_ok=True) self.cleaner_mapping = self.load_map_file() os.umask(0o77) self.in_place = in_place self.hash_name = self.policy.get_preferred_hash_name() self.cleaner_md = self.manifest.components.add_section('cleaner') self.parsers = [ SoSHostnameParser(self.cleaner_mapping, self.opts.domains), SoSIPParser(self.cleaner_mapping), SoSMacParser(self.cleaner_mapping), SoSKeywordParser(self.cleaner_mapping, self.opts.keywords, self.opts.keyword_file), SoSUsernameParser(self.cleaner_mapping, self.opts.usernames) ] self.archive_types = [ SoSReportDirectory, SoSReportArchive, SoSCollectorDirectory, SoSCollectorArchive, InsightsArchive, # make sure these two are always last as they are fallbacks DataDirArchive, TarballArchive ] self.nested_archive = None self.log_info("Cleaner initialized. From cmdline: %s" % self.from_cmdline)
def setUp(self): self.ip_parser = SoSIPParser() self.mac_parser = SoSMacParser() self.host_parser = SoSHostnameParser(opt_domains='foobar.com') self.kw_parser = SoSKeywordParser(keywords=['foobar']) self.kw_parser_none = SoSKeywordParser()