def wait_for_quorum(keyname, db_nodes, replication):
 command = ((cassandra_interface.NODE_TOOL + ' ') + 'status')
 key_file = '{}/{}.key'.format(utils.KEY_DIRECTORY, keyname)
 ssh_cmd = ['ssh', '-i', key_file, appscale_info.get_db_master_ip(), command]
 if ((db_nodes < 1) or (replication < 1)):
  raise dbconstants.AppScaleDBError('At least 1 database machine is needed.')
 if (replication > db_nodes):
  raise dbconstants.AppScaleDBError('The replication factor cannot exceed the number of database machines.')
 can_fail = math.ceil(((replication / 2.0) - 1))
 needed = int((db_nodes - can_fail))
 while True:
  output = subprocess.check_output(ssh_cmd)
  nodes_ready = len([line for line in output.splitlines() if line.startswith('UN')])
  logging.info('{} nodes are up. {} are needed.'.format(nodes_ready, needed))
  if (nodes_ready >= needed):
   break
  time.sleep(1)

def wait_for_quorum ( keyname , db_nodes , replication ) : command = ( ( cassandra_interface . NODE_TOOL + ' ' ) + 'status' ) key_file = '{}/{}.key' . format ( utils . KEY_DIRECTORY , keyname ) ssh_cmd = [ 'ssh' , '-i' , key_file , appscale_info . get_db_master_ip ( ) , command ] if ( ( db_nodes < 1 ) or ( replication < 1 ) ) : raise dbconstants . AppScaleDBError ( 'At least 1 database machine is needed.' ) if ( replication > db_nodes ) : raise dbconstants . AppScaleDBError ( 'The replication factor cannot exceed the number of database machines.' ) can_fail = math . ceil ( ( ( replication / 2.0 ) - 1 ) ) needed = int ( ( db_nodes - can_fail ) ) while True : output = subprocess . check_output ( ssh_cmd ) nodes_ready = len ( [ line for line in output . splitlines ( ) if line . startswith ( 'UN' ) ] ) logging . info ( '{} nodes are up. {} are needed.' . format ( nodes_ready , needed ) ) if ( nodes_ready >= needed ) : break time . sleep ( 1 )
waits until enough cassandra nodes are up for a quorum .