'Prints a summary for each active cluster on EC2'

def list_clusters(self, cluster_groups=None, show_ssh_status=False):

    if (not cluster_groups):
        cluster_groups = self.get_cluster_security_groups()
        if (not cluster_groups):
            log.info('No    clusters    found...')
    else:
        try:
            cluster_groups = [self.get_cluster_security_group(g) for g in cluster_groups]
        except exception.SecurityGroupDoesNotExist:
            raise exception.ClusterDoesNotExist(g)
    for scg in cluster_groups:
        tag = self.get_tag_from_sg(scg.name)
        try:
            cl = self.get_cluster(tag, group=scg, load_plugins=False, load_volumes=False, require_keys=False)
        except exception.IncompatibleCluster as e:
            sep = ('*' * 60)
            log.error('\n'.join([sep, e.msg, sep]), extra=dict(__textwrap__=True))
            print
            continue
        header = ('%s    (security    group:    %s)' % (tag, scg.name))
        print ('-' * len(header))
        print header
        print ('-' * len(header))
        nodes = cl.nodes
        try:
            n = nodes[0]
        except IndexError:
            n = None
        state = getattr(n, 'state', None)
        ltime = 'N/A'
        uptime = 'N/A'
        if (state in ['pending', 'running']):
            ltime = getattr(n, 'local_launch_time', 'N/A')
            uptime = getattr(n, 'uptime', 'N/A')
        print ('Launch    time:    %s' % ltime)
        print ('Uptime:    %s' % uptime)
        if scg.vpc_id:
            print ('VPC:    %s' % scg.vpc_id)
            print ('Subnet:    %s' % getattr(n, 'subnet_id', 'N/A'))
        print ('Zone:    %s' % getattr(n, 'placement', 'N/A'))
        print ('Keypair:    %s' % getattr(n, 'key_name', 'N/A'))
        ebs_vols = []
        for node in nodes:
            devices = node.attached_vols
            if (not devices):
                continue
            node_id = (node.alias or node.id)
            for dev in devices:
                d = devices.get(dev)
                vol_id = d.volume_id
                status = d.status
                ebs_vols.append((vol_id, node_id, dev, status))
        if ebs_vols:
            print 'EBS    volumes:'
            for (vid, nid, dev, status) in ebs_vols:
                print ('                %s    on    %s:%s    (status:    %s)' % (vid, nid, dev, status))
        else:
            print 'EBS    volumes:    N/A'
        spot_reqs = cl.spot_requests
        if spot_reqs:
            active = len([s for s in spot_reqs if (s.state == 'active')])
            opn = len([s for s in spot_reqs if (s.state == 'open')])
            msg = ''
            if (active != 0):
                msg += ('%d    active' % active)
            if (opn != 0):
                if msg:
                    msg += ',    '
                msg += ('%d    open' % opn)
            print ('Spot    requests:    %s' % msg)
        if nodes:
            print 'Cluster    nodes:'
            for node in nodes:
                nodeline = ('                %7s    %s    %s    %s' % (node.alias, node.state, node.id, (node.addr or '')))
                if node.spot_id:
                    nodeline += ('    (spot    %s)' % node.spot_id)
                if show_ssh_status:
                    ssh_status = {True: 'Up', False: 'Down'}
                    nodeline += ('    (SSH:    %s)' % ssh_status[node.is_up()])
                print nodeline
            print ('Total    nodes:    %d' % len(nodes))
        else:
            print 'Cluster    nodes:    N/A'
        print
