def get_ring():
 ring_output = check_output([NODE_TOOL, 'ring', KEYSPACE])
 ring = []
 index = 0
 for line in ring_output.splitlines():
  fields = line.split()
  if (len(fields) != 8):
   continue
  ring.append({'index': index, 'ip': fields[0], 'status': fields[2], 'state': fields[3], 'load': load_bytes(float(fields[4]), fields[5]), 'token': fields[7]})
  index += 1
 assert (len(ring) > 0)
 ideal_load = (sum((node['load'] for node in ring)) / len(ring))
 for (index, node) in enumerate(ring):
  try:
   node['skew'] = (abs((node['load'] - ideal_load)) / ideal_load)
  except ZeroDivisionError:
   node['skew'] = 0
  node['diff'] = abs((node['load'] - ring[(index - 1)]['load']))
 return ring

def get_ring ( ) : ring_output = check_output ( [ NODE_TOOL , 'ring' , KEYSPACE ] ) ring = [ ] index = 0 for line in ring_output . splitlines ( ) : fields = line . split ( ) if ( len ( fields ) != 8 ) : continue ring . append ( { 'index' : index , 'ip' : fields [ 0 ] , 'status' : fields [ 2 ] , 'state' : fields [ 3 ] , 'load' : load_bytes ( float ( fields [ 4 ] ) , fields [ 5 ] ) , 'token' : fields [ 7 ] } ) index += 1 assert ( len ( ring ) > 0 ) ideal_load = ( sum ( ( node [ 'load' ] for node in ring ) ) / len ( ring ) ) for ( index , node ) in enumerate ( ring ) : try : node [ 'skew' ] = ( abs ( ( node [ 'load' ] - ideal_load ) ) / ideal_load ) except ZeroDivisionError : node [ 'skew' ] = 0 node [ 'diff' ] = abs ( ( node [ 'load' ] - ring [ ( index - 1 ) ] [ 'load' ] ) ) return ring
return the ring status in a structured way .