closes #48 code comments
diff --git a/ec2stack/__init__.py b/ec2stack/__init__.py
index 71f2fa3..7501d2c 100644
--- a/ec2stack/__init__.py
+++ b/ec2stack/__init__.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module creates the flask application.
+"""
+
import os
import sys
diff --git a/ec2stack/__main__.py b/ec2stack/__main__.py
index 704a310..0c55a58 100644
--- a/ec2stack/__main__.py
+++ b/ec2stack/__main__.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module is used to launch EC2Stack
+"""
+
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
diff --git a/ec2stack/configure.py b/ec2stack/configure.py
index 0433d80..ec01a45 100644
--- a/ec2stack/configure.py
+++ b/ec2stack/configure.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module provides functions to generate an ec2stack configuration file.
+"""
+
import os
from alembic import command
diff --git a/ec2stack/controllers/__init__.py b/ec2stack/controllers/__init__.py
index 6f804bc..87cbeaf 100644
--- a/ec2stack/controllers/__init__.py
+++ b/ec2stack/controllers/__init__.py
@@ -1,2 +1,5 @@
#!/usr/bin/env python
# encoding: utf-8
+
+"""This module contains route handlers for the application.
+"""
diff --git a/ec2stack/controllers/default.py b/ec2stack/controllers/default.py
index 63b0775..a7b6b72 100644
--- a/ec2stack/controllers/default.py
+++ b/ec2stack/controllers/default.py
@@ -85,7 +85,7 @@
def register_secret_key():
"""
- Registers a user's API key and secret key
+ Register a user's API key and secret key
@return: Response.
@raise Ec2stackError: API key already being registered.
@@ -114,7 +114,7 @@
def remove_secret_key():
"""
- Remove's a user's API key and secret key
+ Remove a user's API key and secret key
@return: Response.
@raise Ec2stackError: API key doesn't exist.
diff --git a/ec2stack/core.py b/ec2stack/core.py
index 9411a23..3ef557b 100644
--- a/ec2stack/core.py
+++ b/ec2stack/core.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module provides core classes.
+"""
+
from flask_sqlalchemy import SQLAlchemy
DB = SQLAlchemy()
diff --git a/ec2stack/errors.py b/ec2stack/errors.py
index c8b9165..49a420e 100644
--- a/ec2stack/errors.py
+++ b/ec2stack/errors.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for error reporting.
+"""
+
from ec2stack.core import Ec2stackError
diff --git a/ec2stack/helpers.py b/ec2stack/helpers.py
index ba00643..a34c194 100644
--- a/ec2stack/helpers.py
+++ b/ec2stack/helpers.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains helper functions used across the package namespace.
+"""
+
import os
import hmac
import hashlib
diff --git a/ec2stack/models/__init__.py b/ec2stack/models/__init__.py
index d633667..433e1ef 100644
--- a/ec2stack/models/__init__.py
+++ b/ec2stack/models/__init__.py
@@ -1,4 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module exposes all models.
+"""
+
from ec2stack.models.users.models import *
diff --git a/ec2stack/models/users/__init__.py b/ec2stack/models/users/__init__.py
index b894c9f..ae8fba9 100644
--- a/ec2stack/models/users/__init__.py
+++ b/ec2stack/models/users/__init__.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module creates a user service.
+"""
+
from ec2stack.core import Service
from ec2stack.models.users.models import User
diff --git a/ec2stack/models/users/models.py b/ec2stack/models/users/models.py
index 6479e58..b0f712a 100644
--- a/ec2stack/models/users/models.py
+++ b/ec2stack/models/users/models.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module creates the user model.
+"""
+
from ec2stack.core import DB
diff --git a/ec2stack/providers/__init__.py b/ec2stack/providers/__init__.py
index 6f804bc..c67da43 100644
--- a/ec2stack/providers/__init__.py
+++ b/ec2stack/providers/__init__.py
@@ -1,2 +1,5 @@
#!/usr/bin/env python
# encoding: utf-8
+
+"""This module contains providers for request execution.
+"""
diff --git a/ec2stack/providers/cloudstack/__init__.py b/ec2stack/providers/cloudstack/__init__.py
index fe3d9fa..1b8eeec 100644
--- a/ec2stack/providers/cloudstack/__init__.py
+++ b/ec2stack/providers/cloudstack/__init__.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains helper functions used across the package namespace.
+"""
+
from ec2stack import helpers
from ec2stack.providers.cloudstack import requester
diff --git a/ec2stack/providers/cloudstack/disk_offerings.py b/ec2stack/providers/cloudstack/disk_offerings.py
index 57739e4..28672b7 100644
--- a/ec2stack/providers/cloudstack/disk_offerings.py
+++ b/ec2stack/providers/cloudstack/disk_offerings.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to disk
+offerings
+"""
+
from ec2stack import errors
from ec2stack.providers import cloudstack
diff --git a/ec2stack/providers/cloudstack/images.py b/ec2stack/providers/cloudstack/images.py
index 4b525ef..3a0bc51 100644
--- a/ec2stack/providers/cloudstack/images.py
+++ b/ec2stack/providers/cloudstack/images.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to images
+"""
+
from ec2stack import helpers, errors
from ec2stack.providers import cloudstack
diff --git a/ec2stack/providers/cloudstack/instances.py b/ec2stack/providers/cloudstack/instances.py
index 251a467..9eed292 100644
--- a/ec2stack/providers/cloudstack/instances.py
+++ b/ec2stack/providers/cloudstack/instances.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to instances
+"""
+
from flask import current_app
from ec2stack.providers import cloudstack
@@ -190,7 +193,7 @@
elif 'A key pair with name' in response['errortext']:
errors.invalid_keypair_name()
else:
- errors.invalid_parameter_value(response['errortext'])
+ errors.invalid_request(response['errortext'])
else:
response = response['virtualmachine']
response = {
diff --git a/ec2stack/providers/cloudstack/keypairs.py b/ec2stack/providers/cloudstack/keypairs.py
index 66eb608..e879430 100644
--- a/ec2stack/providers/cloudstack/keypairs.py
+++ b/ec2stack/providers/cloudstack/keypairs.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to keypairs
+"""
+
from base64 import b64decode
from ec2stack.providers import cloudstack
diff --git a/ec2stack/providers/cloudstack/passwords.py b/ec2stack/providers/cloudstack/passwords.py
index 2641c4a..02afdfd 100644
--- a/ec2stack/providers/cloudstack/passwords.py
+++ b/ec2stack/providers/cloudstack/passwords.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to password
+data
+"""
+
from ec2stack import helpers, errors
from ec2stack.providers.cloudstack import requester
diff --git a/ec2stack/providers/cloudstack/requester.py b/ec2stack/providers/cloudstack/requester.py
index df10574..5c05e9d 100644
--- a/ec2stack/providers/cloudstack/requester.py
+++ b/ec2stack/providers/cloudstack/requester.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling the execution of requests
+against Cloudstack.
+"""
+
from urllib import urlencode, quote_plus
from hashlib import sha1
from base64 import b64encode
diff --git a/ec2stack/providers/cloudstack/security_groups.py b/ec2stack/providers/cloudstack/security_groups.py
index f2667ef..a9de4c5 100644
--- a/ec2stack/providers/cloudstack/security_groups.py
+++ b/ec2stack/providers/cloudstack/security_groups.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to security
+groups
+"""
+
from ec2stack import helpers, errors
from ec2stack.providers import cloudstack
from ec2stack.core import Ec2stackError
@@ -62,8 +66,8 @@
)
elif 'Unable to find security group' in response['errortext']:
errors.invalid_security_group()
-
- errors.invalid_parameter_value(response['errortext'])
+ else:
+ errors.invalid_request(response['errortext'])
else:
if rule_type == 'ingress':
rule_type = 'AuthorizeSecurityGroupIngressResponse'
@@ -280,12 +284,12 @@
def _find_rule(rule, rule_type):
- # TODO @imduffy15 commenting.
"""
+ Searches a Cloudstack response for a rule and returns its Id.
- @param rule:
- @param rule_type:
- @return:
+ @param rule: Rule to be found.
+ @param rule_type: Type of rule.
+ @return: Id of the rule.
"""
security_group = _get_security_group(rule)
@@ -300,12 +304,12 @@
def _compare_rules(left, right):
- # TODO @imduffy15 commenting.
"""
+ Compares two rules to see if they are the same.
- @param left:
- @param right:
- @return:
+ @param left: rule to be compared.
+ @param right: rule to compare with.
+ @return: Boolean
"""
protocol_match = str(left['protocol']) == str(right['protocol'])
cidr_match = str(left['cidrlist']) == str(right['cidr'])
@@ -343,11 +347,11 @@
def _parse_security_group_request(args=None):
- # TODO @imduffy15 commenting.
"""
+ Parse the request parameters into a Cloudstack request payload.
- @param args:
- @return:
+ @param args: Arguments to include in the request.
+ @return: Request payload.
"""
if args is None:
args = {}
diff --git a/ec2stack/providers/cloudstack/service_offerings.py b/ec2stack/providers/cloudstack/service_offerings.py
index fca3c07..feddee6 100644
--- a/ec2stack/providers/cloudstack/service_offerings.py
+++ b/ec2stack/providers/cloudstack/service_offerings.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to service
+offerings
+"""
+
from ec2stack import errors
from ec2stack.providers import cloudstack
diff --git a/ec2stack/providers/cloudstack/volumes.py b/ec2stack/providers/cloudstack/volumes.py
index a94b5bd..06c9935 100644
--- a/ec2stack/providers/cloudstack/volumes.py
+++ b/ec2stack/providers/cloudstack/volumes.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to volumes
+"""
+
import uuid
from flask import current_app
diff --git a/ec2stack/providers/cloudstack/zones.py b/ec2stack/providers/cloudstack/zones.py
index 0c108eb..be49b85 100644
--- a/ec2stack/providers/cloudstack/zones.py
+++ b/ec2stack/providers/cloudstack/zones.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module contains functions for handling requests in relation to zones
+"""
+
from ec2stack.providers import cloudstack
from ec2stack import helpers, errors
diff --git a/ec2stack/secretkey_manager.py b/ec2stack/secretkey_manager.py
index 2077ebf..8598175 100644
--- a/ec2stack/secretkey_manager.py
+++ b/ec2stack/secretkey_manager.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module provides functions to register AWSAccessKeyIds and AWSSecretKeys
+"""
+
import argparse
from xml.dom.minidom import parseString as xmlparse
diff --git a/ec2stack/services.py b/ec2stack/services.py
index a2b331d..2761cc8 100644
--- a/ec2stack/services.py
+++ b/ec2stack/services.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8
+"""This module creates services for all models.
+"""
+
from ec2stack.models.users import UsersService
diff --git a/tests/instances_tests.py b/tests/instances_tests.py
index 6401d54..f1986c2 100644
--- a/tests/instances_tests.py
+++ b/tests/instances_tests.py
@@ -540,4 +540,4 @@
)
self.assert_bad_request(response)
- assert 'InvalidParameterValue' in response.data
+ assert 'InvalidRequest' in response.data
diff --git a/tests/security_group_tests.py b/tests/security_group_tests.py
index c948fa1..f276907 100644
--- a/tests/security_group_tests.py
+++ b/tests/security_group_tests.py
@@ -157,7 +157,7 @@
)
self.assert_bad_request(response)
- assert 'InvalidParameterValue' in response.data
+ assert 'InvalidRequest' in response.data
def test_invalid_security_group_authorize_security_group(self):
data = self.get_example_data()