def list_queued(options, args): """%(prog)s list-queued [options] List all images currently queued for caching. """ client = get_client(options) images = client.get_queued_images() if not images: print("No queued images.") return SUCCESS print("Found %d queued images..." % len(images)) pretty_table = utils.PrettyTable() pretty_table.add_column(36, label="ID") print(pretty_table.make_header()) for image in images: print(pretty_table.make_row(image))
def list_cached(options, args): """%(prog)s list-cached [options] List all images currently cached. """ client = get_client(options) images = client.get_cached_images() if not images: print("No cached images.") return SUCCESS print("Found %d cached images..." % len(images)) pretty_table = utils.PrettyTable() pretty_table.add_column(36, label="ID") pretty_table.add_column(19, label="Last Accessed (UTC)") pretty_table.add_column(19, label="Last Modified (UTC)") # 1 TB takes 13 characters to display: len(str(2**40)) == 13 pretty_table.add_column(14, label="Size", just="r") pretty_table.add_column(10, label="Hits", just="r") print(pretty_table.make_header()) for image in images: last_modified = image['last_modified'] last_modified = timeutils.iso8601_from_timestamp(last_modified) last_accessed = image['last_accessed'] if last_accessed == 0: last_accessed = "N/A" else: last_accessed = timeutils.iso8601_from_timestamp(last_accessed) print(pretty_table.make_row( image['image_id'], last_accessed, last_modified, image['size'], image['hits']))