| 342 | return data, "" |
| 343 | |
| 344 | def create_php_site(self, site_name: str, port: int, **kwargs) -> Tuple[Optional[int], str]: |
| 345 | path = "/www/wwwroot/{}".format(site_name) |
| 346 | if port not in (80, 443): |
| 347 | path = "/www/wwwroot/{}_{}".format(site_name, port) |
| 348 | webname = { |
| 349 | "domain": site_name if port in (80, 443) else "{}:{}".format(site_name, port), |
| 350 | "domainlist": [], |
| 351 | "count": 0 |
| 352 | } |
| 353 | data, err = self._request("/site", "AddSite", pdata={ |
| 354 | "path": path, |
| 355 | "ftp": "false", |
| 356 | "type": "PHP", |
| 357 | "type_id": "0", |
| 358 | "ps": "{}【负载均衡节点】".format(site_name), |
| 359 | "port": str(port), |
| 360 | "version": "00", |
| 361 | "sql": "false", |
| 362 | "webname": json.dumps(webname) |
| 363 | }) |
| 364 | |
| 365 | if err: |
| 366 | return None, err |
| 367 | if not isinstance(data, dict): |
| 368 | return None, "数据格式错误" |
| 369 | |
| 370 | if isinstance(data, dict) and "msg" in data and not data.get("status", True): |
| 371 | return None, data["msg"] |
| 372 | |
| 373 | site_id = data.get("siteId", None) |
| 374 | if not isinstance(site_id, int): |
| 375 | return None, "数据解析错误" |
| 376 | return site_id, "" |
| 377 | |
| 378 | def set_firewall_open(self, port: int, protocol: str = "tcp") -> Tuple[bool, str]: |
| 379 | data, err = self._request("/firewall/com/set_port_rule", "", pdata={ |