def list_ami_branch(region, version): add_file_logger() def get_tags(ami): return {i['Key']: i['Value'] for i in ami.tags} if ":" not in version: version += ":all" amis = get_branched_ami(version, region_name=region) tbl = PrettyTable( ["Name", "ImageId", "CreationDate", "BuildId", "Test Status"]) tbl.align = "l" for ami in amis: tags = get_tags(ami) test_status = [(k, v) for k, v in tags.items() if k.startswith('JOB:')] test_status = [click.style(k, fg='green') for k, v in test_status if v == 'PASSED'] + \ [click.style(k, fg='red') for k, v in test_status if not v == 'PASSED'] test_status = ", ".join(test_status) if test_status else click.style( 'Unknown', fg='yellow') tbl.add_row([ ami.name, ami.id, ami.creation_date, tags['build-id'], test_status ]) click.echo(tbl.get_string(title="Scylla AMI branch versions"))
def list_ami_branch(region, version): def get_tags(ami): return {i['Key']: i['Value'] for i in ami.tags} amis = get_branched_ami(version, region_name=region) x = PrettyTable(["Name", "ImageId", "CreationDate", "BuildId"]) x.align = "l" for ami in amis: x.add_row( [ami.name, ami.id, ami.creation_date, get_tags(ami)['build-id']]) click.echo(x.get_string(title="Scylla AMI branch versions"))