From 7dfe03424942ba2a51897a0d5d63301f698ae5ec Mon Sep 17 00:00:00 2001 From: Seokho Son Date: Mon, 9 Sep 2024 20:00:24 +0900 Subject: [PATCH] Update cloud region zone info --- assets/cloudinfo.yaml | 23 ++++++++++++++++++++++- scripts/misc/update-cloudinfo.py | 23 ++++++++++++++++------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/assets/cloudinfo.yaml b/assets/cloudinfo.yaml index 92a5c2b44..8cdc4b58c 100644 --- a/assets/cloudinfo.yaml +++ b/assets/cloudinfo.yaml @@ -1089,6 +1089,26 @@ cloud: latitude: 41.5908 longitude: -93.6208 zone: [] + spaincentral: + desc: Spain Central + location: + display: Madrid + latitude: 40.4259 + longitude: 3.4209 + zone: + - '1' + - '2' + - '3' + mexicocentral: + desc: Mexico Central + location: + display: Mexico + latitude: 20.588818 + longitude: -100.389888 + zone: + - '1' + - '2' + - '3' gcp: description: Google Cloud Platform driver: gcp-driver-v1.0.so @@ -1622,8 +1642,8 @@ cloud: latitude: 36.802725 longitude: 127.177481 zone: + - 9845bd17-d438-4bde-816d-1b12f37d5080 - eceb5d65-6571-4696-875f-5a17949f3317 - - 9845bd17-d438-4bde-816d-1b12f37d5080 ktcloudvpc: description: KT Cloud (VPC) driver: ktcloudvpc-driver-v1.0.so @@ -1798,6 +1818,7 @@ cloud: - ap-beijing-3 - ap-beijing-6 - ap-beijing-7 + - ap-beijing-8 ap-chengdu: description: Chengdu location: diff --git a/scripts/misc/update-cloudinfo.py b/scripts/misc/update-cloudinfo.py index ab1d0b7a9..2a8c4ff11 100755 --- a/scripts/misc/update-cloudinfo.py +++ b/scripts/misc/update-cloudinfo.py @@ -18,6 +18,8 @@ import yaml import json import requests +import shutil + nominatim_base_url = 'https://nominatim.openstreetmap.org/search' @@ -40,10 +42,10 @@ 'ibm': 'ibm-us-east', 'alibaba': 'alibaba-us-east-1', 'tencent': 'tencent-ap-singapore', - 'ncp': 'ncp-kr-kr-1', + 'ncp': 'ncp-kr', 'ncpvpc': 'ncpvpc-kr', - 'ktcloud': 'ktcloud-kor-central-a', - 'ktcloudvpc': 'ktcloudvpc-kr-dx-m1', + 'ktcloud': 'ktcloud-kor-central', + 'ktcloudvpc': 'ktcloudvpc-kr1', 'nhncloud': 'nhncloud-kr1' # Add more CSPs here } @@ -79,15 +81,16 @@ def fetch_regions_and_zones_from_spider(csp, region_zones): for region_info in regions_info: region_name = region_info['Name'] print(f"{region_name}:") - if region_info['ZoneList'] is not None: - zones = [zone['Name'] for zone in region_info['ZoneList']] + zone_list = region_info.get('ZoneList', None) + if zone_list is not None: + zones = [zone['Name'] for zone in zone_list] zones.sort() else: zones = [] region_zones[csp][region_name] = zones print(f"{zones}") else: - print(f"Failed to fetch GCP regions and zones: {response.text}") + print(f"Failed to fetch {csp} regions and zones: {response.text}") return region_zones @@ -140,6 +143,12 @@ def fetch_location_details(display_name): # Fetch region description using csp CLI def fetch_region_description(region_name): + + # Check if AWS CLI is installed + if shutil.which('aws') is None: + print(f"AWS CLI is not installed. Cannot fetch region description for {region_name}.") + return f"No description available for {region_name}" + try: result = subprocess.run( ['aws', 'ssm', 'get-parameters-by-path', '--path', f'/aws/service/global-infrastructure/regions/{region_name}', '--query', "Parameters[?Name.contains(@,`longName`)].Value", '--output', 'text'], @@ -233,7 +242,7 @@ def main(): for csp in target_csp: region_zones = fetch_regions_and_zones_from_spider(csp, region_zones) - region_zones = fetch_regions_and_zones('aws', region_zones) + # region_zones = fetch_regions_and_zones('aws', region_zones) compare_and_update_yaml(cloud_info, output_file_path, region_zones)