Commit e79abed5 by diegolima

Não remover DB- dos prefixos do nome no Google

1 parent 43227420
......@@ -46,10 +46,10 @@ elif PRODUCT_TYPE == 'database':
CATALOG = 'https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonRDS/current/index.json'
PRODUCT_FAMILY = 'Database Instance'
#with urllib.request.urlopen(CATALOG) as url:
# DATA = json.loads(url.read().decode())
with open(FCATALOG) as url:
DATA = json.load(url)
with urllib.request.urlopen(CATALOG) as url:
DATA = json.loads(url.read().decode())
#with open(FCATALOG) as url:
# DATA = json.load(url)
for product in DATA["products"]:
if DATA['products'][product]['productFamily'] == PRODUCT_FAMILY:
sku = DATA['products'][product]['sku']
......
......@@ -6,11 +6,11 @@ import sys
PRODUCT_TYPE = 'compute'
if PRODUCT_TYPE == 'compute':
FCATALOG = 'examples/azure.json'
CATALOG = 'https://azure.microsoft.com/api/v1/pricing/virtual-machines/calculator/?culture=en-us'
CATALOG = 'https://azure.microsoft.com/api/v2/pricing/virtual-machines-base/calculator/?culture=pt-br&discount=mosp'
PRODUCT_FAMILY = 'Compute Instance'
elif PRODUCT_TYPE == 'database':
FCATALOG = 'examples/azure.json'
CATALOG = 'https://azure.microsoft.com/api/v1/pricing/virtual-machines/calculator/?culture=en-us'
CATALOG = 'https://azure.microsoft.com/api/v2/pricing/virtual-machines-base/calculator/?culture=pt-br&discount=mosp'
PRODUCT_FAMILY = 'Database Instance'
OSLIST = [
......
import math
import json
import sys
import urllib.request
if len(sys.argv) == 1:
print('You need to specify a product type')
......@@ -42,6 +42,7 @@ with open(FCATALOG) as url:
for product in DATA['gcp_price_list']:
if 'CUSTOM-VM-' not in product:
if PRODUCT_FAMILY in product: # Discard non-product entries
realname = product[len(PRODUCT_FAMILY)-3:].lower()
name = product[len(PRODUCT_FAMILY):].lower()
if PRODUCT_FAMILY == DB_PRODUCT_FAMILY:
match = COMPUTE_PRODUCT_FAMILY+name.upper()
......@@ -96,4 +97,4 @@ with open(FCATALOG) as url:
cost = float(cost)+add
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
print('google,%s,%s,%s,%s,%s,%s' % (realname, 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!