Commit a42411b4 by diegolima

Corrigir parse de banco de dados

1 parent 97ea0b5b
Showing with 13 additions and 4 deletions
......@@ -15,14 +15,16 @@ if (PRODUCT_TYPE != 'compute') and (PRODUCT_TYPE != 'database'):
print('Product type needs to be either computer or database!')
exit(1)
COMPUTE_PRODUCT_FAMILY = 'CP-COMPUTEENGINE-VMIMAGE-'
DB_PRODUCT_FAMILY = 'CP-DB-'
if PRODUCT_TYPE == 'compute':
FCATALOG = 'examples/gce_pricelist.json'
CATALOG = 'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json'
PRODUCT_FAMILY = 'CP-COMPUTEENGINE-VMIMAGE-'
PRODUCT_FAMILY = COMPUTE_PRODUCT_FAMILY
elif PRODUCT_TYPE == 'database':
FCATALOG = 'examples/gce_pricelist.json'
CATALOG = 'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json'
PRODUCT_FAMILY = 'CP-DB-'
PRODUCT_FAMILY = DB_PRODUCT_FAMILY
GCE_REGIONS = [
'us-central1', 'us-east1', 'us-east4', 'us-west1',
......@@ -39,10 +41,17 @@ GCE_OS = ['linux', 'win', 'rhel', 'suse', 'suse-sap', 'sql-standard', 'sql-web',
with open(FCATALOG) as url:
DATA = json.load(url)
for product in DATA['gcp_price_list']:
if 'CUSTOM-VM-' not in product:
if PRODUCT_FAMILY in product:
name = product[len(PRODUCT_FAMILY):].lower()
memory = DATA['gcp_price_list'][product]["memory"] + ' GB'
cpu = DATA['gcp_price_list'][product]["cores"]
if PRODUCT_FAMILY == DB_PRODUCT_FAMILY:
match = COMPUTE_PRODUCT_FAMILY+name.upper()
match = match.replace('PG-','')
else:
match = product
memory = DATA['gcp_price_list'][match]["memory"] + ' GB'
cpu = DATA['gcp_price_list'][match]["cores"]
for region in GCE_REGIONS:
for os in GCE_OS:
cost = DATA['gcp_price_list'][product][region]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!