Skip to content

Commit

Permalink
Merge pull request #148 from asmorodskyi/ec2_region_limit
Browse files Browse the repository at this point in the history
Expose regions in EC2 into config
  • Loading branch information
asmorodskyi authored Jun 15, 2022
2 parents 817308d + 9b249d5 commit c4d0c2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ocw/lib/EC2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .provider import Provider, Image
from webui.settings import PCWConfig
from webui.settings import PCWConfig, ConfigFile
from dateutil.parser import parse
import boto3
from botocore.exceptions import ClientError
Expand All @@ -17,7 +17,10 @@ class EC2(Provider):
def __init__(self, namespace: str):
super().__init__(namespace)
self.check_credentials()
self.all_regions = self.get_all_regions()
if PCWConfig.has('default/ec2_regions'):
self.all_regions = ConfigFile().getList('default/ec2_regions')
else:
self.all_regions = self.get_all_regions()

def __new__(cls, vault_namespace):
if vault_namespace not in EC2.__instances:
Expand Down
2 changes: 2 additions & 0 deletions templates/pcw.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ base-url = https://publiccloud.qa.suse.de
namespaces = qac
# true here will make PCW harmless by replacing ALL modification calls to CSP's by log messages.
dry_run = true
# limit the scope of regions queried for EC2 . In case not defined all regions will be used
ec2_regions = eu-central-1, us-west-2

[notify]
# time frame (hours) during it PCW will ignore running VM .
Expand Down

0 comments on commit c4d0c2b

Please sign in to comment.