(self)
return [y for x,y in w]
Return information about the cassandra nodes.
Return information about the cassandra nodes.
Return information about the cassandra nodes .
def cassandra(self):
        """
        Return information about the cassandra nodes.
        """
        # Determine up/down status using a random node
        import random
        hosts = self._hosts['cassandra']
        for i in range(len(hosts)):
            h = random.choice(hosts)
            print "cassandra host = ", h
            v = self._hosts(h, "cd salvus/salvus&& . salvus-env&& nodetool status", wait=True, verbose=False, timeout=80)
            r = v[v.keys()[0]]
            status = {}
            for z in [x for x in r['stdout'].splitlines() if 'RAC' in x]:
                w = z.split()
                status[w[1]] = 'up' if w[0] == "UN" else 'down'
            if len(status) > 0:
                # keep trying until we at least get some output.
                break
        ans = []
        for k, v in self._hosts('cassandra', 'df -h /mnt/cassandra', wait=True, parallel=True, verbose=False, timeout=80).iteritems():
            if v.get('exit_status',1) or 'stdout' not in v:
                ans.append({'service':'cassandra', 'host':k[0], 'status':'down'})
            else:
                ans.append({'service':'cassandra', 'host':k[0], 'use%':int(v['stdout'].splitlines()[1].split()[4][:-1]), 'status':status.get(k[0],'down')})

        for d in ans:
            if d['status'] == 'down':
                self.attempt_to_heal_cassandra_server(d['host'])

        w = [((d['status'],d.get('use%','')), d) for d in ans]
        w.sort()
        return [y for x,y in w]
def cassandra ( self ) : # Determine up/down status using a random node import random hosts = self . _hosts [ 'cassandra' ] for i in range ( len ( hosts ) ) : h = random . choice ( hosts ) print "cassandra host = " , h v = self . _hosts ( h , "cd salvus/salvus&& . salvus-env&& nodetool status" , wait = True , verbose = False , timeout = 80 ) r = v [ v . keys ( ) [ 0 ] ] status = { } for z in [ x for x in r [ 'stdout' ] . splitlines ( ) if 'RAC' in x ] : w = z . split ( ) status [ w [ 1 ] ] = 'up' if w [ 0 ] == "UN" else 'down' if len ( status ) > 0 : # keep trying until we at least get some output. break ans = [ ] for k , v in self . _hosts ( 'cassandra' , 'df -h /mnt/cassandra' , wait = True , parallel = True , verbose = False , timeout = 80 ) . iteritems ( ) : if v . get ( 'exit_status' , 1 ) or 'stdout' not in v : ans . append ( { 'service' : 'cassandra' , 'host' : k [ 0 ] , 'status' : 'down' } ) else : ans . append ( { 'service' : 'cassandra' , 'host' : k [ 0 ] , 'use%' : int ( v [ 'stdout' ] . splitlines ( ) [ 1 ] . split ( ) [ 4 ] [ : - 1 ] ) , 'status' : status . get ( k [ 0 ] , 'down' ) } ) for d in ans : if d [ 'status' ] == 'down' : self . attempt_to_heal_cassandra_server ( d [ 'host' ] ) w = [ ( ( d [ 'status' ] , d . get ( 'use%' , '' ) ) , d ) for d in ans ] w . sort ( ) return [ y for x , y in w ]