This is an automated email from the ASF dual-hosted git repository. tomaz pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 66068783878ac5b009245ec1f9ffc88f394fd95f Author: Tomaz Muraus <[email protected]> AuthorDate: Wed Nov 13 23:34:02 2019 +0100 Fix scrape ec2-sizes script so it handles disk size strings in the following format: 225 GB NVMe SSD. --- contrib/scrape-ec2-sizes.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/contrib/scrape-ec2-sizes.py b/contrib/scrape-ec2-sizes.py index dbd832b..80d2de3 100755 --- a/contrib/scrape-ec2-sizes.py +++ b/contrib/scrape-ec2-sizes.py @@ -34,7 +34,8 @@ import ijson # pylint: disable=import-error FILEPATH = os.environ.get('TMP_JSON', '/tmp/ec.json') URL = "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json" IGNORED_FIELDS = ['locationType', 'operatingSystem'] -REG_STORAGE = re.compile(r'(\d+) x ([0-9,]+)') +REG1_STORAGE = re.compile(r'(\d+) x ([0-9,]+)') +REG2_STORAGE = re.compile(r'(\d+) GB.*?') REG_BANDWIDTH = re.compile(r'\D*(\d+)\D*') # From <https://aws.amazon.com/marketplace/help/200777880> REGION_DETAILS = { @@ -257,8 +258,15 @@ def parse(): 'extra': filter_extras(products_data[sku]['attributes']), } if products_data[sku]['attributes'].get('storage') != "EBS only": - disk_number, disk_size = REG_STORAGE.match( - products_data[sku]['attributes']['storage']).groups() + match = REG1_STORAGE.match(products_data[sku]['attributes']['storage']) + if match: + disk_number, disk_size = match.groups() + else: + match = REG2_STORAGE.match(products_data[sku]['attributes']['storage']) + if match: + disk_number, disk_size = 1, match.groups()[0] + else: + disk_number, disk_size = 0, '0' disk_number, disk_size = int(disk_number), int(disk_size.replace(',', '')) sizes[instance_type]['disk'] = disk_number * disk_size else:
