Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cloud region zone info and the helper tool #1811

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion assets/cloudinfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1798,6 +1818,7 @@ cloud:
- ap-beijing-3
- ap-beijing-6
- ap-beijing-7
- ap-beijing-8
ap-chengdu:
description: Chengdu
location:
Expand Down
23 changes: 16 additions & 7 deletions scripts/misc/update-cloudinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import yaml
import json
import requests
import shutil


nominatim_base_url = 'https://nominatim.openstreetmap.org/search'

Expand All @@ -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
}
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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)

Expand Down