forked from wangqifan/calc
19 lines
899 B
Python
19 lines
899 B
Python
|
|
# 服务包初始化文件
|
|||
|
|
from typing import Dict, Any
|
|||
|
|
from .aws.pricing import calculate_ec2_price
|
|||
|
|
from .azure.pricing import calculate_vm_price
|
|||
|
|
from .aliyun.pricing import calculate_ecs_price
|
|||
|
|
|
|||
|
|
async def calculate_price(platform: str, instance_type: str, region: str,
|
|||
|
|
operating_system: str = "Linux", disk_gb: int = 0) -> Dict[str, float]:
|
|||
|
|
"""
|
|||
|
|
统一的价格计算接口,根据不同平台调用不同的价格计算服务
|
|||
|
|
"""
|
|||
|
|
if platform == "aws":
|
|||
|
|
return await calculate_ec2_price(instance_type, region, operating_system, disk_gb)
|
|||
|
|
elif platform == "azure":
|
|||
|
|
return await calculate_vm_price(instance_type, region, operating_system, disk_gb)
|
|||
|
|
elif platform == "aliyun":
|
|||
|
|
return await calculate_ecs_price(instance_type, region, operating_system, disk_gb)
|
|||
|
|
else:
|
|||
|
|
raise ValueError(f"不支持的平台: {platform}")
|