Commit d2520957 by diegolima

Corrigir logica do parser do google

1 parent 6d42c356
Showing with 13 additions and 13 deletions
......@@ -3,6 +3,7 @@ import math
import json
import sys
if len(sys.argv) == 1:
print('You need to specify a product type', end='\n\n')
print('Supported product types are:')
......@@ -14,7 +15,6 @@ PRODUCT_TYPE = sys.argv[1]
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':
......@@ -42,19 +42,24 @@ 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:
if PRODUCT_FAMILY in product: # Discard non-product entries
name = product[len(PRODUCT_FAMILY):].lower()
if PRODUCT_FAMILY == DB_PRODUCT_FAMILY:
match = COMPUTE_PRODUCT_FAMILY+name.upper()
match = match.replace('PG-','')
if 'PG-' in name.upper():
os = 'postgresql'
else:
os = 'mysql'
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]
if PRODUCT_FAMILY == COMPUTE_PRODUCT_FAMILY:
cost = DATA['gcp_price_list'][product][region]
for os in GCE_OS:
if os == 'linux':
add = 0
else:
......@@ -89,11 +94,6 @@ with open(FCATALOG) as url:
add = float(DATA['gcp_price_list']['CP-COMPUTEENGINE-OS']['win']["high"]) * float(billing_cpu)
add = add + float(DATA['gcp_price_list']['CP-COMPUTEENGINE-OS'][os]["high"]) * float(billing_cpu)
cost = float(cost)+add
print('google', end=',')
print(name, end=',')
print(cpu, end=',')
print(memory, end=',')
print(cost, end=',')
print(region, end=',')
print(os)
\ No newline at end of file
print('google,%s,%s,%s,%s,%s,%s' % (name, cpu, memory, cost, region, os))
else:
print('google,%s,%s,%s,%s,%s,%s' % (name, cpu, memory, cost, region, os))
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!