Esempio n. 1
0
    def take_action(self, parsed_args):
        client = get_client(parsed_args)

        marker = parsed_args.marker if parsed_args.marker else None
        limit = parsed_args.limit if parsed_args.limit else None

        kwargs = {'marker': marker, 'limit': limit}

        if parsed_args.tag:
            result = client.services.list_for_tag(parsed_args.tag, **kwargs)
        else:
            result = client.services.list(**kwargs)

        values = result['values']
        metadata = result['metadata']

        parsed_args.returned_metadata = metadata

        service_tuples = [(value['id'],
                          value['heartbeat_timeout'],
                          format_timestamp(value['last_seen']),
                          ', '.join(value['tags']),
                          format_metadata(value['metadata']))
                          for value in values]
        return (('Service ID', 'Heartbeat Timeout', 'Last Seen', 'Tags',
                 'Metadata'), service_tuples)
Esempio n. 2
0
 def take_action(self, parsed_args):
     client = get_client(parsed_args)
     value = client.services.get(parsed_args.object_id)
     metadata_str = format_metadata(value["metadata"])
     service_tuple = (
         value["id"],
         value["heartbeat_timeout"],
         value["last_seen"],
         ", ".join(value["tags"]),
         metadata_str,
     )
     return (("Service ID", "Heartbeat Timeout", "Last Seen", "Tags", "Metadata"), service_tuple)