ifosch / accloudtant Goto Github PK
View Code? Open in Web Editor NEWAWS cost calculator
AWS cost calculator
Provide a command hierarchy to access current features, like:
accloudtant print
accloudtant report
It should allow common and specific options, following aws-cli style and naming for them.
Prices doesn't get prices for instance types of previous generations, making reports to fail miserably if there are instances of these types.
We should start using logger instead of print. Let's replace these.
The help message don't explain the existing commands.
For some of the EC2 pricing tables, get current values from internet. For MVP 0.1, we require the following:
The table format is great to see the data in the terminal, but to facilytate the import into other tools, CSV is a best (and simple) choice.
def match_reserved_instance(self, reserved):
if any((self.state != 'running',
reserved['State'] != 'active',
reserved['InstancesLeft'] == 0,
reserved['ProductDescription'] != self.operating_system,
reserved['InstanceType'] != self.size,
reserved['AvailabilityZone'] != self.availability_zone)):
return False
return True
Using any
here requires create the list of conditions to determine if the reserved instance and the instance match enough to consider this instance to be reserved.
If I understood ok, @jsoucheiron points the fact that having to create the list adds too much cost in processing time to the function, while having a generator, or using or
instead, should improve the timing of the function.
AWS has published API for getting prices.
In the announcement, they also offer a [documentation[(http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html).
This will probably replace current JS page, and also, it seems a faster way to fix that.
Not a critical issue, but would be nice to setup and use autopep8
for fixing style issues in all files.
There are some packages required but not really needed to run the app.
My system have Python 3 installed by default (Archlinux). This is the output of accloudtant report
:
Traceback (most recent call last):
File "/usr/bin/accloudtant", line 22, in <module>
cli()
File "/usr/lib/python3.5/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.5/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.5/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/bin/accloudtant", line 19, in report
click.echo(Reports())
File "/usr/lib/python3.5/site-packages/click/utils.py", line 221, in echo
message = text_type(message)
File "/usr/lib/python3.5/site-packages/accloudtant/aws/reports.py", line 69, in __repr__
instance.name,
File "/usr/lib/python3.5/site-packages/accloudtant/aws/instance.py", line 68, in name
return names[0]['Value']
IndexError: list index out of range
I can't verify that it works well on Python 2 so fell free to close this issue and open a new one if the problem is not caused by the Python version.
Following Code Climate instructions, its analysis should be improved, and aligned with flake8 output.
When I use the report
command
I want to get a footer with totals.
Could be nice be able to complete commands and options.
I want to get pricing for EBS
Check errors when using flake8
on repo root:
$ flake8 --max-complexity 5
./accloudtant/aws/reports.py:17:1: C901 'Reports.find_reserved_instance' is too complex (6)
./accloudtant/aws/instance.py:79:1: C901 'Instance.match_reserved_instance' is too complex (7)
./tests/aws/conftest.py:44:1: C901 'ec2_resource' is too complex (9)
./tests/aws/conftest.py:73:1: C901 'ec2_client' is too complex (8)
./tests/aws/conftest.py:101:1: C901 'mock_requests_get' is too complex (6)
./tests/aws/conftest.py:125:1: C901 'process_ec2' is too complex (7)
It would be great to fix these over complexity, even when happening in tests.
I wanted to run accloudtant inside Docker using FROM python:2.7-onbuild
.
This is the output of docker build
:
# Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/
lstat requirements.txt: no such file or directory
More info on how onbuild works
https://hub.docker.com/_/python/
Different AWS services not always are present in regions in the all regions. This may also happen for service details.
In that aspect, the pricing should signal there's no service in a region, by showing something like '-' or, maybe clearer, 'N/A'.
When printing prices, there were a nice list of warnings about problems getting the data.
Since the addition of the two commands, this list vanished.
When a default profile is not defined, or when no AWS environment variables are found, the app crashes.
Reserved instances and instances should be linked.
I want to have the program working with Python 2.7, so the tests need to be run on this version as well.
This story implies:
python setup.py sdist upload -r pypitest
python setup.py sdist upload -r pypi
Get and list current EC2 pricing, for OD and RI on hourly basis.
Take a try and peek on epheph/ec2-check-reserved-instances[1], it is pretty old and looks unmaintained, but still could give some idea.
When generating reports, the code iterates over all instances, and all reserved instances, to get the links between these, the report should iterate over running instances and active reserved instances, only.
I tried to get list of my EC2 instances and its reports followed by https://pypi.python.org/pypi/accloudtant/0.1.3.
I tried from Mac and Ubuntu systems,
with Python3, am keep getting this error msg and not sure whats cause this,
#accloudtant list
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/accloudtant", line 22, in
cli()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/accloudtant", line 14, in price_list
click.echo(Prices())
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/accloudtant/aws/prices.py", line 36, in init
self.output = print_prices(self.prices)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/accloudtant/aws/prices.py", line 92, in print_prices
for size in sorted(instances[ec2_kind][region].keys()):
KeyError: 'linux'
Reserved instances are currently simple dictionaries. Implementing these as objects might help to use them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.