#!/usr/bin/env python3
from util import *

node_list = ['18.217.165.238','3.133.124.205','18.216.188.108','3.135.187.123','3.15.218.204', '3.15.214.205', '18.188.110.226', '18.191.11.15']
node_list_len = len(node_list)
node_max = 8

generate_node_conf(node_list, node_list_len, node_list_len)

cmd_list = ['stopall','bin','initdb','gdata 10']
for item in cmd_list:
    cmd = './prepare.py %s' % item
    output('>' + item)
    exec_comand_system(cmd, True)

loop = 2
while loop <= node_max:
    output('>test in %s nodes' % loop)
    generate_node_conf(node_list, node_list_len, loop)
    loop += 1
    cmd_list = ['resetparent', 'runselect']
    for item in cmd_list:
        cmd = './prepare.py %s' % item
        output('>' + item)
        exec_comand_system(cmd, True)



cmd_list = ['gdata 2']
for item in cmd_list:
    cmd = './prepare.py %s' % item
    output('>' + item)
    exec_comand_system(cmd, True)

node_max = 5
loop = 2
while loop <= node_max:
    output('>test in %s nodes' % loop)
    generate_node_conf(node_list, node_list_len, loop)
    loop += 1
    cmd_list = ['resetparent', 'runselectall']
    for item in cmd_list:
        cmd = './prepare.py %s' % item
        output('>' + item)
        exec_comand_system(cmd, True)

cmd = './prepare.py stopall'
output('>stopall')
exec_comand_system(cmd, True)
output('FINISH')
