(get)
| 792 | |
| 793 | @staticmethod |
| 794 | def file_dstpath_check(get): |
| 795 | path = get.get("path/s", "") |
| 796 | node_ids = list_args(get, "node_ids") |
| 797 | if not path or not node_ids: |
| 798 | return json_response(status=False, msg="参数错误") |
| 799 | |
| 800 | if path == "/": |
| 801 | return json_response(status=False, msg="不能上传到根目录") |
| 802 | |
| 803 | nodes_db = ServerNodeDB() |
| 804 | ret = [] |
| 805 | |
| 806 | def check_node(n_data:dict, t_srv: Union[ServerNode, LPanelNode, SSHApi]): |
| 807 | res = {"id": n_data["id"], "err": "", "remarks": n_data["remarks"]} |
| 808 | err = t_srv.upload_dir_check(path) |
| 809 | if err: |
| 810 | res["err"] = err |
| 811 | ret.append(res) |
| 812 | |
| 813 | th_list = [] |
| 814 | for i in node_ids: |
| 815 | n = nodes_db.get_node_by_id(i) |
| 816 | if not n: |
| 817 | ret.append({"id": i, "err": "节点不存在"}) |
| 818 | n["ssh_conf"] = json.loads(n["ssh_conf"]) |
| 819 | if n["app_key"] or n["api_key"]: |
| 820 | srv = ServerNode.new_by_data(n) |
| 821 | elif n["ssh_conf"]: |
| 822 | srv = SSHApi(**n["ssh_conf"]) |
| 823 | else: |
| 824 | ret.append({"id": i, "err": "节点配置错误"}) |
| 825 | continue |
| 826 | |
| 827 | th = threading.Thread(target=check_node, args=(n, srv)) |
| 828 | th.start() |
| 829 | th_list.append(th) |
| 830 | |
| 831 | for th in th_list: |
| 832 | th.join() |
| 833 | |
| 834 | return json_response(status=True, data=ret) |
| 835 | |
| 836 | @staticmethod |
| 837 | def create_flow_template(get): |
nothing calls this directly
no test coverage detected