def install_etcd(iplist='localhost', cluster_port=2380, client_port=2379, node_prefix='test', basedir='/usr/local/etcd/'): if iplist == 'localhost': remote_run = False cluster_port_list = [ cluster_port, cluster_port + 1000, cluster_port + 2000 ] client_port_list = [ client_port, client_port + 1000, client_port + 2000 ] local_ip = get_ip() iplist = [local_ip for _ in xrange(3)] else: remote_run = True iplist = iplist.split(';') cluster_port_list = [2380 for _ in xrange(len(iplist))] client_port_list = [2379 for _ in xrange(len(iplist))] cluster_member = ','.join([ "%s%s=http://%s:%s" % (node_prefix, i[0], i[1], i[2]) for i in zip(range(len(iplist)), iplist, cluster_port_list) ]) rst = {} for i in xrange(len(iplist)): args = " {node_prefix}{id} {node_ip} {cluster_port} {client_port} {cluster_member} {etcd_basedir}".format( node_prefix=node_prefix, id=i, node_ip=iplist[i], cluster_port=cluster_port_list[i], client_port=client_port_list[i], cluster_member=cluster_member, etcd_basedir=basedir) item_rst = execute_script(script="./etcd/deploy_etcd.sh", args=args, remote=remote_run, ip_list=[ iplist[i], ]) for k, v in item_rst.items(): if not v['stat']: rst[k] = v #check the etcd installing args = "%s %s" % (basedir, get_ip()) time.sleep(3) tmp_rst = execute_script(script='./etcd/check_etcd.sh', args=args)['localhost'] stat, chk_rst = tmp_rst['stat'], tmp_rst['rst'] #if not stat: # return False, rst return True, chk_rst
def install_mysql(install_type, base_dir): if install_type == 'yum': tmp_rst = execute_script( script="./mysql/deploy_mysql_yum.sh")['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] elif install_type == 'source': tmp_rst = execute_script(script="./mysql/deploy_mysql_source.sh", args=base_dir) stat, rst = tmp_rst['stat'], tmp_rst['rst'] else: stat, rst = False, 'Unkown install mysql type' return stat, rst
def patch_agent(): tseer_basedir = config_parse('tseer', 'base_dir', '/usr/local/') args = "%s" % (tseer_basedir) tmp_rst = execute_script(script='./patchagent.sh', args=args)['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] if not stat: print rst
def resolve_dependency(): print '[INFO] %s Starting resolve dependency...' % TIME_STAMP tmp_rst = execute_script( script='./cmake/resolve_dependency.sh')['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] print rst if not stat: sys.exit(1)
def local_install(): print "[INFO] %s Starting local install tseer..." % TIME_STAMP tseer_basedir = config_parse('tseer', 'base_dir', '/usr/local/') tmp_rst = execute_script(script='./cmake/local_install.sh', args=tseer_basedir)['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] if not stat: sys.exit(1)
def deploy_tars(): print '[INFO] %s Starting deploy tars...' % TIME_STAMP tmp_rst = execute_script(script='./cmake/deploy_tars.sh')['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] if not stat: sys.exit(1) else: print '[INFO] %s Deploy tars success!' % TIME_STAMP
def cmake_build(): print "[INFO] %s Starting build tseer..." % TIME_STAMP tseer_basedir = config_parse('tseer', 'base_dir', '/usr/local/') storage = config_parse('tseer', 'storage', 'etcd') cmake_cmd = '-DINSTALL_PATH=%s ' % tseer_basedir if storage == 'mysql': mysql_dir = config_parse('mysql', 'base_dir', '/usr/local/mysql') cmake_cmd += '-DUSE_MYSQL=ON -DMYSQL_DIR=%s' % mysql_dir tmp_rst = execute_script(script='./cmake/make_install.sh', args=cmake_cmd)['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] if not stat: sys.exit(1)
def change_sc_or_conf(): print "[INFO] %s Change conf..." % TIME_STAMP localip = get_ip() tseer_basedir = config_parse('tseer', 'base_dir', '/usr/local/') storage = config_parse('tseer', 'storage', 'etcd') etcd_host = config_parse('etcd', 'host_list', localip).split(',') etcd_client_port = config_parse('etcd', 'client_port', '2379') etcd_endpoint = ';'.join([i + ':' + etcd_client_port for i in etcd_host]) bind_ip = config_parse('tseer', 'bind_ip', localip) if bind_ip in ['localhost', '127.0.0.1']: bind_ip = get_ip() regport = config_parse('tseer_server', 'regport', '9902') queryport = config_parse('tseer_server', 'queryport', '9003') apiport = config_parse('tseer_server', 'apiport', '9904') args = "%s %s %s %s %s %s %s" % (tseer_basedir, bind_ip, storage, etcd_endpoint, regport, queryport, apiport) tmp_rst = execute_script(script='./cmake/change_conf.sh', args=args)['localhost'] stat, rst = tmp_rst['stat'], tmp_rst['rst'] if not stat: sys.exit(1)
def generate_utils(): tseer_basedir = config_parse("tseer", "base_dir", '/usr/local/') tmp_rst = execute_script(script='./cmake/generate_utils.sh', args=tseer_basedir) rst = tmp_rst['localhost']['rst']