diff --git a/magnum/api/controllers/v1/__init__.py b/magnum/api/controllers/v1/__init__.py index f312b62bd5..9364872fe9 100644 --- a/magnum/api/controllers/v1/__init__.py +++ b/magnum/api/controllers/v1/__init__.py @@ -60,7 +60,7 @@ MIN_VER = controllers_base.Version( {controllers_base.Version.string: MIN_VER_STR}, MIN_VER_STR, MAX_VER_STR) MAX_VER = controllers_base.Version( {controllers_base.Version.string: MAX_VER_STR}, - MIN_VER_STR, MAX_VER_STR) + MIN_VER_STR, MAX_VER_STR) class MediaType(controllers_base.APIBase): diff --git a/magnum/api/hooks.py b/magnum/api/hooks.py index e9f86ce7be..b09662d133 100644 --- a/magnum/api/hooks.py +++ b/magnum/api/hooks.py @@ -86,6 +86,7 @@ class RPCHook(hooks.PecanHook): class NoExceptionTracebackHook(hooks.PecanHook): """Workaround rpc.common: deserialize_remote_exception. + deserialize_remote_exception builds rpc exception traceback into error message which is then sent to the client. Such behavior is a security concern so this hook is aimed to cut-off traceback from the error message. diff --git a/magnum/common/k8s_manifest.py b/magnum/common/k8s_manifest.py index 34e0e7e61f..64c19546d3 100644 --- a/magnum/common/k8s_manifest.py +++ b/magnum/common/k8s_manifest.py @@ -33,6 +33,7 @@ def _construct_yaml_str(self, node): def parse(manifest_str): '''Takes a string and returns a dict containing the parsed structure. + This includes determination of whether the string is using the JSON or YAML format. ''' diff --git a/magnum/common/policy.py b/magnum/common/policy.py index 302e587f5b..d040ea456d 100644 --- a/magnum/common/policy.py +++ b/magnum/common/policy.py @@ -96,6 +96,7 @@ def enforce(context, action=None, target=None, # decorator) on an API method for it to work correctly def enforce_wsgi(api_name, act=None): """This is a decorator to simplify wsgi action policy rule check. + :param api_name: The collection name to be evaluate. :param act: The function name of wsgi action. diff --git a/magnum/conductor/bay_lock.py b/magnum/conductor/bay_lock.py index 08c6aa4cfa..38e1150835 100644 --- a/magnum/conductor/bay_lock.py +++ b/magnum/conductor/bay_lock.py @@ -117,6 +117,7 @@ class BayLock(object): @contextlib.contextmanager def thread_lock(self, bay_uuid): """Acquire a lock and release it only if there is an exception. + The release method still needs to be scheduled to be run at the end of the thread using the Thread.link method. """ diff --git a/magnum/conductor/handlers/ca_conductor.py b/magnum/conductor/handlers/ca_conductor.py index 8ee4122c03..0376a8828a 100644 --- a/magnum/conductor/handlers/ca_conductor.py +++ b/magnum/conductor/handlers/ca_conductor.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Magnum CA RPC handler.""" from oslo_log import log as logging @@ -22,9 +21,10 @@ LOG = logging.getLogger(__name__) class Handler(object): - """These are the backend operations. They are executed by the backend - service. API calls via AMQP (within the ReST API) trigger the - handlers to be called. + """Magnum CA RPC handler. + + These are the backend operations. They are executed by the backend service. + API calls via AMQP (within the ReST API) trigger the handlers to be called. """ diff --git a/magnum/conductor/handlers/conductor_listener.py b/magnum/conductor/handlers/conductor_listener.py index 7ef907ee8e..d343caa0a2 100644 --- a/magnum/conductor/handlers/conductor_listener.py +++ b/magnum/conductor/handlers/conductor_listener.py @@ -12,11 +12,15 @@ class Handler(object): - '''Listen on an AMQP queue named for the conductor. Allows individual - conductors to communicate with each other for multi-conductor support. + '''Listen on an AMQP queue named for the conductor. + + Allows individual conductors to communicate with each other for + multi-conductor support. ''' def ping_conductor(self, context): - '''Respond affirmatively to confirm that the conductor performing the + '''Respond to conductor. + + Respond affirmatively to confirm that the conductor performing the action is still alive. ''' return True diff --git a/magnum/conductor/handlers/k8s_conductor.py b/magnum/conductor/handlers/k8s_conductor.py index 9b0990d75e..a42e8f4aca 100644 --- a/magnum/conductor/handlers/k8s_conductor.py +++ b/magnum/conductor/handlers/k8s_conductor.py @@ -10,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Magnum Kubernetes RPC handler.""" from oslo_log import log as logging @@ -26,9 +25,10 @@ LOG = logging.getLogger(__name__) class Handler(object): - """These are the backend operations. They are executed by the backend - service. API calls via AMQP (within the ReST API) trigger the - handlers to be called. + """Magnum Kubernetes RPC handler. + + These are the backend operations. They are executed by the backend service. + API calls via AMQP (within the ReST API) trigger the handlers to be called. """ diff --git a/magnum/conductor/handlers/x509keypair_conductor.py b/magnum/conductor/handlers/x509keypair_conductor.py index 3453254684..120d3e3c91 100644 --- a/magnum/conductor/handlers/x509keypair_conductor.py +++ b/magnum/conductor/handlers/x509keypair_conductor.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Magnum X509KeyPair RPC handler.""" from oslo_log import log as logging @@ -22,9 +21,10 @@ LOG = logging.getLogger(__name__) class Handler(object): - """These are the backend operations. They are executed by the backend - service. API calls via AMQP (within the ReST API) trigger the - handlers to be called. + """Magnum X509KeyPair RPC handler. + + These are the backend operations. They are executed by the backend service. + API calls via AMQP (within the ReST API) trigger the handlers to be called. """ diff --git a/magnum/conductor/template_definition.py b/magnum/conductor/template_definition.py index c8485d875e..3bb71de65b 100644 --- a/magnum/conductor/template_definition.py +++ b/magnum/conductor/template_definition.py @@ -82,7 +82,9 @@ cfg.CONF.register_opts(template_def_opts, group='bay') class ParameterMapping(object): - """A ParameterMapping is an association of a Heat parameter name with + """A mapping associating heat param and bay/baymodel attr. + + A ParameterMapping is an association of a Heat parameter name with an attribute on a Bay, Baymodel, or both. In the case of both baymodel_attr and bay_attr being set, the Baymodel @@ -120,7 +122,9 @@ class ParameterMapping(object): class OutputMapping(object): - """An OutputMapping is an association of a Heat output with a key + """A mapping associating heat outputs and bay attr. + + An OutputMapping is an association of a Heat output with a key Magnum understands. """ @@ -150,7 +154,9 @@ class OutputMapping(object): @six.add_metaclass(abc.ABCMeta) class TemplateDefinition(object): - '''A TemplateDefinition is essentially a mapping between Magnum objects + '''A mapping between Magnum objects and Heat templates. + + A TemplateDefinition is essentially a mapping between Magnum objects and Heat templates. Each TemplateDefinition has a mapping of Heat parameters. ''' @@ -215,7 +221,9 @@ class TemplateDefinition(object): @classmethod def get_template_definition(cls, server_type, os, coe): - '''Returns the enabled TemplateDefinition class for the provided + '''Get enabled TemplateDefinitions. + + Returns the enabled TemplateDefinition class for the provided bay_type. With the following classes: @@ -300,7 +308,9 @@ class TemplateDefinition(object): return template_params def get_heat_param(self, bay_attr=None, baymodel_attr=None): - """Returns stack param name using bay and baymodel attributes + """Returns stack param name. + + Return stack param name using bay and baymodel attributes :param bay_attr bay attribute from which it maps to stack attribute :param baymodel_attr baymodel attribute from which it maps to stack attribute diff --git a/magnum/objects/base.py b/magnum/objects/base.py index 320ee9f621..8f2e81c591 100644 --- a/magnum/objects/base.py +++ b/magnum/objects/base.py @@ -54,6 +54,7 @@ class MagnumObjectDictCompat(ovoo_base.VersionedObjectDictCompat): class MagnumPersistentObject(object): """Mixin class for Persistent objects. + This adds the fields that we use in common for all persistent objects. """ fields = { diff --git a/magnum/objects/replicationcontroller.py b/magnum/objects/replicationcontroller.py index 84fae81393..762b3bfb4d 100644 --- a/magnum/objects/replicationcontroller.py +++ b/magnum/objects/replicationcontroller.py @@ -63,7 +63,9 @@ class ReplicationController(base.MagnumPersistentObject, base.MagnumObject, @base.remotable_classmethod def get_by_id(cls, context, rc_id): - """Find a ReplicationController based on its integer id and return a + """Find a ReplicationController based on its integer id. + + Find ReplicationController based on id and return a ReplicationController object. :param rc_id: the id of a ReplicationController. @@ -75,8 +77,10 @@ class ReplicationController(base.MagnumPersistentObject, base.MagnumObject, @base.remotable_classmethod def get_by_uuid(cls, context, uuid): - """Find a ReplicationController based on uuid and return - a :class:`ReplicationController` object. + """Find a ReplicationController based on uuid. + + Find ReplicationController by uuid and return a + :class:`ReplicationController` object. :param uuid: the uuid of a ReplicationController. :param context: Security context @@ -88,8 +92,10 @@ class ReplicationController(base.MagnumPersistentObject, base.MagnumObject, @base.remotable_classmethod def get_by_name(cls, context, name): - """Find a ReplicationController based on name and return - a :class:`ReplicationController` object. + """Find a ReplicationController based on name. + + Find ReplicationController by name and return a + :class:`ReplicationController` object. :param name: the name of a ReplicationController. :param context: Security context diff --git a/magnum/objects/service.py b/magnum/objects/service.py index beab00f26a..88d3139476 100644 --- a/magnum/objects/service.py +++ b/magnum/objects/service.py @@ -89,6 +89,7 @@ class Service(base.MagnumPersistentObject, base.MagnumObject, @base.remotable_classmethod def get_by_name(cls, context, name): """Find a service based on service name and + return a :class:`Service` object. :param name: the name of a service. diff --git a/magnum/objects/x509keypair.py b/magnum/objects/x509keypair.py index f734cd4cfb..4ae1e8f2b1 100644 --- a/magnum/objects/x509keypair.py +++ b/magnum/objects/x509keypair.py @@ -58,8 +58,9 @@ class X509KeyPair(base.MagnumPersistentObject, base.MagnumObject, @base.remotable_classmethod def get(cls, context, x509keypair_id): - """Find a x509keypair_id based on its id or uuid and return a - X509KeyPair object. + """Find a X509KeyPair based on its id or uuid. + + Find X509KeyPair by id or uuid and return a X509KeyPair object. :param x509keypair_id: the id *or* uuid of a x509keypair. :returns: a :class:`X509KeyPair` object. @@ -73,8 +74,9 @@ class X509KeyPair(base.MagnumPersistentObject, base.MagnumObject, @base.remotable_classmethod def get_by_id(cls, context, x509keypair_id): - """Find a x509keypair based on its integer id and return a - X509KeyPair object. + """Find a X509KeyPair based on its integer id. + + Find X509KeyPair by id and return a X509KeyPair object. :param x509keypair_id: the id of a x509keypair. :returns: a :class:`X509KeyPair` object. diff --git a/magnum/tests/functional/common/client.py b/magnum/tests/functional/common/client.py index 866d62409d..98c959ba67 100644 --- a/magnum/tests/functional/common/client.py +++ b/magnum/tests/functional/common/client.py @@ -38,8 +38,7 @@ class BaseMagnumClient(rest_client.RestClient): class MagnumClient(BaseMagnumClient): - """Responsible for setting up auth provider for default user - """ + """Responsible for setting up auth provider for default user""" def get_auth_provider(self): mgr = manager.Manager() diff --git a/magnum/tests/unit/api/base.py b/magnum/tests/unit/api/base.py index 2e2a514eb6..73895081f3 100644 --- a/magnum/tests/unit/api/base.py +++ b/magnum/tests/unit/api/base.py @@ -12,7 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Base classes for API tests.""" # NOTE: Ported from ceilometer/tests/api.py (subsequently moved to # ceilometer/tests/api/__init__.py). This should be oslo'ified: @@ -33,8 +32,10 @@ PATH_PREFIX = '/v1' class FunctionalTest(base.DbTestCase): - """Used for functional tests of Pecan controllers where you need to - test your literal application and its integration with the + """Base class for API tests. + + Pecan controller test. Used for functional tests of Pecan controllers where + you need to test your literal application and its integration with the framework. """ diff --git a/magnum/tests/unit/db/utils.py b/magnum/tests/unit/db/utils.py index c96adcf812..4fff74cb23 100644 --- a/magnum/tests/unit/db/utils.py +++ b/magnum/tests/unit/db/utils.py @@ -58,6 +58,7 @@ def get_test_baymodel(**kw): def create_test_baymodel(**kw): """Create test baymodel entry in DB and return BayModel DB object. + Function to be used to create test BayModel objects in the database. :param kw: kwargs with overriding values for baymodel's attributes. :returns: Test BayModel DB object. @@ -97,6 +98,7 @@ def get_test_bay(**kw): def create_test_bay(**kw): """Create test bay entry in DB and return Bay DB object. + Function to be used to create test Bay objects in the database. :param kw: kwargs with overriding values for bay's attributes. :returns: Test Bay DB object. @@ -129,6 +131,7 @@ def get_test_pod(**kw): def create_test_pod(**kw): """Create test pod entry in DB and return Pod DB object. + Function to be used to create test Pod objects in the database. :param kw: kwargs with overriding values for pod's attributes. :returns: Test Pod DB object. @@ -160,6 +163,7 @@ def get_test_service(**kw): def create_test_service(**kw): """Create test service entry in DB and return Service DB object. + Function to be used to create test Service objects in the database. :param kw: kwargs with overriding values for service's attributes. :returns: Test Service DB object. @@ -188,6 +192,7 @@ def get_test_node(**kw): def create_test_node(**kw): """Create test node entry in DB and return Node DB object. + Function to be used to create test Node objects in the database. :param kw: kwargs with overriding values for node's attributes. :returns: Test Node DB object. @@ -218,6 +223,7 @@ def get_test_container(**kw): def create_test_container(**kw): """Create test container entry in DB and return Container DB object. + Function to be used to create test Container objects in the database. :param kw: kwargs with overriding values for container's attributes. :returns: Test Container DB object. @@ -249,6 +255,7 @@ def get_test_rc(**kw): def create_test_rc(**kw): """Create test rc entry in DB and return ReplicationController DB object. + Function to be used to create test ReplicationController objects in the database. :param kw: kwargs with overriding values for @@ -292,6 +299,7 @@ def get_test_x509keypair(**kw): def create_test_x509keypair(**kw): """Create test x509keypair entry in DB and return X509KeyPair DB object. + Function to be used to create test X509KeyPair objects in the database. :param kw: kwargs with overriding values for x509keypair's attributes. :returns: Test X509KeyPair DB object. diff --git a/magnum/tests/unit/test_hacking.py b/magnum/tests/unit/test_hacking.py index d927137332..f68812bb74 100644 --- a/magnum/tests/unit/test_hacking.py +++ b/magnum/tests/unit/test_hacking.py @@ -21,7 +21,9 @@ from magnum.tests import base class HackingTestCase(base.TestCase): - """This class tests the hacking checks in magnum.hacking.checks by passing + """Hacking test class. + + This class tests the hacking checks in magnum.hacking.checks by passing strings to the check methods like the pep8/flake8 parser would. The parser loops over each line in the file and then passes the parameters to the check method. The parameter names in the check method dictate what type of diff --git a/tox.ini b/tox.ini index 2aca904127..9d9eea38c4 100644 --- a/tox.ini +++ b/tox.ini @@ -55,11 +55,9 @@ commands = [flake8] # E711 is ignored because it is normal to use "column == None" in sqlalchemy -# The rest of the ignores are TODOs -# New from hacking 0.9: E129, E131, H407, H405, H904 # E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301 -ignore = E131,E251,H405,E711 +ignore = E251,E711 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,magnum/common/pythonk8sclient [hacking]