(zk_cluster, zk_root_path, ns_conf, teardown)
| 172 | |
| 173 | |
| 174 | def DeployNameserver(zk_cluster, zk_root_path, ns_conf, teardown): |
| 175 | source_file = ns_conf["package"] |
| 176 | file_name = os.path.basename(source_file) |
| 177 | version = file_name.split("-")[-1][:-7] |
| 178 | for item in ns_conf["address_arr"]: |
| 179 | real_path = '' |
| 180 | if "path" in item: |
| 181 | real_path = item["path"] |
| 182 | else: |
| 183 | real_path = ns_conf["path"] |
| 184 | host = item["address"].split(":")[0] |
| 185 | (prefix, suffix, is_local) = GetPrefixAndSuffix(host) |
| 186 | work_path = real_path + "/fedb-nameserver-" + version |
| 187 | cmd_arr = [] |
| 188 | if teardown: |
| 189 | print("teardown nameserver on {}. path: {}".format(host, real_path)) |
| 190 | cmd_arr.append("{} cd {}; sh bin/start_ns.sh stop {}".format(prefix, work_path, suffix)) |
| 191 | cmd_arr.append("{} cd {}; rm {}; rm -rf {} {}".format(prefix, real_path, file_name, "fedb-nameserver-*", suffix)) |
| 192 | else: |
| 193 | print("start nameserver on {}. path: {}".format(host, real_path)) |
| 194 | cmd_arr.append("{} mkdir -p {} {}".format(prefix, real_path, suffix)) |
| 195 | if is_local: |
| 196 | cmd_arr.append("cp {} {}".format(source_file, real_path)) |
| 197 | else: |
| 198 | cmd_arr.append("scp {} {}:{}".format(source_file, host, real_path)) |
| 199 | cmd_arr.append("{} cd {}; tar -zxvf {}; mv {} fedb-nameserver-{} {}".format(prefix, real_path, file_name, file_name[:-7], version, suffix)) |
| 200 | cmd_arr.append("{} cd {}; sed -i 's/--endpoint=.*/--endpoint={}/g' conf/nameserver.flags;" |
| 201 | "sed -i 's/--zk_cluster=.*/--zk_cluster={}/g' conf/nameserver.flags;" |
| 202 | "sed -i 's/--zk_root_path=.*/--zk_root_path={}/g' conf/nameserver.flags {}".format( |
| 203 | prefix, work_path, item["address"], zk_cluster, zk_root_path.replace("/", "\/"), suffix)) |
| 204 | cmd_arr.append("{} cd {}; sh bin/start_ns.sh start {}".format(prefix, work_path, suffix)) |
| 205 | for cmd in cmd_arr: |
| 206 | (returncode,output,errout) = RunWithRetunCode(cmd) |
| 207 | if returncode != 0: |
| 208 | print("execute cmd[{}] failed! error msg: {}".format(cmd, errout)) |
| 209 | return |
| 210 | print("execute cmd[{}] success".format(cmd)) |
| 211 | |
| 212 | def DeployTablet(zk_cluster, zk_root_path, tablet_conf, teardown): |
| 213 | source_file = tablet_conf["package"] |
no test coverage detected