Commit 9a0d9c7d by diegolima

Traduzir nomes de regiao

1 parent d2520957
Showing with 37 additions and 17 deletions
......@@ -17,19 +17,39 @@ if (PRODUCT_TYPE != 'compute') and (PRODUCT_TYPE != 'database'):
TERM_ONDEMAND = 'JRTCKXETXF' #Ondemand. TODO: Find out where to get this from
HOURLY_DIMENSION = '6YS6EN2CT7' #Tier1. TODO: Find out where to get this from
def locationmap(argument):
switcher = {
"Asia Pacific (Tokyo)": "ap-northeast-1",
"Asia Pacific (Seoul)": "ap-northeast-2",
"Asia Pacific (Mumbai)": "ap-south-1",
"Asia Pacific (Singapore)": "ap-southeast-1",
"Asia Pacific (Sydney)": "ap-southeast-2",
"Canada (Central)": "ca-central-1",
"EU (Frankfurt)": "eu-central-1",
"EU (Ireland)": "eu-west-1",
"EU (London)": "eu-west-2",
"South America (Sao Paulo)": "sa-east-1",
"US East (N. Virginia)": "us-east-1",
"US East (Ohio)": "us-east-2",
"US West (N. California)": "us-west-1",
"US West (Oregon)": "us-west-2",
"AWS GovCloud (US)": "us-gov-west-1",
}
return switcher.get(argument, "UNKNOWNREGIONERROR")
if PRODUCT_TYPE == 'compute':
FCATALOG = 'ec2.json'
FCATALOG = 'examples/aws_ec2.json'
CATALOG = 'https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json'
PRODUCT_FAMILY = 'Compute Instance'
elif PRODUCT_TYPE == 'database':
FCATALOG = 'rds.json'
FCATALOG = 'examples/aws_rds.json'
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']
......@@ -37,16 +57,16 @@ with urllib.request.urlopen(CATALOG) as url:
if key:
cost = key[sku + '.' + TERM_ONDEMAND]['priceDimensions'][sku + '.' + TERM_ONDEMAND + '.' + HOURLY_DIMENSION]['pricePerUnit']['USD']
if cost != '0.0000000000':
print('aws', end=',')
print(DATA['products'][product]['attributes']['instanceType'], end=',')
print(DATA['products'][product]['attributes']['vcpu'], end=',')
print(DATA['products'][product]['attributes']['memory'], end=',')
print(cost, end=',')
print(DATA['products'][product]['attributes']['location'], end=',')
name = DATA['products'][product]['attributes']['instanceType']
region = locationmap(DATA['products'][product]['attributes']['location'])
cpu = DATA['products'][product]['attributes']['vcpu']
memory = DATA['products'][product]['attributes']['memory']
if PRODUCT_TYPE == 'compute':
print(DATA['products'][product]['attributes']['operatingSystem'])
os = DATA['products'][product]['attributes']['operatingSystem']
print('aws,%s,%s,%s,%s,%s,%s' % (name, cpu, memory, cost, region, os))
elif PRODUCT_TYPE == 'database':
print(DATA['products'][product]['attributes']['databaseEngine'], end=',')
print(DATA['products'][product]['attributes'].get('databaseEdition'), end=',')
print(DATA['products'][product]['attributes']['licenseModel'], end=',')
print(DATA['products'][product]['attributes']['deploymentOption'])
os = DATA['products'][product]['attributes']['databaseEngine']
edition = DATA['products'][product]['attributes'].get('databaseEdition')
licensemodel = DATA['products'][product]['attributes']['licenseModel']
deployment = DATA['products'][product]['attributes']['deploymentOption']
print('aws,%s,%s,%s,%s,%s,%s,%s,%s,%s' % (name, cpu, memory, cost, region, os, edition, licensemodel, deployment))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!