def container_query(self, query, quiet=False): '''search for a specific container. This function would likely be similar to the above, but have different filter criteria from the user (based on the query) ''' results = self._list_containers() matches = [] for result in results: for key, val in result.metadata.items(): if query in val and result not in matches: matches.append(result) if not quiet: bot.info("[gs://%s] Found %s containers" % (self._bucket_name, len(matches))) for image in matches: size = round(image.size / (1024 * 1024.0)) bot.custom(prefix=image.name, color="CYAN") bot.custom(prefix='id: ', message=image.id) bot.custom(prefix='uri: ', message=image.metadata['uri']) bot.custom(prefix='updated:', message=image.updated) bot.custom(prefix='size: ', message=' %s MB' % (size)) bot.custom(prefix='md5: ', message=image.md5_hash) bot.newline() return matches
def container_query(self, query, quiet=False): """search for a specific container. This function would likely be similar to the above, but have different filter criteria from the user (based on the query) """ results = self._list_containers() matches = [] for result in results: for _, val in result.metadata.items(): if query in val and result not in matches: matches.append(result) elif query in result.name and result not in matches: matches.append(result) if not quiet: bot.info("[gs://%s] Found %s containers" % (self._bucket_name, len(matches))) for image in matches: size = round(image.size / (1024 * 1024.0)) bot.custom(prefix=image.name, color="CYAN") bot.custom(prefix="id: ", message=image.id) bot.custom(prefix="name: ", message=image.name) bot.custom(prefix="updated:", message=image.updated) bot.custom(prefix="size: ", message=" %s MB" % (size)) bot.custom(prefix="md5: ", message=image.md5_hash) if "public_url" in image.metadata: public_url = image.metadata["public_url"] bot.custom(prefix="url: ", message=public_url) bot.newline() return matches
def container_query(self, query, quiet=False): '''search for a specific container. This function is the same as the search all, but instead of showing all results, filters them down based on user criteria (the query) ''' results = self._list_containers() matches = [] for result in results: is_match = False if query in result['id']: is_match = True elif query in result['name']: is_match = True else: for key, val in result['properties'].items(): if query in val and is_match is False: is_match = True break if is_match is True: matches.append(result) if not quiet: bot.info("[drive://%s] Found %s containers" % (self._base, len(matches))) for image in matches: # If the image has properties, show to the user if 'properties' in image: image.update(image['properties']) bot.info(image['uri']) for key in sorted(image, key=len): val = image[key] if isinstance(val, str): bot.custom(prefix=key.ljust(10), message=val, color="CYAN") bot.newline() return matches
def list_builders(self, project=None, zone='us-west1-a'): '''list builders, or instances for the project. They should start with sregistry-builder Parameters ========== project: specify a project, will default to environment first zone: the zone to use, defaults to us-west1-a if environment not set ''' builders = [] instances = self._get_instances(project, zone) for instance in instances['items']: builders.append([instance['name'], instance['status']]) bot.info("[google-compute] Found %s instances" % (len(builders))) bot.table(builders) bot.newline()