fix: 阿里云/腾讯云list_vps补分页(超100台实例不再漏同步)
This commit is contained in:
+10
-2
@@ -79,9 +79,13 @@ class AliyunAdapter(BaseAdapter):
|
|||||||
return {"ok": False, "message": str(e)}
|
return {"ok": False, "message": str(e)}
|
||||||
|
|
||||||
def list_vps(self) -> list:
|
def list_vps(self) -> list:
|
||||||
data = self._call("DescribeInstances", {"PageSize": "100"})
|
# 分页拉取:单次最多 100 条,按 TotalCount 翻页,避免实例超 100 台时漏同步
|
||||||
result = []
|
result = []
|
||||||
for inst in data.get("Instances", {}).get("Instance", []):
|
page = 1
|
||||||
|
while True:
|
||||||
|
data = self._call("DescribeInstances", {"PageSize": "100", "PageNumber": str(page)})
|
||||||
|
instances = data.get("Instances", {}).get("Instance", [])
|
||||||
|
for inst in instances:
|
||||||
public_ips = inst.get("PublicIpAddress", {}).get("IpAddress", [])
|
public_ips = inst.get("PublicIpAddress", {}).get("IpAddress", [])
|
||||||
eip = inst.get("EipAddress", {}).get("IpAddress")
|
eip = inst.get("EipAddress", {}).get("IpAddress")
|
||||||
mem_mb = inst.get("Memory") or 0
|
mem_mb = inst.get("Memory") or 0
|
||||||
@@ -100,4 +104,8 @@ class AliyunAdapter(BaseAdapter):
|
|||||||
raw=inst,
|
raw=inst,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
total = int(data.get("TotalCount") or 0)
|
||||||
|
if not instances or page * 100 >= total:
|
||||||
|
break
|
||||||
|
page += 1
|
||||||
return result
|
return result
|
||||||
|
|||||||
+10
-2
@@ -94,10 +94,14 @@ class TencentAdapter(BaseAdapter):
|
|||||||
return {"ok": False, "message": str(e)}
|
return {"ok": False, "message": str(e)}
|
||||||
|
|
||||||
def list_vps(self) -> list:
|
def list_vps(self) -> list:
|
||||||
data = self._call("DescribeInstances", {"Limit": 100})
|
# 分页拉取:单次最多 100 条,按 TotalCount 翻页,避免实例超 100 台时漏同步
|
||||||
result = []
|
result = []
|
||||||
status_map = {"RUNNING": "active", "STOPPED": "stopped"}
|
status_map = {"RUNNING": "active", "STOPPED": "stopped"}
|
||||||
for inst in data.get("InstanceSet", []):
|
offset = 0
|
||||||
|
while True:
|
||||||
|
data = self._call("DescribeInstances", {"Limit": 100, "Offset": offset})
|
||||||
|
inst_set = data.get("InstanceSet", [])
|
||||||
|
for inst in inst_set:
|
||||||
public_ips = inst.get("PublicIpAddresses", [])
|
public_ips = inst.get("PublicIpAddresses", [])
|
||||||
result.append(
|
result.append(
|
||||||
NormalizedVPS(
|
NormalizedVPS(
|
||||||
@@ -114,4 +118,8 @@ class TencentAdapter(BaseAdapter):
|
|||||||
raw=inst,
|
raw=inst,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
total = int(data.get("TotalCount") or 0)
|
||||||
|
offset += len(inst_set)
|
||||||
|
if not inst_set or offset >= total:
|
||||||
|
break
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user