Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Diego Lima
/
aws-price-parser
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e79abed5
authored
Feb 01, 2018
by
diegolima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Não remover DB- dos prefixos do nome no Google
1 parent
43227420
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
9 deletions
aws_parser.py
azure_parser.py
examples/gce_pricelist.json
gce_parser.py
aws_parser.py
View file @
e79abed
...
...
@@ -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'
]
...
...
azure_parser.py
View file @
e79abed
...
...
@@ -6,11 +6,11 @@ import sys
PRODUCT_TYPE
=
'compute'
if
PRODUCT_TYPE
==
'compute'
:
FCATALOG
=
'examples/azure.json'
CATALOG
=
'https://azure.microsoft.com/api/v
1/pricing/virtual-machines/calculator/?culture=en-us
'
CATALOG
=
'https://azure.microsoft.com/api/v
2/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/v
1/pricing/virtual-machines/calculator/?culture=en-us
'
CATALOG
=
'https://azure.microsoft.com/api/v
2/pricing/virtual-machines-base/calculator/?culture=pt-br&discount=mosp
'
PRODUCT_FAMILY
=
'Database Instance'
OSLIST
=
[
...
...
examples/gce_pricelist.json
View file @
e79abed
This diff is collapsed.
Click to expand it.
gce_parser.py
View file @
e79abed
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
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment