Skip to content

Commit e4422a0

Browse files
Xiao Liangjyejare
authored andcommitted
aws: add default regions in aws-china and aws-us-gov
Handle failures When pass "all" in regions, us-west-2 is not proper when token is for aws-china and aws-us-gov. Signed-off-by: Xiao Liang <xiliang@redhat.com>
1 parent 069c295 commit e4422a0

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

cloudwash/providers/aws.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,26 @@
55
from cloudwash.utils import dry_data
66
from cloudwash.utils import echo_dry
77
from cloudwash.utils import total_running_time
8-
8+
import sys
99

1010
def cleanup(**kwargs):
1111

1212
is_dry_run = kwargs["dry_run"]
1313
data = ['VMS', 'NICS', 'DISCS', 'PIPS', 'RESOURCES', 'STACKS']
1414
regions = settings.aws.auth.regions
1515
if "all" in regions:
16-
with compute_client("aws", aws_region="us-west-2") as client:
17-
regions = client.list_regions()
16+
default_regions = ['us-west-2', 'cn-northwest-1', 'us-gov-west-1']
17+
for region in default_regions:
18+
try:
19+
with compute_client("aws", aws_region=region) as client:
20+
regions = client.list_regions()
21+
if regions:
22+
break
23+
except Exception as e:
24+
pass
25+
if "all" in regions:
26+
logger.error(f"Unable to retrive region list using currrent token!")
27+
sys.exit(1)
1828
for region in regions:
1929
dry_data['VMS']['stop'] = []
2030
dry_data['VMS']['skip'] = []

0 commit comments

Comments
 (0)