Skip to content

Commit

Permalink
aws: add default regions in aws-china and aws-us-gov
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
liangxiao1 committed Feb 9, 2023
1 parent fb78112 commit 78d3796
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cloudwash/providers/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@
from cloudwash.utils import dry_data
from cloudwash.utils import echo_dry
from cloudwash.utils import total_running_time

import sys

def cleanup(**kwargs):

is_dry_run = kwargs["dry_run"]
data = ['VMS', 'NICS', 'DISCS', 'PIPS', 'RESOURCES', 'STACKS']
regions = settings.aws.auth.regions
if "all" in regions:
with compute_client("aws", aws_region="us-west-2") as client:
regions = client.list_regions()
default_regions = ['us-west-2', 'cn-northwest-1', 'us-gov-west-1']
for region in default_regions:
try:
with compute_client("aws", aws_region=region) as client:
regions = client.list_regions()
if regions:
break
except Exception as e:
pass
if "all" in regions:
logger.error(f"Unable to retrive region list using currrent token!")
sys.exit(1)
for region in regions:
dry_data['VMS']['stop'] = []
dry_data['VMS']['skip'] = []
Expand Down

0 comments on commit 78d3796

Please sign in to comment.