Skip to content

Commit

Permalink
Merge pull request #148 from /issues/146
Browse files Browse the repository at this point in the history
Issues/146 - 0.3.1 release
  • Loading branch information
jantman committed Mar 4, 2016
2 parents 4357312 + 78fe76e commit 73b155a
Show file tree
Hide file tree
Showing 24 changed files with 636 additions and 201 deletions.
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Contributing to awslimitchecker
===============================

See the [Development page of the documentation on ReadTheDocs](http://awslimitchecker.readthedocs.org/en/develop/development.html) for information on how to contribute to awslimitchecker.
71 changes: 71 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Before opening an issue, please see the
[Getting Help](http://awslimitchecker.readthedocs.org/en/latest/getting_help.html)
page of the documentation.

Please remove all of this template but the relevant section below, and fill in
each item in that section.

## Feature Request

If your feature request is for support of a service or limit not currently
supported by awslimitchecker, you can simply title the issue "add support for
<name of service, or name of service and limit>" and add a simple description.

For anything else, please fill in the following:

### Feature Description

Describe in detail the feature you would like to see implemented, especially
how it would work from a user perspective and what benefits it adds. Your description
should be detailed enough to be used to determine if code written for the feature
adequately solves the problem.

### Use Cases

Describe one or more use cases for why this feature will be useful.

### Testing Assistance

Indicate whether or not you will be able to assist in testing pre-release
code for the feature.

## Bug Report

When reporting a bug in awslimitchecker, please provide all of the following information,
as well as any additional details that may be useful in reproducing or fixing
the issue:

### Version

awslimitchecker version, as reported by ``awslimitchecker --version``

### Installation Method

How was awslimitchecker installed (provide as much detail as possible, ideally
the exact command used and whether it was installed in a virtualenv or not).

### Supporting Software Versions

The output of ``python --version`` and ``virtualenv --version`` in the environment
that awslimitchecker is running in, as well as your operating system type and version.

### Actual Output

```
Paste here the output of awslimitchecker (including the command used to run it),
run with the -vv (debug-level output) flag, that shows the issue.
```

### Expected Output

Describe the output that you expected (what's wrong). If possible, after your description,
copy the actual output above and modify it to what was expected.

### TrustedAdvisor

If the bug/issue is related to TrustedAdvisor, which support contract your account has.

### Testing Assistance

Indicate whether or not you will be able to assist in testing pre-release
code for the feature.
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Before submitting pull requests, please see the
[Development documentation](http://awslimitchecker.readthedocs.org/en/latest/development.html)
and specifically the [Pull Request Guidelines](http://awslimitchecker.readthedocs.org/en/latest/development.html#pull-requests).

# Pull Request Checklist

- [ ] Code should conform to the [Development Guidelines](http://awslimitchecker.readthedocs.org/en/latest/development.html#guidelines):
- [ ] pep8 compliant with some exceptions (see pytest.ini)
- [ ] 100% test coverage with pytest (with valid tests). If you have difficulty
writing tests for the code, feel free to ask for help or submit the PR without tests.
- [ ] Complete, correctly-formatted documentation for all classes, functions and methods.
- [ ] documentation has been rebuilt with ``tox -e docs``
- [ ] Connections to the AWS services should only be made by the class's
``connect()`` and ``connect_resource()`` methods, inherited from
[awslimitchecker.connectable.Connectable](http://awslimitchecker.readthedocs.org/en/latest/awslimitchecker.connectable.html)
- [ ] All modules should have (and use) module-level loggers.
- [ ] **Commit messages** should be meaningful, and reference the Issue number
if you're working on a GitHub issue (i.e. "issue #x - <message>"). Please
refrain from using the "fixes #x" notation unless you are *sure* that the
the issue is fixed in that commit.
- [ ] Git history is fully intact; please do not squash or rewrite history.
- [ ] If you made changes to the ``versioncheck`` code, be sure to locally run the
``-versioncheck`` tox tests.
58 changes: 40 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,46 @@ sudo: false
cache:
directories:
- "$HOME/.pip-cache/"
env:
- TOXENV=py26-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py27-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py32-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py33-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py34-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=pypy-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=pypy3-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py26-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py27-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py32-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py33-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=py34-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=pypy-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=pypy3-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=docs PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- TOXENV=integration
- TOXENV=integration3
matrix:
include:
- python: "2.6"
env: TOXENV=py26-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "2.7"
env: TOXENV=py27-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.2"
env: TOXENV=py32-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.3"
env: TOXENV=py33-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.4"
env: TOXENV=py34-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.5"
env: TOXENV=py35-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "pypy"
env: TOXENV=pypy-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "pypy3"
env: TOXENV=pypy3-unit PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "2.6"
env: TOXENV=py26-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "2.7"
env: TOXENV=py27-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.2"
env: TOXENV=py32-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.3"
env: TOXENV=py33-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.4"
env: TOXENV=py34-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "3.5"
env: TOXENV=py35-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "pypy"
env: TOXENV=pypy-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "pypy3"
env: TOXENV=pypy3-versioncheck PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "2.7"
env: TOXENV=docs PIP_DOWNLOAD_CACHE=$HOME/.pip-cache
- python: "2.7"
env: TOXENV=integration
- python: "3.4"
env: TOXENV=integration3
install:
- virtualenv --version; test $TOXENV = "py32-unit" -o $TOXENV = "py32-versioncheck" -o $TOXENV = "pypy3-unit" -o $TOXENV = "pypy3-versioncheck" && pip install --upgrade virtualenv==13.1.2 || /bin/true
- git config --global user.email "travisci@jasonantman.com"
Expand Down
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Changelog
Pre-release (develop branch)
----------------------------


0.3.1 (2016-03-04)
------------------

* `#117 <https://github.com/jantman/awslimitchecker/issues/117>`_ fix Python 3.5 TravisCI tests and re-enable automatic testing for 3.5.
* `#116 <https://github.com/jantman/awslimitchecker/issues/116>`_ add t2.nano EC2 instance type; fix typo - "m4.8xlarge" should have been "m4.10xlarge"; update default limits for m4.(4|10)xlarge
* `#134 <https://github.com/jantman/awslimitchecker/issues/134>`_ Minor update to project description in docs and setup.py; use only _VERSION (not git) when building in RTD; include short description in docs HTML title; set meta description on docs index.rst.
* `#128 <https://github.com/jantman/awslimitchecker/issues/128>`_ Update Development and Getting Help documentation; add GitHub CONTRIBUTING.md file with link back to docs, as well as Issue and PR templates.
* `#131 <https://github.com/jantman/awslimitchecker/issues/131>`_ Refactor TrustedAdvisor interaction with limits for special naming cases (limits where the TrustedAdvisor service or limit name doesn't match that of the awslimitchecker limit); enable newly-available TrustedAdvisor data for some EC2 on-demand instance usage.

0.3.0 (2016-02-18)
------------------

Expand Down
10 changes: 7 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Develop:
:target: https://readthedocs.org/projects/awslimitchecker/?badge=develop
:alt: sphinx documentation for develop branch

A script and python module to check your AWS service limits and usage using `boto <http://docs.pythonboto.org/en/latest/>`_.
A script and python module to check your AWS service limits and usage, and warn when usage approaches limits.

Users building out scalable services in Amazon AWS often run into AWS' `service limits <http://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html>`_ -
often at the least convenient time (i.e. mid-deploy or when autoscaling fails). Amazon's `Trusted Advisor <https://aws.amazon.com/premiumsupport/trustedadvisor/>`_
Expand Down Expand Up @@ -145,8 +145,8 @@ For basic usage, see:
See the `project documentation <http://awslimitchecker.readthedocs.org>`_
for further information.

Bugs, Feature Requests
----------------------
Bugs, Feature Requests, Support
-------------------------------

Questions, comments, Bug reports and feature requests are happily accepted via
the `GitHub Issue Tracker <https://github.com/jantman/awslimitchecker/issues>`_.
Expand All @@ -155,6 +155,10 @@ Pull requests are always welcome.
Please see the `Development <http://awslimitchecker.readthedocs.org/en/latest/development.html>`_
and `Getting Help <http://awslimitchecker.readthedocs.org/en/latest/getting_help.html>`_ documentation for more information.

For paid support and development options, please see the
`Enterprise Support Agreements and Contract Development <http://awslimitchecker.readthedocs.org/en/latest/getting_help.html#getting-help-paid-support>`_
section of the documentation.

Changelog
---------

Expand Down
19 changes: 10 additions & 9 deletions awslimitchecker/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,20 @@ def __init__(self, warning_threshold=80, critical_threshold=99,
self.mfa_token = mfa_token
self.region = region
self.services = {}
for sname, cls in _services.items():
self.services[sname] = cls(warning_threshold, critical_threshold,
account_id, account_role, region,
external_id, mfa_serial_number,
mfa_token)
self.ta = TrustedAdvisor(
self.services,
account_id=account_id,
account_role=account_role,
region=region,
external_id=external_id,
mfa_serial_number=mfa_serial_number,
mfa_token=mfa_token
mfa_token=mfa_token,
)
for sname, cls in _services.items():
self.services[sname] = cls(warning_threshold, critical_threshold,
account_id, account_role, region,
external_id, mfa_serial_number,
mfa_token)

def get_version(self):
"""
Expand Down Expand Up @@ -175,7 +176,7 @@ def get_limits(self, service=None, use_ta=True):
if service is not None:
to_get = {service: self.services[service]}
if use_ta:
self.ta.update_limits(to_get)
self.ta.update_limits()
for sname, cls in to_get.items():
if hasattr(cls, '_update_limits_from_api'):
cls._update_limits_from_api()
Expand Down Expand Up @@ -211,7 +212,7 @@ def find_usage(self, service=None, use_ta=True):
if service is not None:
to_get = {service: self.services[service]}
if use_ta:
self.ta.update_limits(to_get)
self.ta.update_limits()
for cls in to_get.values():
if hasattr(cls, '_update_limits_from_api'):
cls._update_limits_from_api()
Expand Down Expand Up @@ -409,7 +410,7 @@ def check_thresholds(self, service=None, use_ta=True):
if service is not None:
to_get = {service: self.services[service]}
if use_ta:
self.ta.update_limits(to_get)
self.ta.update_limits()
for sname, cls in to_get.items():
if hasattr(cls, '_update_limits_from_api'):
cls._update_limits_from_api()
Expand Down
42 changes: 40 additions & 2 deletions awslimitchecker/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class AwsLimit(object):

def __init__(self, name, service, default_limit,
def_warning_threshold, def_critical_threshold,
limit_type=None, limit_subtype=None):
limit_type=None, limit_subtype=None,
ta_service_name=None, ta_limit_name=None):
"""
Describes one specific AWS service limit, as well as its
current utilization, default limit, thresholds, and any
Expand All @@ -65,7 +66,7 @@ def __init__(self, name, service, default_limit,
:type name: string
:param service: the :py:class:`~._AwsService` class that
this limit is for
:type service_name: :py:class:`~._AwsService`
:type service: :py:class:`~._AwsService`
:param default_limit: the default value of this limit for new accounts
:type default_limit: int
:param def_warning_threshold: the default warning threshold, as an
Expand All @@ -80,6 +81,13 @@ def __init__(self, name, service, default_limit,
such as "AWS::EC2::Instance" or "AWS::RDS::DBSubnetGroup".
:param limit_subtype: resource sub-type for this limit, if applicable,
such as "t2.micro" or "SecurityGroup"
:type limit_subtype: str
:param ta_service_name: The service name returned by Trusted Advisor
for this limit, if different from the name of ``service``
:type ta_service_name: str
:param ta_limit_name: The limit name returned by Trusted Advisor for
this limit, if different from ``name``.
:type ta_limit_name: str
:raises: ValueError
"""
if def_warning_threshold >= def_critical_threshold:
Expand All @@ -103,6 +111,8 @@ def __init__(self, name, service, default_limit,
self.crit_count = None
self._warnings = []
self._criticals = []
self._ta_service_name = ta_service_name
self._ta_limit_name = ta_limit_name

def set_limit_override(self, limit_value, override_ta=True):
"""
Expand Down Expand Up @@ -379,6 +389,34 @@ def get_criticals(self):
"""
return self._criticals

@property
def ta_service_name(self):
"""
Return the effective Trusted Advisor service name that this limit's
data will have. This should be ``self._ta_service_name`` if set,
otherwise the name of ``self.service``.
:return: Trusted Advisor service data name
:rtype: str
"""
if self._ta_service_name is not None:
return self._ta_service_name
return self.service.service_name

@property
def ta_limit_name(self):
"""
Return the effective Trusted Advisor limit name that this limit's
data will have. This should be ``self._ta_limit_name`` if set,
otherwise ``self.name``.
:return: Trusted Advisor limit data name
:rtype: str
"""
if self._ta_limit_name is not None:
return self._ta_limit_name
return self.name


class AwsLimitUsage(object):

Expand Down
9 changes: 7 additions & 2 deletions awslimitchecker/services/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def _get_limits_instances(self):
'i2.8xlarge': (2, 20, 0),
'd2.4xlarge': (10, 20, 5),
'd2.8xlarge': (5, 20, 5),
'm4.4xlarge': (10, 20, 5),
'm4.10xlarge': (5, 20, 5)
}
limits = {}
for i_type in self._instance_types():
Expand All @@ -258,7 +260,8 @@ def _get_limits_instances(self):
self.warning_threshold,
self.critical_threshold,
limit_type='On-Demand instances',
limit_subtype=i_type
limit_subtype=i_type,
ta_limit_name='On-Demand instances - %s' % i_type
)
# limit for ALL running On-Demand instances
key = 'Running On-Demand EC2 instances'
Expand Down Expand Up @@ -358,6 +361,7 @@ def _get_limits_networking(self):
self.critical_threshold,
limit_type='AWS::EC2::EIP',
limit_subtype='AWS::EC2::VPC',
ta_service_name='VPC' # TA shows this as VPC not EC2
)
# the EC2 limits screen calls this 'EC2-Classic Elastic IPs'
# but Trusted Advisor just calls it 'Elastic IP addresses (EIPs)'
Expand Down Expand Up @@ -413,6 +417,7 @@ def _instance_types(self):
:rtype: list
"""
GENERAL_TYPES = [
't2.nano',
't2.micro',
't2.small',
't2.medium',
Expand All @@ -425,7 +430,7 @@ def _instance_types(self):
'm4.xlarge',
'm4.2xlarge',
'm4.4xlarge',
'm4.8xlarge',
'm4.10xlarge'
]

PREV_GENERAL_TYPES = [
Expand Down
Loading

0 comments on commit 73b155a

Please sign in to comment.