diff --git a/lower-constraints.txt b/lower-constraints.txt index cf61fc210..5e19648f3 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -9,12 +9,11 @@ decorator==3.4.0 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 future==0.16.0 gabbi==1.35.0 gitdb2==2.0.3 GitPython==2.1.8 -hacking==0.12.0 +hacking==4.0.0 iso8601==0.1.11 Jinja2==2.10 jsonpath-rw==1.4.0 @@ -25,7 +24,6 @@ keystonemiddleware==4.18.0 linecache2==1.0.0 Mako==1.0.7 MarkupSafe==1.1.1 -mccabe==0.2.1 microversion-parse==0.2.1 monotonic==1.4 mox3==0.20.0 @@ -57,7 +55,6 @@ prettytable==0.7.1 psycopg2==2.8 py==1.5.2 pycadf==2.7.0 -pyflakes==2.1.1 PyMySQL==0.8.0 pyparsing==2.2.0 pytest==3.4.2 @@ -69,7 +66,7 @@ python-subunit==1.2.0 pytz==2018.3 PyYAML==3.13 repoze.lru==0.7 -requests==2.14.2 +requests==2.25.0 requestsexceptions==1.4.0 rfc3986==0.3.1 Routes==2.3.1 @@ -87,7 +84,6 @@ testscenarios==0.4 testtools==2.2.0 traceback2==1.4.0 unittest2==1.1.0 -urllib3==1.22 WebOb==1.8.2 wrapt==1.10.11 wsgi-intercept==1.7.0 diff --git a/placement/conf/database.py b/placement/conf/database.py index ace868467..a37062716 100644 --- a/placement/conf/database.py +++ b/placement/conf/database.py @@ -34,6 +34,7 @@ def enrich_help_text(alt_db_opts): # texts here if needed. alt_db_opt.help = db_opt.help + alt_db_opt.help + # NOTE(markus_z): We cannot simply do: # conf.register_opts(oslo_db_options.database_opts, 'placement_database') # If we reuse a db config option for two different groups ("placement_database" @@ -55,48 +56,62 @@ not start. """) placement_db_opts = [ - cfg.StrOpt('connection', + cfg.StrOpt( + 'connection', help='', required=True, secret=True), - cfg.StrOpt('connection_parameters', + cfg.StrOpt( + 'connection_parameters', default='', help=''), - cfg.BoolOpt('sqlite_synchronous', + cfg.BoolOpt( + 'sqlite_synchronous', default=True, help=''), - cfg.StrOpt('slave_connection', + cfg.StrOpt( + 'slave_connection', secret=True, help=''), - cfg.StrOpt('mysql_sql_mode', + cfg.StrOpt( + 'mysql_sql_mode', default='TRADITIONAL', help=''), - cfg.IntOpt('connection_recycle_time', + cfg.IntOpt( + 'connection_recycle_time', default=3600, help=''), - cfg.IntOpt('max_pool_size', + cfg.IntOpt( + 'max_pool_size', help=''), - cfg.IntOpt('max_retries', + cfg.IntOpt( + 'max_retries', default=10, help=''), - cfg.IntOpt('retry_interval', + cfg.IntOpt( + 'retry_interval', default=10, help=''), - cfg.IntOpt('max_overflow', + cfg.IntOpt( + 'max_overflow', help=''), - cfg.IntOpt('connection_debug', + cfg.IntOpt( + 'connection_debug', default=0, help=''), - cfg.BoolOpt('connection_trace', + cfg.BoolOpt( + 'connection_trace', default=False, help=''), - cfg.IntOpt('pool_timeout', + cfg.IntOpt( + 'pool_timeout', help=''), - cfg.BoolOpt('sync_on_startup', + cfg.BoolOpt( + 'sync_on_startup', default=False, help='If True, database schema migrations will be attempted when the' ' web service starts.'), -] # noqa +] def register_opts(conf): diff --git a/placement/direct.py b/placement/direct.py index 9bb681c19..fa35ce9da 100644 --- a/placement/direct.py +++ b/placement/direct.py @@ -59,7 +59,10 @@ class PlacementDirect(interceptor.RequestsInterceptor): def __init__(self, conf, latest_microversion=False): conf.set_override('auth_strategy', 'noauth2', group='api') - app = lambda: deploy.loadapp(conf) + + def app(): + return deploy.loadapp(conf) + self.url = 'http://%s/placement' % str(uuidutils.generate_uuid()) # Supply our own session so the wsgi-intercept can intercept # the right thing. diff --git a/placement/handlers/trait.py b/placement/handlers/trait.py index a92ec601f..4def62757 100644 --- a/placement/handlers/trait.py +++ b/placement/handlers/trait.py @@ -96,8 +96,8 @@ def put_trait(req): if want_version.matches((1, 15)): # If the TraitExists exception was hit above, created_at is None # so fall back to now for the last modified header. - last_modified = (trait.created_at - or timeutils.utcnow(with_timezone=True)) + last_modified = (trait.created_at or + timeutils.utcnow(with_timezone=True)) req.response.last_modified = last_modified req.response.cache_control = 'no-cache' return req.response diff --git a/placement/objects/allocation_candidate.py b/placement/objects/allocation_candidate.py index 3bf332588..5322bc53c 100644 --- a/placement/objects/allocation_candidate.py +++ b/placement/objects/allocation_candidate.py @@ -203,8 +203,8 @@ class AllocationRequest(object): return repr_str def __eq__(self, other): - return (set(self.resource_requests) == set(other.resource_requests) - and self.mappings == other.mappings) + return (set(self.resource_requests) == set(other.resource_requests) and + self.mappings == other.mappings) def __hash__(self): # We need a stable sort order on the resource requests to get an diff --git a/placement/requestlog.py b/placement/requestlog.py index a85bbf81a..3b59cb771 100644 --- a/placement/requestlog.py +++ b/placement/requestlog.py @@ -36,10 +36,6 @@ class RequestLog(request_id.RequestId): This also guards against a missing "Accept" header. """ - format = ('%(REMOTE_ADDR)s "%(REQUEST_METHOD)s %(REQUEST_URI)s" ' - 'status: %(status)s len: %(bytes)s ' - 'microversion: %(microversion)s') - def __init__(self, application): self.application = application @@ -108,13 +104,13 @@ class RequestLog(request_id.RequestId): """ if size is None: size = '-' - log_format = { - 'REMOTE_ADDR': environ.get('REMOTE_ADDR', '-'), - 'REQUEST_METHOD': environ['REQUEST_METHOD'], - 'REQUEST_URI': req_uri, - 'status': status.split(None, 1)[0], - 'bytes': size, - 'microversion': environ.get( - microversion.MICROVERSION_ENVIRON, '-'), - } - LOG.info(self.format, log_format) + LOG.info('%(REMOTE_ADDR)s "%(REQUEST_METHOD)s %(REQUEST_URI)s" ' + 'status: %(status)s len: %(bytes)s ' + 'microversion: %(microversion)s', + {'REMOTE_ADDR': environ.get('REMOTE_ADDR', '-'), + 'REQUEST_METHOD': environ['REQUEST_METHOD'], + 'REQUEST_URI': req_uri, + 'status': status.split(None, 1)[0], + 'bytes': size, + 'microversion': environ.get( + microversion.MICROVERSION_ENVIRON, '-')}) diff --git a/placement/tests/functional/fixtures/placement.py b/placement/tests/functional/fixtures/placement.py index f021ea36c..6142354be 100644 --- a/placement/tests/functional/fixtures/placement.py +++ b/placement/tests/functional/fixtures/placement.py @@ -79,7 +79,10 @@ class PlacementFixture(fixtures.Fixture): if self.use_intercept: loader = deploy.loadapp(self.conf_fixture.conf) - app = lambda: loader + + def app(): + return loader + self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid() intercept = interceptor.RequestsInterceptor(app, url=self.endpoint) intercept.install_intercept() diff --git a/requirements.txt b/requirements.txt index bdbe52cb7..f1f55d4b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ keystonemiddleware>=4.18.0 # Apache-2.0 Routes>=2.3.1 # MIT WebOb>=1.8.2 # MIT jsonschema>=3.2.0 # MIT -requests>=2.14.2 # Apache-2.0 +requests>=2.25.0 # Apache-2.0 setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0.0 # PSF/ZPL oslo.concurrency>=3.26.0 # Apache-2.0 oslo.config>=6.7.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index 890d52e85..12c74efea 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,11 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 -# remove this pyflakes from here once you bump the -# hacking to 3.2.0 or above. hacking 3.2.0 takes -# care of pyflakes version compatibilty. -pyflakes>=2.1.1 +hacking>=4.0.0,<4.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index 71e9fbce4..d16e128da 100644 --- a/tox.ini +++ b/tox.ini @@ -155,12 +155,13 @@ commands = bandit -r placement -x tests -n 5 -ll enable-extensions = H106,H203,H904 # H405 is a good guideline, but sometimes multiline doc strings just don't have # a natural summary line. Rejecting code for this reason is wrong. -ignore = H405 +# W504 skipped since you must choose either W503 or W504 (they conflict) +ignore = H405, W504 exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,releasenotes -# To get a list of functions that have a complexity of 17 or more, set -# max-complexity to 17 and run 'tox -epep8'. -# 16 is currently the most complex thing we have -max-complexity=17 +# To get a list of functions that have a complexity of 19 or more, set +# max-complexity to 19 and run 'tox -epep8'. +# 19 is currently the most complex thing we have +max-complexity=19 [testenv:bindep] # Do not install any requirements. We want this to be fast and work even if