def init_cluster(config, vapp, template): from container_service_extension.config import get_data_file script = get_data_file('mstr-%s.sh' % template['name']) nodes = get_nodes(vapp, TYPE_MASTER) result = execute_script_in_nodes(config, vapp, template['admin_password'], script, nodes) if result[0][0] != 0: raise Exception('Couldn\'t initialize cluster:\n%s' % result[0][2].content.decode())
def join_cluster(config, vapp, template): from container_service_extension.config import get_data_file init_info = get_init_info(config, vapp, template['admin_password']) tmp_script = get_data_file('node-%s.sh' % template['name']) script = tmp_script.format(token=init_info[0], ip=init_info[1]) nodes = get_nodes(vapp, TYPE_NODE) results = execute_script_in_nodes(config, vapp, template['admin_password'], script, nodes) for result in results: if result[0] != 0: raise Exception( 'Couldn\'t join cluster:\n%s' % result[2].content.decode())
def join_cluster(config, vapp, template, target_nodes=None): from container_service_extension.config import get_data_file init_info = get_init_info(config, vapp, template['admin_password']) tmp_script = get_data_file('node-%s.sh' % template['name']) script = tmp_script.format(token=init_info[0], ip=init_info[1]) if target_nodes is None: nodes = get_nodes(vapp, TYPE_NODE) else: nodes = [] for node in vapp.get_all_vms(): if node.get('name') in target_nodes: nodes.append(node) results = execute_script_in_nodes(config, vapp, template['admin_password'], script, nodes) for result in results: if result[0] != 0: raise Exception( 'Couldn\'t join cluster:\n%s' % result[2].content.decode())