Merge "Fix flake8 errors"
This commit is contained in:
commit
702c6b783b
@ -14,6 +14,7 @@
|
||||
|
||||
from keystoneauth1.identity import v3
|
||||
from keystoneauth1 import session
|
||||
from oslo_log import log as logging
|
||||
|
||||
from deckhand.conf import config
|
||||
from deckhand import errors
|
||||
@ -22,6 +23,7 @@ from barbicanclient import barbican
|
||||
from barbicanclient import exceptions as barbican_exc
|
||||
|
||||
CONF = config.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BarbicanClientWrapper(object):
|
||||
@ -41,8 +43,8 @@ class BarbicanClientWrapper(object):
|
||||
if retry_on_conflict and self._cached_client is not None:
|
||||
return self._cached_client
|
||||
|
||||
# TODO: Deckhand's configuration file needs to be populated with
|
||||
# correct Keysone authentication values as well as the Barbican
|
||||
# TODO(fmontei): Deckhand's configuration file needs to be populated
|
||||
# with correct Keysone authentication values as well as the Barbican
|
||||
# endpoint URL automatically.
|
||||
barbican_url = (CONF.barbican.api_endpoint
|
||||
if CONF.barbican.api_endpoint
|
||||
@ -53,7 +55,7 @@ class BarbicanClientWrapper(object):
|
||||
sess = session.Session(auth=auth)
|
||||
|
||||
try:
|
||||
# TODO: replace with ``barbican_url``.
|
||||
# TODO(fmontei): replace with ``barbican_url``.
|
||||
cli = barbican.client.Client(endpoint=barbican_url,
|
||||
session=sess)
|
||||
# Cache the client so we don't have to reconstruct and
|
||||
@ -63,7 +65,7 @@ class BarbicanClientWrapper(object):
|
||||
|
||||
except barbican_exc.HTTPAuthError:
|
||||
msg = _("Unable to authenticate Barbican client.")
|
||||
# TODO: Log the error.
|
||||
# TODO(fmontei): Log the error.
|
||||
raise errors.ApiError(msg)
|
||||
|
||||
return cli
|
||||
@ -106,9 +108,8 @@ class BarbicanClientWrapper(object):
|
||||
# client and the next try will start with a fresh one.
|
||||
if not attempt:
|
||||
self._invalidate_cached_client()
|
||||
# TODO: include after implementing oslo.log.
|
||||
# LOG.debug("The Barbican client became unauthorized. "
|
||||
# "Will attempt to reauthorize and try again.")
|
||||
LOG.debug("The Barbican client became unauthorized. "
|
||||
"Will attempt to reauthorize and try again.")
|
||||
else:
|
||||
# This code should be unreachable actually
|
||||
raise
|
||||
|
@ -37,7 +37,7 @@ def __setup_logging():
|
||||
|
||||
logging.register_options(CONF)
|
||||
config.parse_args()
|
||||
|
||||
|
||||
current_path = os.path.dirname(os.path.realpath(__file__))
|
||||
root_path = os.path.abspath(os.path.join(current_path, os.pardir,
|
||||
os.pardir))
|
||||
|
@ -26,6 +26,6 @@ class ViewBuilder(object):
|
||||
_collection_name = None
|
||||
|
||||
def _gen_url(self, revision):
|
||||
# TODO: Use a config-based url for the base url below.
|
||||
# TODO(fmontei): Use a config-based url for the base url below.
|
||||
base_url = 'https://deckhand/api/v1.0/%s/%s'
|
||||
return base_url % (self._collection_name, revision.get('id'))
|
||||
|
@ -12,14 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import yaml
|
||||
|
||||
import falcon
|
||||
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from deckhand.control import base as api_base
|
||||
from deckhand.db.sqlalchemy import api as db_api
|
||||
|
@ -13,7 +13,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
import falcon
|
||||
from oslo_db import exception as db_exc
|
||||
|
||||
from deckhand.control import base as api_base
|
||||
from deckhand.db.sqlalchemy import api as db_api
|
||||
@ -25,7 +24,7 @@ class RevisionDocumentsResource(api_base.BaseResource):
|
||||
|
||||
def on_get(self, req, resp, revision_id):
|
||||
"""Returns all documents for a `revision_id`.
|
||||
|
||||
|
||||
Returns a multi-document YAML response containing all the documents
|
||||
matching the filters specified via query string parameters. Returned
|
||||
documents will be as originally posted with no substitutions or
|
||||
|
@ -25,7 +25,7 @@ class RevisionsResource(api_base.BaseResource):
|
||||
|
||||
def on_get(self, req, resp, revision_id=None):
|
||||
"""Returns list of existing revisions.
|
||||
|
||||
|
||||
Lists existing revisions and reports basic details including a summary
|
||||
of validation status for each `deckhand/ValidationPolicy` that is part
|
||||
of each revision.
|
||||
|
@ -62,7 +62,7 @@ class ViewBuilder(common.ViewBuilder):
|
||||
'id': revision.get('id'),
|
||||
'createdAt': revision.get('created_at'),
|
||||
'url': self._gen_url(revision),
|
||||
# TODO: Not yet implemented.
|
||||
# TODO(fmontei): Not yet implemented.
|
||||
'validationPolicies': validation_policies,
|
||||
'status': success_status
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import ast
|
||||
import copy
|
||||
import datetime
|
||||
import threading
|
||||
|
||||
from oslo_config import cfg
|
||||
@ -25,16 +24,8 @@ from oslo_db import exception as db_exception
|
||||
from oslo_db import options
|
||||
from oslo_db.sqlalchemy import session
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
import six
|
||||
from six.moves import range
|
||||
import sqlalchemy
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
from sqlalchemy import desc
|
||||
from sqlalchemy import MetaData, Table
|
||||
import sqlalchemy.orm as sa_orm
|
||||
from sqlalchemy import sql
|
||||
import sqlalchemy.sql as sa_sql
|
||||
|
||||
from deckhand.db.sqlalchemy import models
|
||||
from deckhand import errors
|
||||
@ -82,22 +73,6 @@ def get_session(autocommit=True, expire_on_commit=False):
|
||||
expire_on_commit=expire_on_commit)
|
||||
|
||||
|
||||
def _validate_db_int(**kwargs):
|
||||
"""Make sure that all arguments are less than or equal to 2 ** 31 - 1.
|
||||
This limitation is introduced because databases stores INT in 4 bytes.
|
||||
If the validation fails for some argument, exception. Invalid is raised
|
||||
with appropriate information.
|
||||
"""
|
||||
max_int = (2 ** 31) - 1
|
||||
|
||||
for param_key, param_value in kwargs.items():
|
||||
if param_value and param_value > max_int:
|
||||
msg = _("'%(param)s' value out of range, "
|
||||
"must not exceed %(max)d.") % {"param": param_key,
|
||||
"max": max_int}
|
||||
raise exception.Invalid(msg)
|
||||
|
||||
|
||||
def clear_db_env():
|
||||
"""Unset global configuration variables for database."""
|
||||
global _FACADE
|
||||
@ -255,7 +230,7 @@ def _filter_revision_documents(documents, **filters):
|
||||
|
||||
:returns: list of documents that match specified filters.
|
||||
"""
|
||||
# TODO: Implement this as an sqlalchemy query.
|
||||
# TODO(fmontei): Implement this as an sqlalchemy query.
|
||||
filtered_documents = []
|
||||
|
||||
for document in documents:
|
||||
|
@ -23,12 +23,9 @@ from sqlalchemy import DateTime
|
||||
from sqlalchemy.ext import declarative
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy import Integer
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import backref, relationship
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy import schema
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import Text
|
||||
from sqlalchemy.types import TypeDecorator
|
||||
|
||||
|
||||
# Declarative base class which maintains a catalog of classes and tables
|
||||
@ -121,7 +118,8 @@ class Revision(BASE, DeckhandBase):
|
||||
|
||||
class DocumentMixin(object):
|
||||
"""Mixin class for sharing common columns across all document resources
|
||||
such as documents themselves, layering policies and validation policies."""
|
||||
such as documents themselves, layering policies and validation policies.
|
||||
"""
|
||||
|
||||
name = Column(String(64), nullable=False)
|
||||
schema = Column(String(64), nullable=False)
|
||||
|
@ -120,7 +120,7 @@ class DocumentValidation(object):
|
||||
validation_policy_factory = factories.ValidationPolicyFactory()
|
||||
|
||||
for document in self.documents:
|
||||
document_validations = self._validate_one(document)
|
||||
self._validate_one(document)
|
||||
|
||||
deckhand_schema_validation = validation_policy_factory.gen(
|
||||
types.DECKHAND_SCHEMA_VALIDATION, status='success')
|
||||
@ -156,12 +156,12 @@ class DocumentValidation(object):
|
||||
document_type=document['schema'])
|
||||
else:
|
||||
LOG.info('Skipping schema validation for abstract '
|
||||
'document: %s.' % document)
|
||||
'document: %s.', document)
|
||||
|
||||
def _is_abstract(self, document):
|
||||
try:
|
||||
is_abstract = document['metadata']['layeringDefinition'][
|
||||
'abstract'] == True
|
||||
'abstract'] is True
|
||||
return is_abstract
|
||||
# NOTE(fmontei): If the document is of ``document_schema`` type and
|
||||
# no "layeringDefinition" or "abstract" property is found, then treat
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import abc
|
||||
import copy
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -23,8 +24,8 @@ from deckhand import types
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class DeckhandFactory(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def gen(self, *args):
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
import mock
|
||||
|
||||
import falcon
|
||||
from falcon import testing as falcon_testing
|
||||
|
||||
from deckhand.control import api
|
||||
|
@ -17,9 +17,7 @@ import yaml
|
||||
|
||||
import falcon
|
||||
|
||||
from deckhand.control import api
|
||||
from deckhand.tests.functional import base as test_base
|
||||
from deckhand import types
|
||||
|
||||
|
||||
class TestDocumentsApi(test_base.TestFunctionalBase):
|
||||
@ -38,10 +36,6 @@ class TestDocumentsApi(test_base.TestFunctionalBase):
|
||||
result = self.app.simulate_post('/api/v1.0/documents', body=yaml_data)
|
||||
self.assertEqual(falcon.HTTP_201, result.status)
|
||||
|
||||
expected_documents = [yaml.safe_load(yaml_data)]
|
||||
expected_validation_policy = self.validation_policy_factory.gen(
|
||||
types.DECKHAND_SCHEMA_VALIDATION, status='success')
|
||||
|
||||
# Validate that the correct number of documents were created: one
|
||||
# document corresponding to ``yaml_data``.
|
||||
resp_documents = [d for d in yaml.safe_load_all(result.text)]
|
||||
|
@ -17,9 +17,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import testtools
|
||||
|
||||
from deckhand.conf import config
|
||||
from deckhand.db.sqlalchemy import api as db_api
|
||||
from deckhand.db.sqlalchemy import models as db_models
|
||||
|
||||
CONF = cfg.CONF
|
||||
logging.register_options(CONF)
|
||||
|
@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
|
||||
from deckhand.db.sqlalchemy import api as db_api
|
||||
|
@ -12,8 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from deckhand.tests.unit.db import base
|
||||
from deckhand import factories
|
||||
from deckhand.tests.unit.db import base
|
||||
from deckhand import types
|
||||
|
||||
|
||||
|
@ -16,11 +16,6 @@ import copy
|
||||
import os
|
||||
import yaml
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from deckhand.engine import document_validation
|
||||
from deckhand import errors
|
||||
from deckhand.tests.unit import base as test_base
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
---
|
||||
schema: deckhand/LayeringPolicy/v1.0
|
||||
metadata:
|
||||
schema: metadata/Control/v1
|
||||
schema: metadata/Control/v1.0
|
||||
name: a-unique-config-name-12345
|
||||
data:
|
||||
layerOrder:
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
from deckhand.control.views import revision
|
||||
from deckhand import factories
|
||||
from deckhand.tests.unit.db import base
|
||||
from deckhand.tests import test_utils
|
||||
from deckhand.tests.unit.db import base
|
||||
from deckhand import types
|
||||
|
||||
|
||||
@ -103,9 +103,6 @@ class TestRevisionViews(base.TestDbBase):
|
||||
|
||||
expected_attrs = ('id', 'url', 'createdAt', 'validationPolicies',
|
||||
'status')
|
||||
expected_validation_policies = [
|
||||
{'name': 'deckhand-schema-validation'}, 'status'
|
||||
]
|
||||
|
||||
for attr in expected_attrs:
|
||||
self.assertIn(attr, revision_view)
|
||||
@ -118,7 +115,6 @@ class TestRevisionViews(base.TestDbBase):
|
||||
self.assertEqual(revision_view['validationPolicies'][0]['status'],
|
||||
'success')
|
||||
|
||||
|
||||
def test_show_revision_failed_validation_policy(self):
|
||||
# Simulate 4 document payload with an internally generated validation
|
||||
# policy which executes 'deckhand-schema-validation'.
|
||||
@ -134,9 +130,6 @@ class TestRevisionViews(base.TestDbBase):
|
||||
|
||||
expected_attrs = ('id', 'url', 'createdAt', 'validationPolicies',
|
||||
'status')
|
||||
expected_validation_policies = [
|
||||
{'name': 'deckhand-schema-validation'}, 'status'
|
||||
]
|
||||
|
||||
for attr in expected_attrs:
|
||||
self.assertIn(attr, revision_view)
|
||||
|
@ -1,3 +1,10 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||
|
||||
falcon==1.1.0
|
||||
|
||||
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
|
||||
|
@ -1,3 +1,10 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||
|
||||
falcon==1.1.0
|
||||
|
||||
mock>=2.0
|
||||
|
5
tox.ini
5
tox.ini
@ -47,5 +47,6 @@ commands = flake8 {posargs}
|
||||
[flake8]
|
||||
# D100-104 deal with docstrings in public functions
|
||||
# D205, D400, D401 deal with docstring formatting
|
||||
ignore=E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405,D100,D101,D102,D103,D104,D205,D400,D401,H101,I100
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools/xenserver*,releasenotes
|
||||
enable-extensions = H106,H203,H904
|
||||
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405
|
||||
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools/xenserver*,releasenotes
|
||||
|
Loading…
x
Reference in New Issue
Block a user