135 lines
4.7 KiB
Plaintext
135 lines
4.7 KiB
Plaintext
async def get_zhipu_0112_product_detail(ns={}):
|
|
import random
|
|
import copy
|
|
ygpu_base = {
|
|
"device_id": "CZ-YGPU-80",
|
|
"internal_ip": "192.168.1.80",
|
|
"public_ip": "101.202.185.248",
|
|
"service_period": {
|
|
"start_date": "2025-10-01",
|
|
"end_date": "2025-12-31"
|
|
},
|
|
"hardware_config": {
|
|
"gpu": {
|
|
"model": "NVIDIA A100 80GB",
|
|
"memory": "80GB"
|
|
},
|
|
"cpu": "AMD EPYC 7763 64-core",
|
|
"ram": "256GB",
|
|
"storage": "2TB NVMe SSD"
|
|
},
|
|
"network_config": {
|
|
"bandwidth": "10Gbps"
|
|
},
|
|
"service_level": {
|
|
"sla": "99.9%",
|
|
"max_concurrent_connections": 100,
|
|
"max_load_threshold": "90%",
|
|
"billing_method": "monthly"
|
|
},
|
|
"historical_stats": {
|
|
"uptime_rate": "1",
|
|
"average_load": "1",
|
|
"peak_load": "1",
|
|
"total_usage_hours": 1
|
|
}
|
|
}
|
|
hgpu_base = {
|
|
"device_id": "CZ-HGPU-02",
|
|
"internal_ip": "192.168.2.80",
|
|
"public_ip": "101.202.185.248",
|
|
"service_period": {
|
|
"start_date": "2025-10-01",
|
|
"end_date": "2025-12-31"
|
|
},
|
|
"hardware_config": {
|
|
"gpu": {
|
|
"model": " NVIDIA RTX 4090 24GB",
|
|
"memory": "24GB"
|
|
},
|
|
"cpu": "Intel Xeon Platinum 8375C 32-core",
|
|
"ram": "128GB",
|
|
"storage": "1TB NVMe SSD"
|
|
},
|
|
"network_config": {
|
|
"bandwidth": "5Gbps"
|
|
},
|
|
"service_level": {
|
|
"sla": "99.5%",
|
|
"max_concurrent_connections": 50,
|
|
"max_load_threshold": "80%",
|
|
"billing_method": "monthly"
|
|
},
|
|
"historical_stats": {
|
|
"uptime_rate": "1",
|
|
"average_load": "1",
|
|
"peak_load": "1",
|
|
"total_usage_hours": 1
|
|
}
|
|
}
|
|
ygpu_list = []
|
|
for i in range(1, 97):
|
|
ygpu = copy.deepcopy(ygpu_base)
|
|
ygpu['device_id'] = f'CZ-YGPU-{i:02d}'
|
|
ygpu['internal_ip'] = f'192.168.1.{i}'
|
|
ygpu['public_ip'] = f'101.202.{i+100}.{i+123}'
|
|
ygpu['historical_stats']['uptime_rate'] = str(round(random.uniform(90, 99.99), 2)) + '%'
|
|
ygpu['historical_stats']['average_load'] = str(round(random.uniform(60, 80.9), 1)) + '%'
|
|
ygpu['historical_stats']['peak_load'] = str(round(random.uniform(80, 90.9), 1)) + '%'
|
|
ygpu['historical_stats']['total_usage_hours'] = random.randint(1900, 2100)
|
|
ygpu_list.append(ygpu)
|
|
hgpu_list = []
|
|
for i in range(1, 73):
|
|
hgpu = copy.deepcopy(hgpu_base)
|
|
uptime_rate = str(round(random.uniform(90, 99.99), 2)) + '%'
|
|
average_load = str(round(random.uniform(60, 80.9), 1)) + '%'
|
|
peak_load = str(round(random.uniform(80, 90.9), 1)) + '%'
|
|
total_usage_hours = random.randint(1900, 2100)
|
|
hgpu['device_id'] = f'CZ-HGPU-{i:02d}'
|
|
hgpu['internal_ip'] = f'192.168.2.{i}'
|
|
hgpu['public_ip'] = f'101.202.{i+100}.{i+123}'
|
|
hgpu['historical_stats']['uptime_rate'] = uptime_rate
|
|
hgpu['historical_stats']['average_load'] = average_load
|
|
hgpu['historical_stats']['peak_load'] = peak_load
|
|
hgpu['historical_stats']['total_usage_hours'] = total_usage_hours
|
|
hgpu_list.append(hgpu)
|
|
|
|
data = {
|
|
'status': True,
|
|
'msg': 'get product list success',
|
|
'data': {}
|
|
}
|
|
|
|
if ns.get('keyword') == 'ygpu':
|
|
if ns.get('server_id'):
|
|
count_ygpu = 0
|
|
for ygpu in ygpu_list:
|
|
if ygpu['device_id'] == ns.get('server_id'):
|
|
count_ygpu += 1
|
|
data['data'] = {"servers": [ygpu]}
|
|
return data
|
|
if count_ygpu == 0:
|
|
data['data'] = {"servers": []}
|
|
return {'status': False, 'msg': 'server_id not found', 'data': {"servers": []}}
|
|
data['data'] = {"servers": ygpu_list}
|
|
elif ns.get('keyword') == 'hgpu':
|
|
if ns.get('server_id'):
|
|
count_hgpu = 0
|
|
for hgpu in hgpu_list:
|
|
if hgpu['device_id'] == ns.get('server_id'):
|
|
count_hgpu += 1
|
|
data['data'] = {"servers": [hgpu]}
|
|
return data
|
|
if count_hgpu == 0:
|
|
data['data'] = {"servers": []}
|
|
return {'status': False, 'msg': 'server_id not found', 'data': {"servers": []}}
|
|
data['data'] = {"servers": hgpu_list}
|
|
else:
|
|
data['data'] = {
|
|
"ygpu_servers": ygpu_list,
|
|
"hgpu_servers": hgpu_list
|
|
}
|
|
return data
|
|
|
|
ret = await get_zhipu_0112_product_detail(params_kw)
|
|
return ret |