You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2018/06/29 08:19:33 UTC
[09/10] libcloud git commit: Make scraped EC2 sizes deterministic
Make scraped EC2 sizes deterministic
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/384e4233
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/384e4233
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/384e4233
Branch: refs/heads/trunk
Commit: 384e42336e073594acccb5ad1c0e873830c9a06c
Parents: 91e7e00
Author: Quentin Pradet <qu...@apache.org>
Authored: Fri Jun 29 10:08:20 2018 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Jun 29 12:05:30 2018 +0400
----------------------------------------------------------------------
contrib/scrap-ec2-sizes.py | 16 +-
libcloud/compute/constants.py | 5575 +++++++++++++++++-------------------
2 files changed, 2671 insertions(+), 2920 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/384e4233/contrib/scrap-ec2-sizes.py
----------------------------------------------------------------------
diff --git a/contrib/scrap-ec2-sizes.py b/contrib/scrap-ec2-sizes.py
index 992000e..0a0f4ff 100755
--- a/contrib/scrap-ec2-sizes.py
+++ b/contrib/scrap-ec2-sizes.py
@@ -204,6 +204,16 @@ def get_json():
return download_json()
+def filter_extras(extras):
+ return {
+ key: extras[key] for key in extras
+ if key not in [
+ 'capacitystatus', 'ebsOptimized', 'operation', 'licenseModel',
+ 'preInstalledSw', 'tenancy', 'usagetype'
+ ]
+ }
+
+
def parse():
# Set vars
sizes = {}
@@ -244,7 +254,7 @@ def parse():
'name': instance_type,
'ram': ram,
'bandwidth': bandwidth,
- 'extra': products_data[sku]['attributes'],
+ 'extra': filter_extras(products_data[sku]['attributes']),
}
if products_data[sku]['attributes'].get('storage') != "EBS only":
disk_number, disk_size = REG_STORAGE.match(
@@ -263,8 +273,8 @@ def parse():
def dump():
sizes, regions = parse()
print("# File generated by script")
- print("INSTANCE_TYPES = " + json.dumps(sizes, indent=4).replace('null', 'None'))
- print("REGION_DETAILS = " + json.dumps(regions, indent=4))
+ print("INSTANCE_TYPES = " + json.dumps(sizes, indent=4, sort_keys=True).replace('null', 'None'))
+ print("REGION_DETAILS = " + json.dumps(regions, indent=4, sort_keys=True))
if __name__ == '__main__':