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 f30e1156
authored
Feb 22, 2018
by
diegolima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
melhorar tratamento de tipo de produto
1 parent
2b69923b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
11 deletions
gce_parser.py
gce_parser.py
View file @
f30e115
...
@@ -3,17 +3,9 @@ import json
...
@@ -3,17 +3,9 @@ import json
import
sys
import
sys
import
urllib.request
import
urllib.request
if
len
(
sys
.
argv
)
==
1
:
print
(
'You need to specify a product type'
)
print
(
'Supported product types are:'
)
print
(
'- compute'
)
print
(
'- database'
)
exit
(
1
)
PRODUCT_TYPE
=
sys
.
argv
[
1
]
PRODUCT_TYPE
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
==
2
else
'none'
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-'
COMPUTE_PRODUCT_FAMILY
=
'CP-COMPUTEENGINE-VMIMAGE-'
DB_PRODUCT_FAMILY
=
'CP-DB-'
DB_PRODUCT_FAMILY
=
'CP-DB-'
if
PRODUCT_TYPE
==
'compute'
:
if
PRODUCT_TYPE
==
'compute'
:
...
@@ -24,6 +16,9 @@ elif PRODUCT_TYPE == 'database':
...
@@ -24,6 +16,9 @@ elif PRODUCT_TYPE == 'database':
FCATALOG
=
'examples/gce_pricelist.json'
FCATALOG
=
'examples/gce_pricelist.json'
CATALOG
=
'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json'
CATALOG
=
'https://cloudpricingcalculator.appspot.com/static/data/pricelist.json'
PRODUCT_FAMILY
=
DB_PRODUCT_FAMILY
PRODUCT_FAMILY
=
DB_PRODUCT_FAMILY
else
:
print
(
"Product type not supported"
)
sys
.
exit
(
1
)
GCE_REGIONS
=
[
GCE_REGIONS
=
[
'us-central1'
,
'us-east1'
,
'us-east4'
,
'us-west1'
,
'us-central1'
,
'us-east1'
,
'us-east4'
,
'us-west1'
,
...
@@ -34,7 +29,6 @@ GCE_REGIONS = [
...
@@ -34,7 +29,6 @@ GCE_REGIONS = [
]
]
GCE_OS
=
[
'linux'
,
'win'
,
'rhel'
,
'suse'
,
'suse-sap'
,
'sql-standard'
,
'sql-web'
,
'sql-enterprise'
]
GCE_OS
=
[
'linux'
,
'win'
,
'rhel'
,
'suse'
,
'suse-sap'
,
'sql-standard'
,
'sql-web'
,
'sql-enterprise'
]
#TODO: Download & decompress the gzipped current catalog
with
urllib
.
request
.
urlopen
(
CATALOG
)
as
url
:
with
urllib
.
request
.
urlopen
(
CATALOG
)
as
url
:
DATA
=
json
.
loads
(
url
.
read
()
.
decode
())
DATA
=
json
.
loads
(
url
.
read
()
.
decode
())
#with open(FCATALOG) as url:
#with open(FCATALOG) as url:
...
...
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