From a31ae8c6dd6ad80173727393a97b30af6eedfd09 Mon Sep 17 00:00:00 2001 From: wangqifan Date: Fri, 29 Aug 2025 18:09:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0AWS=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=98=A0=E5=B0=84=EF=BC=8C=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E6=9B=B4=E5=AE=8C=E6=95=B4=E7=9A=84=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=92=8C=E8=8B=B1=E6=96=87=E5=90=8D=E7=A7=B0=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=9C=A8=E5=AE=9E=E4=BE=8B=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=B8=AD=E6=B7=BB=E5=8A=A0gp2=E5=92=8Cgp3=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E4=BB=B7=E6=A0=BC=E7=9A=84=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apifox_spec.yaml | 217 +++++++++++++ backend/app/core/config.py | 410 +++++++++++++------------ backend/app/services/aws/pricing_v2.py | 6 +- 3 files changed, 432 insertions(+), 201 deletions(-) create mode 100644 backend/apifox_spec.yaml diff --git a/backend/apifox_spec.yaml b/backend/apifox_spec.yaml new file mode 100644 index 0000000..ee8b137 --- /dev/null +++ b/backend/apifox_spec.yaml @@ -0,0 +1,217 @@ +openapi: 3.0.0 +info: + title: 云计算价格计算器 API + description: 支持多云平台价格计算的服务。 + version: "1.0.0" +servers: + - url: /api + description: Main API server + +paths: + /regions: + get: + summary: 获取区域列表 + description: 获取指定平台的可用区域列表。 + parameters: + - name: platform + in: query + description: '云平台。支持的值: "aws", "azure", "aliyun"。' + required: false + schema: + type: string + default: "aws" + enum: ["aws", "azure", "aliyun"] + responses: + '200': + description: 成功响应 + content: + application/json: + schema: + type: array + items: + type: object + properties: + code: + type: string + example: "us-east-1" + name: + type: string + example: "US East (N. Virginia)" + '400': + description: 如果平台不受支持。 + + /instance-types: + get: + summary: 获取实例类型 + description: 获取指定平台的可用实例类型。 + parameters: + - name: platform + in: query + description: 云平台。 + required: false + schema: + type: string + default: "aws" + responses: + '200': + description: 成功响应,包含实例类型及其信息的字典。 + content: + application/json: + schema: + type: object + '400': + description: 如果平台不受支持。 + + /search-instances: + post: + summary: 搜索实例 + description: 搜索符合指定条件的实例类型。 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/InstanceSearchRequest' + responses: + '200': + description: 匹配的实例列表,按月度总价排序。 + content: + application/json: + schema: + type: array + items: + type: object + '400': + description: 如果缺少必需的参数。 + '500': + description: 内部服务器错误。 + + /search-instances-v2: + post: + summary: 搜索实例 V2 + description: 使用 MySQL 数据库搜索符合条件的 AWS 实例。 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/InstanceSearchRequestV2' + responses: + '200': + description: 匹配的实例列表。 + content: + application/json: + schema: + type: array + items: + type: object + '500': + description: 内部服务器错误。 + + /compare-prices: + post: + summary: 比较价格 + description: 比较多种实例配置的价格。 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PriceComparison' + responses: + '200': + description: 包含配置及其计算价格的列表。 + content: + application/json: + schema: + type: array + items: + type: object + '500': + description: 内部服务器错误。 + +components: + schemas: + InstanceSearchRequest: + type: object + properties: + cpu_cores: + type: integer + description: CPU 核心数 + memory_gb: + type: number + format: float + description: 内存 (GB) + disk_gb: + type: integer + description: 磁盘大小 (GB) + region: + type: string + description: 区域 + operating_system: + type: string + description: 操作系统 + default: "Linux" + platform: + type: string + description: 云平台 + default: "aws" + + InstanceSearchRequestV2: + type: object + properties: + cpu_cores: + type: integer + description: CPU 核心数 + memory_gb: + type: number + format: float + description: 内存 (GB) + disk_gb: + type: integer + description: 磁盘大小 (GB) + region: + type: string + description: 区域 + operating_system: + type: string + description: 操作系统 + default: "Linux" + + PriceComparison: + type: object + properties: + configurations: + type: array + items: + $ref: '#/components/schemas/PriceRequest' + description: 价格请求配置列表 + + PriceRequest: + type: object + required: + - instance_type + - region + - operating_system + - purchase_option + properties: + instance_type: + type: string + description: 实例类型 + region: + type: string + description: 区域 + operating_system: + type: string + description: 操作系统 + purchase_option: + type: string + description: 购买选项 + duration: + type: integer + description: 持续时间 + default: 1 + disk_gb: + type: integer + description: 磁盘大小 (GB) + default: 0 diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 4ad28d1..cb25e5d 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -30,210 +30,220 @@ AWS_PRICING_EBS = { # 区域中文名称映射 AWS_REGION_NAMES = { - "af-south-1": "非洲 (开普敦)", - "ap-northeast-1": "亚太地区 (东京)", - "ap-northeast-2": "亚太地区 (首尔)", - "ap-northeast-3": "亚太地区 (大阪)", - "ap-east-1": "亚太地区 (香港)", - "ap-south-1": "亚太地区 (孟买)", - "ap-south-2": "亚太地区 (海得拉巴)", - "ap-southeast-1": "亚太地区 (新加坡)", - "ap-southeast-2": "亚太地区 (悉尼)", - "ap-southeast-3": "亚太地区 (雅加达)", - "ap-southeast-4": "亚太地区 (墨尔本)", - "ap-southeast-5": "亚太地区 (马来西亚)", - "ap-southeast-7": "亚太地区 (泰国)", - "ca-central-1": "加拿大 (中部)", - "ca-west-1": "加拿大西部 (卡尔加里)", - "eu-central-1": "欧洲 (法兰克福)", - "eu-central-2": "欧洲 (苏黎世)", - "eu-north-1": "欧洲 (斯德哥尔摩)", - "eu-south-1": "欧洲 (米兰)", - "eu-south-2": "欧洲 (西班牙)", - "eu-west-1": "欧洲 (爱尔兰)", - "eu-west-2": "欧洲 (伦敦)", - "eu-west-3": "欧洲 (巴黎)", - "il-central-1": "以色列 (特拉维夫)", - "me-central-1": "中东 (阿联酋)", - "me-south-1": "中东 (巴林)", - "mx-central-1": "墨西哥 (中部)", - "sa-east-1": "南美洲 (圣保罗)", - "us-east-1": "美国东部 (弗吉尼亚北部)", - "us-east-2": "美国东部 (俄亥俄)", - "us-east-2-mci-1": "美国东部 (堪萨斯城)", - "us-gov-east-1": "AWS GovCloud (美国东部)", - "us-gov-west-1": "AWS GovCloud (美国西部)", - "us-west-1": "美国西部 (加利福尼亚北部)", - "us-west-2": "美国西部 (俄勒冈)", - "ap-northeast-1-tpe-1": "亚太地区 (台湾)", - "ap-northeast-1-wl1-kix1": "亚太地区 (KDDI) - 大阪", - "ap-northeast-1-wl1-nrt1": "亚太地区 (KDDI) - 东京", - "ap-northeast-2-wl1-cjj1": "亚太地区 (SKT) - 大田", - "ap-northeast-2-wl1-sel1": "亚太地区 (SKT) - 首尔", - "ca-central-1-wl1-yto1": "加拿大 (BELL) - 多伦多", - "eu-central-1-wl1-ber1": "欧洲 (沃达丰) - 柏林", - "eu-central-1-wl1-dtm1": "欧洲 (沃达丰) - 多特蒙德", - "eu-central-1-wl1-muc1": "欧洲 (沃达丰) - 慕尼黑", - "eu-west-2-wl1-lon1": "欧洲 (沃达丰) - 伦敦", - "eu-west-2-wl1-man1": "欧洲 (沃达丰) - 曼彻斯特", - "eu-west-2-wl2-man1": "欧洲 (英国电信) - 曼彻斯特", - "eu-west-3-wl1-cmn1": "摩洛哥 (卡萨布兰卡)", - "us-east-1-wl1": "美国东部 (Verizon) - 波士顿", - "us-east-1-wl1-atl1": "美国东部 (Verizon) - 亚特兰大", - "us-east-1-wl1-bna1": "美国东部 (Verizon) - 纳什维尔", - "us-east-1-wl1-chi1": "美国东部 (Verizon) - 芝加哥", - "us-east-1-wl1-clt1": "美国东部 (Verizon) - 夏洛特", - "us-east-1-wl1-dfw1": "美国东部 (Verizon) - 达拉斯", - "us-east-1-wl1-dtw1": "美国东部 (Verizon) - 底特律", - "us-east-1-wl1-iah1": "美国东部 (Verizon) - 休斯顿", - "us-east-1-wl1-mia1": "美国东部 (Verizon) - 迈阿密", - "us-east-1-wl1-msp1": "美国东部 (Verizon) - 明尼阿波利斯", - "us-east-1-wl1-nyc1": "美国东部 (Verizon) - 纽约", - "us-east-1-wl1-tpa1": "美国东部 (Verizon) - 坦帕", - "us-east-1-wl1-was1": "美国东部 (Verizon) - 华盛顿特区", - "us-west-2-wl1": "美国西部 (Verizon) - 旧金山湾区", - "us-west-2-wl1-den1": "美国西部 (Verizon) - 丹佛", - "us-west-2-wl1-las1": "美国西部 (Verizon) - 拉斯维加斯", - "us-west-2-wl1-lax1": "美国西部 (Verizon) - 洛杉矶", - "us-west-2-wl1-phx1": "美国西部 (Verizon) - 凤凰城", - "us-west-2-wl1-sea1": "美国西部 (Verizon) - 西雅图", - "af-south-1-los-1": "尼日利亚 (拉各斯)", - "ap-south-1-ccu-1": "印度 (加尔各答)", - "ap-south-1-del-1": "印度 (德里)", - "ap-southeast-1-bkk-1": "泰国 (曼谷)", - "ap-southeast-1-mnl-1": "菲律宾 (马尼拉)", - "ap-southeast-2-akl-1": "新西兰 (奥克兰)", - "ap-southeast-2-per-1": "澳大利亚 (珀斯)", - "eu-central-1-ham-1": "德国 (汉堡)", - "eu-central-1-waw-1": "波兰 (华沙)", - "eu-north-1-cph-1": "丹麦 (哥本哈根)", - "eu-north-1-hel-1": "芬兰 (赫尔辛基)", - "me-south-1-mct-1": "阿曼 (马斯喀特)", - "us-east-1-atl-1": "美国东部 (亚特兰大)", - "us-east-1-bos-1": "美国东部 (波士顿)", - "us-east-1-bue-1": "阿根廷 (布宜诺斯艾利斯)", - "us-east-1-chi-1": "美国东部 (芝加哥)", - "us-east-1-dfw-1": "美国东部 (达拉斯)", - "us-east-1-iah-1": "美国东部 (休斯顿)", - "us-east-1-lim-1": "秘鲁 (利马)", - "us-east-1-mci-1": "美国东部 (堪萨斯城 2)", - "us-east-1-mia-1": "美国东部 (迈阿密)", - "us-east-1-msp-1": "美国东部 (明尼阿波利斯)", - "us-east-1-nyc-1": "美国东部 (纽约市)", - "us-east-1-phl-1": "美国东部 (费城)", - "us-east-1-qro-1": "墨西哥 (克雷塔罗)", - "us-east-1-scl-1": "智利 (圣地亚哥)", - "us-west-2-den-1": "美国西部 (丹佛)", - "us-west-2-hnl-1": "美国西部 (火奴鲁鲁)", - "us-west-2-las-1": "美国西部 (拉斯维加斯)", - "us-west-2-lax-1": "美国西部 (洛杉矶)", - "us-west-2-pdx-1": "美国西部 (波特兰)", - "us-west-2-phx-1": "美国西部 (凤凰城)", - "us-west-2-sea-1": "美国西部 (西雅图)" + "Asia Pacific (Malaysia)":"区域:亚太地区(马来西亚)", + "Asia Pacific (Taipei)":"区域:亚太地区(台北)", + "Asia Pacific (Thailand)":"区域:亚太地区(泰国)", + "Mexico (Central)":"区域:墨西哥(中部)", + "Africa (Cape Town)":"区域:非洲(开普敦)", + "Asia Pacific (Hong Kong)":"区域:亚太地区(香港)", + "Asia Pacific (Hyderabad)":"区域:亚太地区(海得拉巴)", + "Asia Pacific (Jakarta)":"区域:亚太地区(雅加达)", + "Asia Pacific (Melbourne)":"区域:亚太地区(墨尔本)", + "Asia Pacific (Osaka)":"区域:亚太地区(大阪)", + "Canada West (Calgary)":"区域:加拿大西部(卡尔加里)", + "EU (Milan)":"区域:欧洲地区(米兰)", + "EU (Spain)":"区域:欧洲(西班牙)", + "EU (Stockholm)":"区域:欧洲地区(斯德哥尔摩)", + "EU (Zurich)":"区域:欧洲(苏黎世)", + "Israel (Tel Aviv)":"区域:以色列(特拉维夫)", + "Middle East (Bahrain)":"区域:中东(巴林)", + "Middle East (UAE)":"区域:中东(阿联酋)", + "US West (N. California)":"区域:美国西部(北加利福尼亚)", + "Argentina (Buenos Aires)":"本地区域:阿根廷(布宜诺斯艾利斯)", + "Asia Pacific (KDDI) - Osaka":"运营商区域:亚太地区(KDDI)– 大阪", + "Asia Pacific (KDDI) - Tokyo":"运营商区域:亚太地区(KDDI)– 东京", + "Asia Pacific (SKT) - Daejeon":"运营商区域:亚太地区(SKT)– 大田", + "Asia Pacific (SKT) - Seoul":"运营商区域:亚太地区(SKT)– 首尔", + "Australia (Perth)":"本地区域:澳大利亚(珀斯)", + "Canada (BELL) - Toronto":"运营商区域:加拿大(BELL)– 多伦多", + "Chile (Santiago)":"本地区域:智利(圣地亚哥)", + "Denmark (Copenhagen)":"本地区域:丹麦(哥本哈根)", + "EU (British Telecom) - Manchester":"运营商区域:欧洲(英国电信)- 曼彻斯特", + "EU (Vodafone) - Berlin":"运营商区域:欧洲(Vodafone)– 柏林", + "EU (Vodafone) - Dortmund":"运营商区域:欧洲(Vodafone)– 多特蒙德", + "EU (Vodafone) - London":"运营商区域:欧洲(Vodafone)– 伦敦", + "EU (Vodafone) - Manchester":"运营商区域:欧洲(Vodafone)– 曼彻斯特", + "EU (Vodafone) - Munich":"运营商区域:欧洲(Vodafone)– 慕尼黑", + "Finland (Helsinki)":"本地区域:芬兰(赫尔辛基)", + "Germany (Hamburg)":"本地区域:德国(汉堡)", + "India (Delhi)":"本地区域:印度(德里)", + "India (Kolkata)":"本地区域:印度(加尔各答)", + "Mexico (Queretaro)":"本地区域:墨西哥(克雷塔罗)", + "Morocco (Casablanca)":"运营商区域:摩洛哥(卡萨布兰卡)", + "New Zealand (Auckland)":"本地区域:新西兰(奥克兰)", + "Nigeria (Lagos)":"本地区域:尼日利亚(拉各斯)", + "Oman (Muscat)":"本地区域:阿曼(马斯喀特)", + "Peru (Lima)":"本地区域:秘鲁(利马)", + "Philippines (Manila)":"本地区域:菲律宾(马尼拉)", + "Poland (Warsaw)":"本地区域:波兰(华沙)", + "Senegal (Dakar)":"运营商区域:塞内加尔(达喀尔)", + "Taiwan (Taipei)":"本地区域:台湾(台北)", + "Thailand (Bangkok)":"本地区域:泰国(曼谷)", + "US East (Atlanta)":"本地区域:美国东部(亚特兰大)", + "US East (Boston)":"本地区域:美国东部(波士顿)", + "US East (Chicago)":"本地区域:美国东部(芝加哥)", + "US East (Dallas)":"本地区域:美国东部(达拉斯)", + "US East (Houston)":"本地区域:美国东部(休斯顿)", + "US East (Kansas City 2)":"本地区域:美国东部(堪萨斯城 2)", + "US East (Lenexa)":"运营商区域:美国东部(列涅萨)", + "US East (Miami)":"本地区域:美国东部(迈阿密)", + "US East (Minneapolis)":"本地区域:美国东部(明尼阿波利斯)", + "US East (New York City)":"本地区域:美国东部(纽约市)", + "US East (Philadelphia)":"本地区域:美国东部(费城)", + "US East (Verizon) - Atlanta":"运营商区域:美国东部(威瑞森)– 亚特兰大", + "US East (Verizon) - Boston":"运营商区域:美国东部(威瑞森)– 波士顿", + "US East (Verizon) - Charlotte":"运营商区域:美国东部(威瑞森)– 夏洛特", + "US East (Verizon) - Chicago":"运营商区域:美国东部(威瑞森)– 芝加哥", + "US East (Verizon) - Dallas":"运营商区域:美国东部(威瑞森)– 达拉斯", + "US East (Verizon) - Detroit":"运营商区域:美国东部(威瑞森)– 底特律", + "US East (Verizon) - Houston":"运营商区域:美国东部(威瑞森)– 休斯顿", + "US East (Verizon) - Miami":"运营商区域:美国东部(威瑞森)– 迈阿密", + "US East (Verizon) - Minneapolis":"运营商区域:美国东部(威瑞森)– 明尼阿波利斯", + "US East (Verizon) - Nashville":"运营商区域:美国东部(威瑞森)- 纳什维尔", + "US East (Verizon) - New York":"运营商区域:美国东部(威瑞森)– 纽约", + "US East (Verizon) - Tampa":"运营商区域:美国东部(威瑞森)– 坦帕", + "US East (Verizon) - Washington DC":"运营商区域:美国东部(威瑞森)– 华盛顿特区", + "US West (Denver)":"本地区域:美国西部(丹佛)", + "US West (Honolulu)":"本地区域:美国西部(檀香山)", + "US West (Las Vegas)":"本地区域:美国西部(拉斯维加斯)", + "US West (Los Angeles)":"本地区域:美国西部(洛杉矶)", + "US West (Phoenix)":"本地区域:美国西部(菲尼克斯)", + "US West (Portland)":"本地区域:美国西部(波特兰)", + "US West (Seattle)":"本地区域:美国西部(西雅图)", + "US West (Verizon) - Denver":"运营商区域:美国西部(威瑞森)- 丹佛", + "US West (Verizon) - Las Vegas":"运营商区域:美国西部(威瑞森)- 拉斯维加斯", + "US West (Verizon) - Los Angeles":"运营商区域:美国西部(威瑞森)– 洛杉矶", + "US West (Verizon) - Phoenix":"运营商区域:美国东部(威瑞森)– 凤凰城", + "US West (Verizon) - San Francisco Bay Area":"运营商区域:美国西部(威瑞森)– 旧金山港湾区", + "US West (Verizon) - Seattle":"运营商区域:美国西部(威瑞森)- 西雅图", + "AWS GovCloud (US)":"区域:AWS GovCloud(美国西部)", + "AWS GovCloud (US-East)":"区域:AWS GovCloud(美国东部)", + "Asia Pacific (Mumbai)":"区域:亚太地区(孟买)", + "Asia Pacific (Seoul)":"区域:亚太地区(首尔)", + "Asia Pacific (Singapore)":"区域:亚太地区(新加坡)", + "Asia Pacific (Sydney)":"区域:亚太地区(悉尼)", + "Asia Pacific (Tokyo)":"区域:亚太地区(东京)", + "Canada (Central)":"区域:加拿大(中部)", + "EU (Frankfurt)":"区域:欧洲地区(法兰克福)", + "EU (Ireland)":"区域:欧洲地区(爱尔兰)", + "EU (London)":"区域:欧洲地区(伦敦)", + "South America (Sao Paulo)":"区域:南美洲(圣保罗)", + "US East (N. Virginia)":"区域:美国东部(弗吉尼亚州北部)", + "US East (Ohio)":"区域:美国东部(俄亥俄州)", + "US West (Oregon)":"区域:美国西部(俄勒冈州)", + "EU (Paris)":"区域:欧洲地区(巴黎)" } AWS_REGION_NAMES_EN = { - "af-south-1": "Africa (Cape Town)", - "ap-northeast-1": "Asia Pacific (Tokyo)", - "ap-northeast-2": "Asia Pacific (Seoul)", - "ap-northeast-3": "Asia Pacific (Osaka)", - "ap-south-1": "Asia Pacific (Mumbai)", - "ap-east-1": "Asia Pacific (Hong Kong)", - "ap-south-2": "Asia Pacific (Hyderabad)", - "ap-southeast-1": "Asia Pacific (Singapore)", - "ap-southeast-2": "Asia Pacific (Sydney)", - "ap-southeast-3": "Asia Pacific (Jakarta)", - "ap-southeast-4": "Asia Pacific (Melbourne)", - "ap-southeast-5": "Asia Pacific (Malaysia)", - "ap-southeast-7": "Asia Pacific (Thailand)", - "ca-central-1": "Canada (Central)", - "ca-west-1": "Canada West (Calgary)", - "eu-central-1": "EU (Frankfurt)", - "eu-central-2": "EU (Zurich)", - "eu-north-1": "EU (Stockholm)", - "eu-south-1": "EU (Milan)", - "eu-south-2": "EU (Spain)", - "eu-west-1": "EU (Ireland)", - "eu-west-2": "EU (London)", - "eu-west-3": "EU (Paris)", - "il-central-1": "Israel (Tel Aviv)", - "me-central-1": "Middle East (UAE)", - "me-south-1": "Middle East (Bahrain)", - "mx-central-1": "Mexico (Central)", - "sa-east-1": "South America (Sao Paulo)", - "us-east-1": "US East (N. Virginia)", - "us-east-2": "US East (Ohio)", - "us-east-2-mci-1": "US East (Kansas City)", - "us-gov-east-1": "AWS GovCloud (US-East)", - "us-gov-west-1": "AWS GovCloud (US)", - "us-west-1": "US West (N. California)", - "us-west-2": "US West (Oregon)", - "ap-northeast-1-wl1-kix1": "Asia Pacific (KDDI) - Osaka", - "ap-northeast-1-wl1-nrt1": "Asia Pacific (KDDI) - Tokyo", - "ap-northeast-2-wl1-cjj1": "Asia Pacific (SKT) - Daejeon", - "ap-northeast-2-wl1-sel1": "Asia Pacific (SKT) - Seoul", - "ap-northeast-1-tpe-1": "Asia Pacific (Taiwan)", - "ca-central-1-wl1-yto1": "Canada (BELL) - Toronto", - "eu-central-1-wl1-ber1": "EU (Vodafone) - Berlin", - "eu-central-1-wl1-dtm1": "EU (Vodafone) - Dortmund", - "eu-central-1-wl1-muc1": "EU (Vodafone) - Munich", - "eu-west-2-wl1-lon1": "EU (Vodafone) - London", - "eu-west-2-wl1-man1": "EU (Vodafone) - Manchester", - "eu-west-2-wl2-man1": "EU (British Telecom) - Manchester", - "eu-west-3-wl1-cmn1": "Morocco (Casablanca)", - "us-east-1-wl1": "US East (Verizon) - Boston", - "us-east-1-wl1-atl1": "US East (Verizon) - Atlanta", - "us-east-1-wl1-bna1": "US East (Verizon) - Nashville", - "us-east-1-wl1-chi1": "US East (Verizon) - Chicago", - "us-east-1-wl1-clt1": "US East (Verizon) - Charlotte", - "us-east-1-wl1-dfw1": "US East (Verizon) - Dallas", - "us-east-1-wl1-dtw1": "US East (Verizon) - Detroit", - "us-east-1-wl1-iah1": "US East (Verizon) - Houston", - "us-east-1-wl1-mia1": "US East (Verizon) - Miami", - "us-east-1-wl1-msp1": "US East (Verizon) - Minneapolis", - "us-east-1-wl1-nyc1": "US East (Verizon) - New York", - "us-east-1-wl1-tpa1": "US East (Verizon) - Tampa", - "us-east-1-wl1-was1": "US East (Verizon) - Washington DC", - "us-west-2-wl1": "US West (Verizon) - San Francisco Bay Area", - "us-west-2-wl1-den1": "US West (Verizon) - Denver", - "us-west-2-wl1-las1": "US West (Verizon) - Las Vegas", - "us-west-2-wl1-lax1": "US West (Verizon) - Los Angeles", - "us-west-2-wl1-phx1": "US West (Verizon) - Phoenix", - "us-west-2-wl1-sea1": "US West (Verizon) - Seattle", - "af-south-1-los-1": "Nigeria (Lagos)", - "ap-south-1-ccu-1": "India (Kolkata)", - "ap-south-1-del-1": "India (Delhi)", - "ap-southeast-1-bkk-1": "Thailand (Bangkok)", - "ap-southeast-1-mnl-1": "Philippines (Manila)", - "ap-southeast-2-akl-1": "New Zealand (Auckland)", - "ap-southeast-2-per-1": "Australia (Perth)", - "eu-central-1-ham-1": "Germany (Hamburg)", - "eu-central-1-waw-1": "Poland (Warsaw)", - "eu-north-1-cph-1": "Denmark (Copenhagen)", - "eu-north-1-hel-1": "Finland (Helsinki)", - "me-south-1-mct-1": "Oman (Muscat)", - "us-east-1-atl-1": "US East (Atlanta)", - "us-east-1-bos-1": "US East (Boston)", - "us-east-1-bue-1": "Argentina (Buenos Aires)", - "us-east-1-chi-1": "US East (Chicago)", - "us-east-1-dfw-1": "US East (Dallas)", - "us-east-1-iah-1": "US East (Houston)", - "us-east-1-lim-1": "Peru (Lima)", - "us-east-1-mci-1": "US East (Kansas City 2)", - "us-east-1-mia-1": "US East (Miami)", - "us-east-1-msp-1": "US East (Minneapolis)", - "us-east-1-nyc-1": "US East (New York City)", - "us-east-1-phl-1": "US East (Philadelphia)", - "us-east-1-qro-1": "Mexico (Queretaro)", - "us-east-1-scl-1": "Chile (Santiago)", - "us-west-2-den-1": "US West (Denver)", - "us-west-2-hnl-1": "US West (Honolulu)", - "us-west-2-las-1": "US West (Las Vegas)", - "us-west-2-lax-1": "US West (Los Angeles)", - "us-west-2-pdx-1": "US West (Portland)", - "us-west-2-phx-1": "US West (Phoenix)", - "us-west-2-sea-1": "US West (Seattle)" + "Asia Pacific (Malaysia)":"Asia Pacific (Malaysia)", + "Asia Pacific (Taipei)":"Asia Pacific (Taipei)", + "Asia Pacific (Thailand)":"Asia Pacific (Thailand)", + "Mexico (Central)":"Mexico (Central)", + "Africa (Cape Town)":"Africa (Cape Town)", + "Asia Pacific (Hong Kong)":"Asia Pacific (Hong Kong)", + "Asia Pacific (Hyderabad)":"Asia Pacific (Hyderabad)", + "Asia Pacific (Jakarta)":"Asia Pacific (Jakarta)", + "Asia Pacific (Melbourne)":"Asia Pacific (Melbourne)", + "Asia Pacific (Osaka)":"Asia Pacific (Osaka)", + "Canada West (Calgary)":"Canada West (Calgary)", + "EU (Milan)":"EU (Milan)", + "EU (Spain)":"EU (Spain)", + "EU (Stockholm)":"EU (Stockholm)", + "EU (Zurich)":"EU (Zurich)", + "Israel (Tel Aviv)":"Israel (Tel Aviv)", + "Middle East (Bahrain)":"Middle East (Bahrain)", + "Middle East (UAE)":"Middle East (UAE)", + "US West (N. California)":"US West (N. California)", + "External":"External", + "Amazon CloudFront":"Amazon CloudFront", + "Argentina (Buenos Aires)":"Argentina (Buenos Aires)", + "Asia Pacific (KDDI) - Osaka":"Asia Pacific (KDDI) - Osaka", + "Asia Pacific (KDDI) - Tokyo":"Asia Pacific (KDDI) - Tokyo", + "Asia Pacific (New Zealand)":"Asia Pacific (New Zealand)", + "Asia Pacific (SKT) - Daejeon":"Asia Pacific (SKT) - Daejeon", + "Asia Pacific (SKT) - Seoul":"Asia Pacific (SKT) - Seoul", + "Australia (Perth)":"Australia (Perth)", + "Canada (BELL) - Toronto":"Canada (BELL) - Toronto", + "Chile (Santiago)":"Chile (Santiago)", + "Denmark (Copenhagen)":"Denmark (Copenhagen)", + "EU (British Telecom) - Manchester":"EU (British Telecom) - Manchester", + "EU (Vodafone) - Berlin":"EU (Vodafone) - Berlin", + "EU (Vodafone) - Dortmund":"EU (Vodafone) - Dortmund", + "EU (Vodafone) - London":"EU (Vodafone) - London", + "EU (Vodafone) - Manchester":"EU (Vodafone) - Manchester", + "EU (Vodafone) - Munich":"EU (Vodafone) - Munich", + "Finland (Helsinki)":"Finland (Helsinki)", + "Germany (Hamburg)":"Germany (Hamburg)", + "India (Delhi)":"India (Delhi)", + "India (Kolkata)":"India (Kolkata)", + "Mexico (Queretaro)":"Mexico (Queretaro)", + "Morocco (Casablanca)":"Morocco (Casablanca)", + "New Zealand (Auckland)":"New Zealand (Auckland)", + "Nigeria (Lagos)":"Nigeria (Lagos)", + "Oman (Muscat)":"Oman (Muscat)", + "Peru (Lima)":"Peru (Lima)", + "Philippines (Manila)":"Philippines (Manila)", + "Poland (Warsaw)":"Poland (Warsaw)", + "SG Government (Singapore)":"SG Government (Singapore)", + "Senegal (Dakar)":"Senegal (Dakar)", + "Taiwan (Taipei)":"Taiwan (Taipei)", + "Thailand (Bangkok)":"Thailand (Bangkok)", + "US East (Atlanta)":"US East (Atlanta)", + "US East (Boston)":"US East (Boston)", + "US East (Chicago)":"US East (Chicago)", + "US East (Dallas)":"US East (Dallas)", + "US East (Houston)":"US East (Houston)", + "US East (Kansas City 2)":"US East (Kansas City 2)", + "US East (Kansas City)":"US East (Kansas City)", + "US East (Lenexa)":"US East (Lenexa)", + "US East (Miami)":"US East (Miami)", + "US East (Minneapolis)":"US East (Minneapolis)", + "US East (New York City)":"US East (New York City)", + "US East (Philadelphia)":"US East (Philadelphia)", + "US East (South Bend)":"US East (South Bend)", + "US East (Verizon) - Atlanta":"US East (Verizon) - Atlanta", + "US East (Verizon) - Boston":"US East (Verizon) - Boston", + "US East (Verizon) - Charlotte":"US East (Verizon) - Charlotte", + "US East (Verizon) - Chicago":"US East (Verizon) - Chicago", + "US East (Verizon) - Dallas":"US East (Verizon) - Dallas", + "US East (Verizon) - Detroit":"US East (Verizon) - Detroit", + "US East (Verizon) - Houston":"US East (Verizon) - Houston", + "US East (Verizon) - Miami":"US East (Verizon) - Miami", + "US East (Verizon) - Minneapolis":"US East (Verizon) - Minneapolis", + "US East (Verizon) - Nashville":"US East (Verizon) - Nashville", + "US East (Verizon) - New York":"US East (Verizon) - New York", + "US East (Verizon) - Tampa":"US East (Verizon) - Tampa", + "US East (Verizon) - Washington DC":"US East (Verizon) - Washington DC", + "US West (Denver)":"US West (Denver)", + "US West (Honolulu)":"US West (Honolulu)", + "US West (Las Vegas)":"US West (Las Vegas)", + "US West (Los Angeles)":"US West (Los Angeles)", + "US West (Phoenix)":"US West (Phoenix)", + "US West (Portland)":"US West (Portland)", + "US West (Seattle)":"US West (Seattle)", + "US West (Verizon) - Denver":"US West (Verizon) - Denver", + "US West (Verizon) - Las Vegas":"US West (Verizon) - Las Vegas", + "US West (Verizon) - Los Angeles":"US West (Verizon) - Los Angeles", + "US West (Verizon) - Phoenix":"US West (Verizon) - Phoenix", + "US West (Verizon) - San Francisco Bay Area":"US West (Verizon) - San Francisco Bay Area", + "US West (Verizon) - Seattle":"US West (Verizon) - Seattle", + "AWS GovCloud (US)":"AWS GovCloud (US)", + "AWS GovCloud (US-East)":"AWS GovCloud (US-East)", + "Asia Pacific (Mumbai)":"Asia Pacific (Mumbai)", + "Asia Pacific (Seoul)":"Asia Pacific (Seoul)", + "Asia Pacific (Singapore)":"Asia Pacific (Singapore)", + "Asia Pacific (Sydney)":"Asia Pacific (Sydney)", + "Asia Pacific (Tokyo)":"Asia Pacific (Tokyo)", + "Canada (Central)":"Canada (Central)", + "EU (Frankfurt)":"EU (Frankfurt)", + "EU (Ireland)":"EU (Ireland)", + "EU (London)":"EU (London)", + "South America (Sao Paulo)":"South America (Sao Paulo)", + "US East (N. Virginia)":"US East (N. Virginia)", + "US East (Ohio)":"US East (Ohio)", + "US West (Oregon)":"US West (Oregon)", + "EU (Paris)":"EU (Paris)" } # 可以添加其他云平台的配置 AZURE_REGION_NAMES = { diff --git a/backend/app/services/aws/pricing_v2.py b/backend/app/services/aws/pricing_v2.py index 109f298..fa0bdb8 100644 --- a/backend/app/services/aws/pricing_v2.py +++ b/backend/app/services/aws/pricing_v2.py @@ -58,6 +58,8 @@ async def search_instances_v2( operating_system, vcpu, memory, + gp3, + gp2, updatetime FROM aws_price WHERE 1=1 @@ -90,6 +92,7 @@ async def search_instances_v2( instances = [] for row in results: hourly_price = float(row['price']) + gp3_price = float(row['gp3']) monthly_price = hourly_price * 730 # 730小时/月 # 计算存储价格 @@ -102,7 +105,8 @@ async def search_instances_v2( region_code = code break - disk_monthly_price = await calculate_ebs_price(region_code, disk_gb) if region_code else 0 + # disk_monthly_price = await calculate_ebs_price(region_code, disk_gb) if region_code else 0 + disk_monthly_price = gp3_price * disk_gb # 计算总价格 total_monthly_price = monthly_price + disk_monthly_price From b1d50572df3ef6ae879396f1b6d6b4e003b9106c Mon Sep 17 00:00:00 2001 From: wangqifan Date: Fri, 29 Aug 2025 18:32:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?CPU=E6=A0=B8=E5=BF=83=E6=95=B0=E5=92=8C=E5=86=85=E5=AD=98?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E7=9A=84=E6=9C=80=E5=B0=8F=E5=80=BC=E4=B8=BA?= =?UTF-8?q?0=EF=BC=8C=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9B=B4=E7=81=B5?= =?UTF-8?q?=E6=B4=BB=E7=9A=84=E8=B5=84=E6=BA=90=E9=85=8D=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/InstanceSearch.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/InstanceSearch.vue b/frontend/src/views/InstanceSearch.vue index 8fa3f31..8464a37 100644 --- a/frontend/src/views/InstanceSearch.vue +++ b/frontend/src/views/InstanceSearch.vue @@ -15,7 +15,7 @@ Date: Fri, 29 Aug 2025 18:42:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?CPU=E6=A0=B8=E5=BF=83=E6=95=B0=E5=92=8C=E5=86=85=E5=AD=98?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E7=9A=84=E6=9C=80=E5=A4=A7=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E8=BE=93=E5=85=A5=E6=9B=B4=E7=81=B5=E6=B4=BB?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=97=B6=E9=99=90=E5=88=B6=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=95=B0=E9=87=8F=E8=87=B340=E6=9D=A1?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/services/aws/pricing_v2.py | 7 +++++-- frontend/src/views/InstanceSearch.vue | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/app/services/aws/pricing_v2.py b/backend/app/services/aws/pricing_v2.py index fa0bdb8..2038d6e 100644 --- a/backend/app/services/aws/pricing_v2.py +++ b/backend/app/services/aws/pricing_v2.py @@ -71,11 +71,11 @@ async def search_instances_v2( query += " AND area_en = %s" params.append(region_name) - if cpu_cores: + if cpu_cores > 0: query += " AND vcpu = %s" params.append(cpu_cores) - if memory_gb: + if memory_gb > 0: query += " AND memory = %s" params.append(memory_gb) @@ -87,6 +87,9 @@ async def search_instances_v2( # 执行查询 cursor.execute(query, params) results = cursor.fetchall() + + if len(results) >= 40: + results = results[0:40] # 处理结果 instances = [] diff --git a/frontend/src/views/InstanceSearch.vue b/frontend/src/views/InstanceSearch.vue index 8464a37..cb77d7e 100644 --- a/frontend/src/views/InstanceSearch.vue +++ b/frontend/src/views/InstanceSearch.vue @@ -16,7 +16,7 @@ @@ -29,7 +29,7 @@ @@ -388,8 +388,8 @@ export default { data() { return { form: { - cpu_cores: null, - memory_gb: null, + cpu_cores: 0, + memory_gb: 0, disk_gb: 30, // 默认30GB region: 'us-east-1', disk_type: 'gp3',