diff --git a/ironic_prometheus_exporter/app/exporter.py b/ironic_prometheus_exporter/app/exporter.py index 8ce2132..c896dfe 100644 --- a/ironic_prometheus_exporter/app/exporter.py +++ b/ironic_prometheus_exporter/app/exporter.py @@ -14,7 +14,11 @@ import configparser import logging import os -from flask import abort, Flask, Response +from flask import abort +from flask import Flask +from flask import Response + + application = Flask(__name__) LOG = logging.getLogger(__name__) diff --git a/ironic_prometheus_exporter/messaging.py b/ironic_prometheus_exporter/messaging.py index 5ba2fcd..acc1664 100644 --- a/ironic_prometheus_exporter/messaging.py +++ b/ironic_prometheus_exporter/messaging.py @@ -13,12 +13,15 @@ import logging import os -from ironic_prometheus_exporter.parsers import ipmi -from ironic_prometheus_exporter.parsers import header -from ironic_prometheus_exporter.parsers import redfish from oslo_config import cfg from oslo_messaging.notify import notifier -from prometheus_client import write_to_textfile, CollectorRegistry +from prometheus_client import CollectorRegistry +from prometheus_client import write_to_textfile + +from ironic_prometheus_exporter.parsers import header +from ironic_prometheus_exporter.parsers import ipmi +from ironic_prometheus_exporter.parsers import redfish + LOG = logging.getLogger(__name__) diff --git a/ironic_prometheus_exporter/parsers/descriptions.py b/ironic_prometheus_exporter/parsers/descriptions.py index 4ee4a46..d61c8f6 100644 --- a/ironic_prometheus_exporter/parsers/descriptions.py +++ b/ironic_prometheus_exporter/parsers/descriptions.py @@ -14,6 +14,7 @@ import json import logging import os + import pkg_resources DESCRIPTIONS = {} diff --git a/ironic_prometheus_exporter/parsers/header.py b/ironic_prometheus_exporter/parsers/header.py index fe749ed..4659576 100644 --- a/ironic_prometheus_exporter/parsers/header.py +++ b/ironic_prometheus_exporter/parsers/header.py @@ -14,8 +14,8 @@ from datetime import datetime from prometheus_client import Gauge -from ironic_prometheus_exporter import utils as ipe_utils from ironic_prometheus_exporter.parsers import descriptions +from ironic_prometheus_exporter import utils as ipe_utils def timestamp_registry(node_information, ipmi_metric_registry): diff --git a/ironic_prometheus_exporter/parsers/ipmi.py b/ironic_prometheus_exporter/parsers/ipmi.py index f487271..581a922 100644 --- a/ironic_prometheus_exporter/parsers/ipmi.py +++ b/ironic_prometheus_exporter/parsers/ipmi.py @@ -12,13 +12,13 @@ import json import logging -import pkg_resources import re +import pkg_resources from prometheus_client import Gauge -from ironic_prometheus_exporter import utils as ipe_utils from ironic_prometheus_exporter.parsers import descriptions +from ironic_prometheus_exporter import utils as ipe_utils # NOTE (iurygregory): most of the sensor readings come in the ipmi format @@ -140,7 +140,7 @@ def metric_names(category_info): def extract_labels(entries, category_info): - """ This function extract the labels to be used by a metric + """This function extract the labels to be used by a metric If a metric has many entries we add the 'Sensor ID' information as label otherwise we will only use the default label that is the 'node_name' and diff --git a/ironic_prometheus_exporter/parsers/redfish.py b/ironic_prometheus_exporter/parsers/redfish.py index 50fb9e6..8225fe9 100644 --- a/ironic_prometheus_exporter/parsers/redfish.py +++ b/ironic_prometheus_exporter/parsers/redfish.py @@ -15,8 +15,8 @@ import logging from prometheus_client import Gauge -from ironic_prometheus_exporter import utils as ipe_utils from ironic_prometheus_exporter.parsers import descriptions +from ironic_prometheus_exporter import utils as ipe_utils LOG = logging.getLogger(__name__) diff --git a/ironic_prometheus_exporter/tests/test_descriptions.py b/ironic_prometheus_exporter/tests/test_descriptions.py index 4a30427..2d7653b 100644 --- a/ironic_prometheus_exporter/tests/test_descriptions.py +++ b/ironic_prometheus_exporter/tests/test_descriptions.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -from ironic_prometheus_exporter.parsers import descriptions - from oslo_messaging.tests import utils as test_utils +from ironic_prometheus_exporter.parsers import descriptions + class TestMetricsDescriptions(test_utils.BaseTestCase): diff --git a/ironic_prometheus_exporter/tests/test_driver.py b/ironic_prometheus_exporter/tests/test_driver.py index 37f51d6..af50382 100644 --- a/ironic_prometheus_exporter/tests/test_driver.py +++ b/ironic_prometheus_exporter/tests/test_driver.py @@ -10,14 +10,15 @@ # License for the specific language governing permissions and limitations # under the License. -import fixtures import json import os + +import fixtures import oslo_messaging +from oslo_messaging.tests import utils as test_utils import ironic_prometheus_exporter from ironic_prometheus_exporter.messaging import PrometheusFileDriver -from oslo_messaging.tests import utils as test_utils class TestPrometheusFileNotifier(test_utils.BaseTestCase): diff --git a/ironic_prometheus_exporter/tests/test_header_parser.py b/ironic_prometheus_exporter/tests/test_header_parser.py index d5c86c6..6dc53ca 100644 --- a/ironic_prometheus_exporter/tests/test_header_parser.py +++ b/ironic_prometheus_exporter/tests/test_header_parser.py @@ -14,11 +14,12 @@ import json import os import unittest -import ironic_prometheus_exporter -from ironic_prometheus_exporter import utils as ipe_utils -from ironic_prometheus_exporter.parsers import header from prometheus_client import CollectorRegistry +import ironic_prometheus_exporter +from ironic_prometheus_exporter.parsers import header +from ironic_prometheus_exporter import utils as ipe_utils + sample_file = os.path.join( os.path.dirname(ironic_prometheus_exporter.__file__), diff --git a/ironic_prometheus_exporter/tests/test_ipmi_parser.py b/ironic_prometheus_exporter/tests/test_ipmi_parser.py index 27489c5..d09ec6a 100644 --- a/ironic_prometheus_exporter/tests/test_ipmi_parser.py +++ b/ironic_prometheus_exporter/tests/test_ipmi_parser.py @@ -14,11 +14,12 @@ import json import os import unittest -import ironic_prometheus_exporter -from ironic_prometheus_exporter import utils as ipe_utils -from ironic_prometheus_exporter.parsers import ipmi from prometheus_client import CollectorRegistry +import ironic_prometheus_exporter +from ironic_prometheus_exporter.parsers import ipmi +from ironic_prometheus_exporter import utils as ipe_utils + sample_file = os.path.join( os.path.dirname(ironic_prometheus_exporter.__file__), diff --git a/ironic_prometheus_exporter/tests/test_redfish_parser.py b/ironic_prometheus_exporter/tests/test_redfish_parser.py index f21c37b..b56eae1 100644 --- a/ironic_prometheus_exporter/tests/test_redfish_parser.py +++ b/ironic_prometheus_exporter/tests/test_redfish_parser.py @@ -1,12 +1,25 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + import json import os import unittest -import ironic_prometheus_exporter -from ironic_prometheus_exporter import utils as ipe_utils -from ironic_prometheus_exporter.parsers import redfish from prometheus_client import CollectorRegistry +import ironic_prometheus_exporter +from ironic_prometheus_exporter.parsers import redfish +from ironic_prometheus_exporter import utils as ipe_utils + sample_file = os.path.join( os.path.dirname(ironic_prometheus_exporter.__file__), diff --git a/lower-constraints.txt b/lower-constraints.txt index 746cedb..56fdf6c 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -23,6 +23,7 @@ Flask==1.0.0 future==0.18.2 futurist==2.1.0 greenlet==0.4.15 +hacking==3.0.0 idna==2.9 importlib-metadata==1.6.0 iso8601==0.1.12 @@ -94,4 +95,4 @@ WebOb==1.8.6 Werkzeug==1.0.1 wrapt==1.12.1 yappi==1.2.3 -zipp==3.1.0 +zipp==3.1.0 \ No newline at end of file diff --git a/test-requirements.txt b/test-requirements.txt index d229add..e95e8fe 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,6 @@ +hacking>=3.0.0,<3.1.0 # Apache-2.0 + flake8 +flake8-import-order>=0.17.1 stestr>=2.0.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 3f95a8c..7fe0025 100644 --- a/tox.ini +++ b/tox.ini @@ -54,10 +54,11 @@ deps = commands = {posargs} [flake8] -ignore = E129 -show-source = True -builtins = _ +application-import-names = ironic_prometheus_exporter exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build +import-order-style = pep8 +show-source = True + [testenv:lower-constraints] deps =