Exemple #1
0
def main():
    compile_config()
    set_up_logging()
    v = handle_startup()
    if v is not None:
        if type(v) != bool:
            print(v)
        return
    else:
        client = InsightsClient()
        client.update_rules()
        tar = client.collect(check_timestamp=False,
                             image_id=(config["image_id"] or config["only"]),
                             tar_file=config["tar_file"],
                             mountpoint=config["mountpoint"])
        if not config['no_upload']:
            client.upload(tar)
        else:
            print('Archive saved to ' + tar)
Exemple #2
0
def collect_and_output():
    c = InsightsClient()
    tar_file = c.collect(analyze_image_id=config["analyze_image_id"],
                         analyze_file=config["analyze_file"],
                         analyze_mountpoint=config["analyze_mountpoint"])
    if not tar_file:
        sys.exit(constants.sig_kill_bad)
    if config['to_stdout']:
        with open(tar_file, 'rb') as tar_content:
            shutil.copyfileobj(tar_content, sys.stdout)
    else:
        resp = None
        if not config['no_upload']:
            resp = c.upload(tar_file)
        else:
            logger.info('Archive saved at %s', tar_file)
        if resp and config["to_json"]:
            print(json.dumps(resp))
    sys.exit()