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 a42411b4
authored
Nov 01, 2017
by
diegolima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrigir parse de banco de dados
1 parent
97ea0b5b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
gce_parser.py
gce_parser.py
View file @
a42411b
...
...
@@ -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
]
...
...
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