示例#1
0
def show_events(test_id: str, follow: bool = False, last_n: int = None, save_to: str = None):
    logging.getLogger("paramiko").setLevel(logging.CRITICAL)
    add_file_logger()
    builders = get_builder_by_test_id(test_id)

    if not builders:
        LOGGER.info(f"Builder was not found for provided test-id {test_id}")

    for builder in builders:
        LOGGER.info(
            f"Applying action for events.log on builder {builder['builder']['name']}:{builder['builder']['public_ip']}...")
        remoter = builder["builder"]["remoter"]

        if follow or last_n:
            options = "-f " if follow else ""
            options += f"-n {last_n} " if last_n else ""
            try:
                remoter.run(f"tail {options} {builder['path']}/events_log/events.log")
            except KeyboardInterrupt:
                LOGGER.info(f'Monitoring events.log for test-id {test_id} stopped!')
        elif save_to:
            remoter.receive_files(f"{builder['path']}/events_log/events.log", save_to)
            LOGGER.info(f"Events saved to {save_to}")
        else:
            remoter.run(f"cat {builder['path']}/events_log/events.log")
    click.echo("Show events done.")
示例#2
0
def search_builder(test_id):
    results = get_builder_by_test_id(test_id)
    tbl = PrettyTable(['Builder Name', "Public IP", "path"])
    tbl.align = 'l'
    for result in results:
        tbl.add_row([result['builder']['name'], result['builder']['public_ip'], result['path']])

    click.echo(tbl.get_string(title='Found builders for Test-id: {}'.format(test_id)))
示例#3
0
def search_builder(test_id):
    logging.getLogger("paramiko").setLevel(logging.CRITICAL)
    add_file_logger()

    results = get_builder_by_test_id(test_id)
    tbl = PrettyTable(['Builder Name', "Public IP", "path"])
    tbl.align = 'l'
    for result in results:
        tbl.add_row([result['builder']['name'], result['builder']['public_ip'], result['path']])

    click.echo(tbl.get_string(title='Found builders for Test-id: {}'.format(test_id)))
示例#4
0
    def collect_logs(self, local_search_path=None):
        for ent in self.log_entities:
            ent.collect(None,
                        self.local_dir,
                        None,
                        local_search_path=local_search_path)
        if not os.listdir(self.local_dir):
            LOGGER.warning('No any local files')
            LOGGER.info('Searching on builders')
            builders = get_builder_by_test_id(self.test_id)

            for obj in builders:
                builder = CollectingNode(name=obj['builder']['name'],
                                         ssh_login_info={
                                             "hostname":
                                             obj['builder']['public_ip'],
                                             "user":
                                             obj['builder']['user'],
                                             "key_file":
                                             obj["builder"]['key_file']
                                         },
                                         instance=None,
                                         global_ip=obj['builder']['public_ip'])
                for ent in self.log_entities:
                    ent.collect_from_builder(builder, self.local_dir,
                                             obj["path"])

            if not os.listdir(self.local_dir):
                LOGGER.warning('Nothing found')
                return None

        final_archive = self.archive_dir_with_zip64(self.local_dir)

        s3_link = self.upload_logs(final_archive,
                                   "{0.test_id}/{0.current_run}".format(self))
        remove_files(self.local_dir)
        remove_files(final_archive)
        return s3_link