Example #1
0
def main(options, _args):
    if not options('general.list'):
        cluster = listClusters(options('general.host'),
                               {'cluster_name': options('general.cluster')})[0]

        print '\t'.join(['STATE', cluster['state']])
        print '\t'.join(['START_TASK', cluster['start_task']]) 
        print '\t'.join(['MASTER'] + instanceToList(cluster['master']))
        for e in cluster['exec_nodes']:
            print '\t'.join(['EXEC'] + instanceToList(e))
        for e in cluster['data_nodes']:
            print '\t'.join(['DATA'] + instanceToList(e))

        print '\t'.join(['GANGLIA',
                         'http://%s/ganglia' % returnEmptyDictIfNone(cluster, 'master'
                                                                     ).get('public_dns', '')])
        print '\t'.join(['ERGATIS',
                         'http://%s/ergatis' % returnEmptyDictIfNone(cluster, 'master'
                                                                     ).get('public_dns', '')])
        print '\t'.join(['SSH',
                         'ssh %s %s@%s' % (cluster.get('config', {}).get('ssh.options', ''),
                                           cluster.get('config', {}).get('ssh.user', ''),
                                           returnEmptyDictIfNone(cluster, 'master'
                                                                 ).get('public_dns', ''))])

    else:
        for c in listClusters(options('general.host')):
            print '\t'.join(['CLUSTER', c['cluster_name'], c['state']])
Example #2
0
def listClustersSafe(host):
    """
    This tries to list the clusters, returns an empty list if listClusters fails at all
    such as networking being down
    """
    def annotateNameWithState(name, state):
        if state == 'unresponsive':
            return '>%s<' % name
        elif state == 'terminated':
            return '(%s)' % name
        elif state == 'failed':
            return '!%s!' % name
        elif state == 'pending':
            return '^%s^' % name
        else:
            return name
    try:
        clusters = cluster.listClusters(host)
        return [(annotateNameWithState(c['cluster_name'], c['state']),
                 len(c['exec_nodes'] + c['data_nodes']))
                for c in clusters]
    except Exception, err:
        print err
        return []
Example #3
0
def listClustersSafe(host):
    """
    This tries to list the clusters, returns an empty list if listClusters fails at all
    such as networking being down
    """
    def annotateNameWithState(name, state):
        if state == 'unresponsive':
            return '>%s<' % name
        elif state == 'terminated':
            return '(%s)' % name
        elif state == 'failed':
            return '!%s!' % name
        elif state == 'pending':
            return '^%s^' % name
        else:
            return name

    try:
        clusters = cluster.listClusters(host)
        return [(annotateNameWithState(c['cluster_name'], c['state']),
                 len(c['exec_nodes'] + c['data_nodes'])) for c in clusters]
    except Exception, err:
        print err
        return []