Browse Source

remove old oslo.config and use new oslo_config

Change-Id: Ic955ab24843c2c1c58748fdefde75356e0bb47df
Tong Li 3 years ago
parent
commit
62a45027b8
39 changed files with 93 additions and 65 deletions
  1. 1
    1
      kiloeyes/api/monasca_api_v2.py
  2. 9
    7
      kiloeyes/api/server.py
  3. 23
    0
      kiloeyes/common/constant.py
  4. 1
    1
      kiloeyes/common/email_sender.py
  5. 1
    1
      kiloeyes/common/es_conn.py
  6. 1
    1
      kiloeyes/common/kafka_conn.py
  7. 1
    1
      kiloeyes/common/resource_api.py
  8. 1
    1
      kiloeyes/dispatcher/sample_dispatcher.py
  9. 1
    1
      kiloeyes/microservice/es_persister.py
  10. 1
    1
      kiloeyes/microservice/fixed_strategy.py
  11. 1
    1
      kiloeyes/microservice/metrics_fixer.py
  12. 1
    1
      kiloeyes/microservice/notification_engine.py
  13. 1
    1
      kiloeyes/microservice/notification_processor.py
  14. 1
    1
      kiloeyes/microservice/server.py
  15. 5
    5
      kiloeyes/microservice/threshold_engine.py
  16. 3
    2
      kiloeyes/microservice/threshold_processor.py
  17. 1
    1
      kiloeyes/microservice/timed_strategy.py
  18. 1
    1
      kiloeyes/openstack/common/eventlet_backdoor.py
  19. 1
    1
      kiloeyes/openstack/common/fileutils.py
  20. 1
    1
      kiloeyes/openstack/common/loopingcall.py
  21. 1
    1
      kiloeyes/openstack/common/service.py
  22. 1
    1
      kiloeyes/openstack/common/systemd.py
  23. 1
    1
      kiloeyes/openstack/common/threadgroup.py
  24. 8
    11
      kiloeyes/service.py
  25. 4
    3
      kiloeyes/tests/common/test_alarm_expr_calculator.py
  26. 2
    1
      kiloeyes/tests/common/test_alarm_expr_parser.py
  27. 3
    2
      kiloeyes/tests/common/test_alarm_expr_validator.py
  28. 1
    1
      kiloeyes/tests/common/test_email_sender.py
  29. 5
    5
      kiloeyes/tests/common/test_es_conn.py
  30. 1
    1
      kiloeyes/tests/microservice/test_metrics_fixer.py
  31. 1
    1
      kiloeyes/tests/microservice/test_notification_processor.py
  32. 1
    1
      kiloeyes/tests/microservice/test_strategy.py
  33. 1
    1
      kiloeyes/tests/microservice/test_threshold_processor.py
  34. 1
    1
      kiloeyes/v2/elasticsearch/alarmdefinitions.py
  35. 1
    1
      kiloeyes/v2/elasticsearch/alarms.py
  36. 1
    1
      kiloeyes/v2/elasticsearch/metrics.py
  37. 1
    1
      kiloeyes/v2/elasticsearch/notificationmethods.py
  38. 1
    1
      kiloeyes/v2/elasticsearch/versions.py
  39. 2
    0
      requirements.txt

+ 1
- 1
kiloeyes/api/monasca_api_v2.py View File

@@ -13,7 +13,7 @@
13 13
 # under the License.
14 14
 
15 15
 from kiloeyes.common import resource_api
16
-from kiloeyes.openstack.common import log
16
+from oslo_log import log
17 17
 
18 18
 
19 19
 LOG = log.getLogger(__name__)

+ 9
- 7
kiloeyes/api/server.py View File

@@ -13,16 +13,15 @@
13 13
 # under the License.
14 14
 
15 15
 import os
16
-from wsgiref import simple_server
17
-
18 16
 from oslo_config import cfg
17
+from oslo_log import log
19 18
 import paste.deploy
20 19
 from stevedore import named
20
+from wsgiref import simple_server
21 21
 
22
-
22
+from kiloeyes.common import constant
23 23
 from kiloeyes.common import namespace
24 24
 from kiloeyes.common import resource_api
25
-from kiloeyes.openstack.common import log
26 25
 
27 26
 OPTS = [
28 27
     cfg.MultiStrOpt('dispatcher',
@@ -35,10 +34,13 @@ LOG = log.getLogger(__name__)
35 34
 
36 35
 
37 36
 def api_app(conf):
37
+    log.set_defaults(constant.KILOEYES_LOGGING_CONTEXT_FORMAT,
38
+                     constant.KILOEYES_LOG_LEVELS)
39
+    log.register_options(cfg.CONF)
40
+
38 41
     cfg.CONF(args=[], project='kiloeyes')
39
-    log_levels = (cfg.CONF.default_log_levels)
40
-    cfg.set_defaults(log.log_opts, default_log_levels=log_levels)
41
-    log.setup('kiloeyes')
42
+
43
+    log.setup(cfg.CONF, 'kiloeyes')
42 44
 
43 45
     dispatcher_manager = named.NamedExtensionManager(
44 46
         namespace=namespace.DISPATCHER_NS,

+ 23
- 0
kiloeyes/common/constant.py View File

@@ -0,0 +1,23 @@
1
+# Copyright 2013 IBM Corp
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+KILOEYES_LOG_LEVELS = ['oslo_messaging=INFO', 'iso8601=WARN',
16
+                       'requests.packages.urllib3.connectionpool=WARN',
17
+                       'urllib3.connectionpool=WARN', 'websocket=WARN',
18
+                       'stevedore=WARN', 'kiloeyes=WARN']
19
+
20
+KILOEYES_LOGGING_CONTEXT_FORMAT = ('%(asctime)s.%(msecs)03d %(process)d '
21
+                                   '%(levelname)s %(name)s [%(request_id)s '
22
+                                   '%(user_identity)s] %(instance)s'
23
+                                   '%(message)s')

+ 1
- 1
kiloeyes/common/email_sender.py View File

@@ -16,7 +16,7 @@ import email.mime.text
16 16
 from oslo_config import cfg
17 17
 import smtplib
18 18
 
19
-from kiloeyes.openstack.common import log
19
+from oslo_log import log
20 20
 
21 21
 MAILSENDER_OPTS = [
22 22
     cfg.StrOpt('username',

+ 1
- 1
kiloeyes/common/es_conn.py View File

@@ -16,7 +16,7 @@ from oslo_config import cfg
16 16
 import requests
17 17
 import ujson as json
18 18
 
19
-from kiloeyes.openstack.common import log
19
+from oslo_log import log
20 20
 
21 21
 
22 22
 ES_OPTS = [

+ 1
- 1
kiloeyes/common/kafka_conn.py View File

@@ -26,7 +26,7 @@ try:
26 26
 except ImportError:
27 27
     import json
28 28
 
29
-from kiloeyes.openstack.common import log
29
+from oslo_log import log
30 30
 
31 31
 
32 32
 KAFKA_OPTS = [

+ 1
- 1
kiloeyes/common/resource_api.py View File

@@ -15,7 +15,7 @@
15 15
 import falcon
16 16
 from falcon import api_helpers
17 17
 
18
-from kiloeyes.openstack.common import log
18
+from oslo_log import log
19 19
 
20 20
 
21 21
 RESOURCE_METHOD_FLAG = 'fab05a04-b861-4651-bd0c-9cb3eb9a6088'

+ 1
- 1
kiloeyes/dispatcher/sample_dispatcher.py View File

@@ -17,7 +17,7 @@ from oslo_config import cfg
17 17
 
18 18
 from kiloeyes.api import monasca_api_v2
19 19
 from kiloeyes.common import resource_api
20
-from kiloeyes.openstack.common import log
20
+from oslo_log import log
21 21
 
22 22
 OPTS = [
23 23
     cfg.MultiStrOpt('id',

+ 1
- 1
kiloeyes/microservice/es_persister.py View File

@@ -14,12 +14,12 @@
14 14
 # under the License.
15 15
 
16 16
 from oslo_config import cfg
17
+from oslo_log import log
17 18
 from stevedore import driver
18 19
 
19 20
 from kiloeyes.common import es_conn
20 21
 from kiloeyes.common import kafka_conn
21 22
 from kiloeyes.common import namespace
22
-from kiloeyes.openstack.common import log
23 23
 from kiloeyes.openstack.common import service as os_service
24 24
 
25 25
 OPTS = [

+ 1
- 1
kiloeyes/microservice/fixed_strategy.py View File

@@ -15,7 +15,7 @@
15 15
 
16 16
 from oslo_config import cfg
17 17
 
18
-from kiloeyes.openstack.common import log
18
+from oslo_log import log
19 19
 
20 20
 LOG = log.getLogger(__name__)
21 21
 

+ 1
- 1
kiloeyes/microservice/metrics_fixer.py View File

@@ -17,7 +17,7 @@ import hashlib
17 17
 import json
18 18
 import time
19 19
 
20
-from kiloeyes.openstack.common import log
20
+from oslo_log import log
21 21
 
22 22
 LOG = log.getLogger(__name__)
23 23
 

+ 1
- 1
kiloeyes/microservice/notification_engine.py View File

@@ -13,12 +13,12 @@
13 13
 # under the License.
14 14
 
15 15
 from oslo_config import cfg
16
+from oslo_log import log
16 17
 from stevedore import driver
17 18
 
18 19
 from kiloeyes.common import es_conn
19 20
 from kiloeyes.common import kafka_conn
20 21
 from kiloeyes.common import namespace
21
-from kiloeyes.openstack.common import log
22 22
 from kiloeyes.openstack.common import service as os_service
23 23
 
24 24
 NOTIFICATION_ENGINE_OPTS = [

+ 1
- 1
kiloeyes/microservice/notification_processor.py View File

@@ -14,7 +14,7 @@
14 14
 
15 15
 import json
16 16
 from kiloeyes.common import email_sender
17
-from kiloeyes.openstack.common import log
17
+from oslo_log import log
18 18
 
19 19
 LOG = log.getLogger(__name__)
20 20
 

+ 1
- 1
kiloeyes/microservice/server.py View File

@@ -14,10 +14,10 @@
14 14
 # under the License.
15 15
 
16 16
 from oslo_config import cfg
17
+from oslo_log import log
17 18
 from stevedore import driver
18 19
 
19 20
 from kiloeyes.common import namespace
20
-from kiloeyes.openstack.common import log
21 21
 from kiloeyes.openstack.common import service as os_service
22 22
 from kiloeyes import service
23 23
 

+ 5
- 5
kiloeyes/microservice/threshold_engine.py View File

@@ -12,16 +12,16 @@
12 12
 # License for the specific language governing permissions and limitations
13 13
 # under the License.
14 14
 
15
+from oslo_config import cfg
16
+from oslo_log import log
17
+from stevedore import driver
18
+import threading
19
+import time
15 20
 
16 21
 from kiloeyes.common import es_conn
17 22
 from kiloeyes.common import kafka_conn
18 23
 from kiloeyes.common import namespace
19
-from kiloeyes.openstack.common import log
20 24
 from kiloeyes.openstack.common import service as os_service
21
-from oslo_config import cfg
22
-from stevedore import driver
23
-import threading
24
-import time
25 25
 
26 26
 lock = threading.RLock()
27 27
 

+ 3
- 2
kiloeyes/microservice/threshold_processor.py View File

@@ -15,11 +15,12 @@
15 15
 import collections
16 16
 import copy
17 17
 import json
18
+from oslo_log import log
19
+import uuid
20
+
18 21
 from kiloeyes.common import alarm_expr_calculator as calculator
19 22
 from kiloeyes.common import alarm_expr_parser as parser
20
-from kiloeyes.openstack.common import log
21 23
 from kiloeyes.openstack.common import timeutils as tu
22
-import uuid
23 24
 
24 25
 
25 26
 LOG = log.getLogger(__name__)

+ 1
- 1
kiloeyes/microservice/timed_strategy.py View File

@@ -18,7 +18,7 @@ import dateutil.parser as dparser
18 18
 from oslo_config import cfg
19 19
 import time
20 20
 
21
-from kiloeyes.openstack.common import log
21
+from oslo_log import log
22 22
 
23 23
 
24 24
 """

+ 1
- 1
kiloeyes/openstack/common/eventlet_backdoor.py View File

@@ -30,7 +30,7 @@ import greenlet
30 30
 from oslo_config import cfg
31 31
 
32 32
 from kiloeyes.openstack.common.gettextutils import _LI
33
-from kiloeyes.openstack.common import log as logging
33
+from oslo_log import log as logging
34 34
 
35 35
 help_for_backdoor_port = (
36 36
     "Acceptable values are 0, <port>, and <start>:<end>, where 0 results "

+ 1
- 1
kiloeyes/openstack/common/fileutils.py View File

@@ -19,7 +19,7 @@ import os
19 19
 import tempfile
20 20
 
21 21
 from kiloeyes.openstack.common import excutils
22
-from kiloeyes.openstack.common import log as logging
22
+from oslo_log import log as logging
23 23
 
24 24
 LOG = logging.getLogger(__name__)
25 25
 

+ 1
- 1
kiloeyes/openstack/common/loopingcall.py View File

@@ -22,7 +22,7 @@ from eventlet import event
22 22
 from eventlet import greenthread
23 23
 
24 24
 from kiloeyes.openstack.common.gettextutils import _LE, _LW
25
-from kiloeyes.openstack.common import log as logging
25
+from oslo_log import log as logging
26 26
 
27 27
 LOG = logging.getLogger(__name__)
28 28
 

+ 1
- 1
kiloeyes/openstack/common/service.py View File

@@ -40,7 +40,7 @@ from oslo_config import cfg
40 40
 from kiloeyes.openstack.common import eventlet_backdoor
41 41
 from kiloeyes.openstack.common.gettextutils import _LE, _LI, _LW
42 42
 from kiloeyes.openstack.common import importutils
43
-from kiloeyes.openstack.common import log as logging
43
+from oslo_log import log as logging
44 44
 from kiloeyes.openstack.common import systemd
45 45
 from kiloeyes.openstack.common import threadgroup
46 46
 

+ 1
- 1
kiloeyes/openstack/common/systemd.py View File

@@ -20,7 +20,7 @@ import os
20 20
 import socket
21 21
 import sys
22 22
 
23
-from kiloeyes.openstack.common import log as logging
23
+from oslo_log import log as logging
24 24
 
25 25
 
26 26
 LOG = logging.getLogger(__name__)

+ 1
- 1
kiloeyes/openstack/common/threadgroup.py View File

@@ -16,7 +16,7 @@ import threading
16 16
 import eventlet
17 17
 from eventlet import greenpool
18 18
 
19
-from kiloeyes.openstack.common import log as logging
19
+from oslo_log import log as logging
20 20
 from kiloeyes.openstack.common import loopingcall
21 21
 
22 22
 

+ 8
- 11
kiloeyes/service.py View File

@@ -14,26 +14,23 @@
14 14
 # License for the specific language governing permissions and limitations
15 15
 # under the License.
16 16
 
17
-import sys
18 17
 
19 18
 from oslo_config import cfg
19
+from oslo_log import log
20
+import sys
20 21
 
21
-from kiloeyes.openstack.common import gettextutils
22
-from kiloeyes.openstack.common import log
23
-
24
-
25
-cfg.CONF.import_opt('default_log_levels', 'kiloeyes.openstack.common.log')
22
+from kiloeyes.common import constant
26 23
 
27 24
 LOG = log.getLogger(__name__)
28 25
 
29 26
 
30 27
 def prepare_service(argv=None):
31
-    gettextutils.install('kiloeyes')
32
-    gettextutils.enable_lazy()
33
-    log_levels = (cfg.CONF.default_log_levels)
34
-    cfg.set_defaults(log.log_opts, default_log_levels=log_levels)
28
+    log.set_defaults(constant.KILOEYES_LOGGING_CONTEXT_FORMAT,
29
+                     constant.KILOEYES_LOG_LEVELS)
30
+    log.register_options(cfg.CONF)
31
+
35 32
     if argv is None:
36 33
         argv = sys.argv
37 34
     cfg.CONF(argv[1:], project='kiloeyes')
38
-    log.setup('kiloeyes')
35
+    log.setup(cfg.CONF, 'kiloeyes')
39 36
     LOG.info('Service has started!')

+ 4
- 3
kiloeyes/tests/common/test_alarm_expr_calculator.py View File

@@ -12,12 +12,13 @@
12 12
 # License for the specific language governing permissions and limitations
13 13
 # under the License.
14 14
 
15
-from kiloeyes.common import alarm_expr_calculator as calculator
16
-from kiloeyes.openstack.common import log
17
-from kiloeyes import tests
15
+from oslo_log import log
18 16
 import random
19 17
 import time
20 18
 
19
+from kiloeyes.common import alarm_expr_calculator as calculator
20
+from kiloeyes import tests
21
+
21 22
 
22 23
 LOG = log.getLogger(__name__)
23 24
 

+ 2
- 1
kiloeyes/tests/common/test_alarm_expr_parser.py View File

@@ -13,8 +13,9 @@
13 13
 # License for the specific language governing permissions and limitations
14 14
 # under the License.
15 15
 
16
+from oslo_log import log
17
+
16 18
 from kiloeyes.common import alarm_expr_parser
17
-from kiloeyes.openstack.common import log
18 19
 from kiloeyes import tests
19 20
 
20 21
 LOG = log.getLogger(__name__)

+ 3
- 2
kiloeyes/tests/common/test_alarm_expr_validator.py View File

@@ -14,10 +14,11 @@
14 14
 # under the License.
15 15
 
16 16
 import json
17
+import os
18
+from oslo_log import log
19
+
17 20
 from kiloeyes.common import alarm_expr_validator as validator
18
-from kiloeyes.openstack.common import log
19 21
 from kiloeyes import tests
20
-import os
21 22
 
22 23
 LOG = log.getLogger(__name__)
23 24
 

+ 1
- 1
kiloeyes/tests/common/test_email_sender.py View File

@@ -14,10 +14,10 @@
14 14
 
15 15
 import email.mime.text
16 16
 import mock
17
+from oslo_log import log
17 18
 import smtplib
18 19
 
19 20
 from kiloeyes.common import email_sender
20
-from kiloeyes.openstack.common import log
21 21
 from kiloeyes import tests
22 22
 
23 23
 LOG = log.getLogger(__name__)

+ 5
- 5
kiloeyes/tests/common/test_es_conn.py View File

@@ -12,16 +12,16 @@
12 12
 # License for the specific language governing permissions and limitations
13 13
 # under the License.
14 14
 
15
+import json
16
+import mock
17
+from oslo_log import log
18
+import requests
19
+
15 20
 from kiloeyes.common import es_conn
16 21
 from kiloeyes.microservice import timed_strategy
17 22
 from kiloeyes.openstack.common.fixture import config
18
-from kiloeyes.openstack.common import log
19 23
 from kiloeyes import tests
20 24
 
21
-import json
22
-import mock
23
-import requests
24
-
25 25
 LOG = log.getLogger(__name__)
26 26
 
27 27
 

+ 1
- 1
kiloeyes/tests/microservice/test_metrics_fixer.py View File

@@ -13,11 +13,11 @@
13 13
 # under the License.
14 14
 
15 15
 import json
16
+from oslo_log import log
16 17
 import time
17 18
 
18 19
 
19 20
 from kiloeyes.microservice import metrics_fixer
20
-from kiloeyes.openstack.common import log
21 21
 from kiloeyes import tests
22 22
 
23 23
 LOG = log.getLogger(__name__)

+ 1
- 1
kiloeyes/tests/microservice/test_notification_processor.py View File

@@ -15,10 +15,10 @@
15 15
 import ast
16 16
 import json
17 17
 import mock
18
+from oslo_log import log
18 19
 
19 20
 from kiloeyes.common import email_sender
20 21
 from kiloeyes.microservice import notification_processor
21
-from kiloeyes.openstack.common import log
22 22
 from kiloeyes import tests
23 23
 
24 24
 LOG = log.getLogger(__name__)

+ 1
- 1
kiloeyes/tests/microservice/test_strategy.py View File

@@ -13,11 +13,11 @@
13 13
 # under the License.
14 14
 
15 15
 import dateutil.parser as dparser
16
+from oslo_log import log
16 17
 import time
17 18
 
18 19
 from kiloeyes.microservice import timed_strategy
19 20
 from kiloeyes.openstack.common.fixture import config
20
-from kiloeyes.openstack.common import log
21 21
 from kiloeyes import tests
22 22
 
23 23
 LOG = log.getLogger(__name__)

+ 1
- 1
kiloeyes/tests/microservice/test_threshold_processor.py View File

@@ -16,9 +16,9 @@
16 16
 import json
17 17
 import mock
18 18
 import os
19
+from oslo_log import log
19 20
 
20 21
 from kiloeyes.microservice import threshold_processor as processor
21
-from kiloeyes.openstack.common import log
22 22
 from kiloeyes.openstack.common import timeutils as tu
23 23
 from kiloeyes import tests
24 24
 

+ 1
- 1
kiloeyes/v2/elasticsearch/alarmdefinitions.py View File

@@ -24,7 +24,7 @@ from kiloeyes.common import alarm_expr_validator
24 24
 from kiloeyes.common import es_conn
25 25
 from kiloeyes.common import namespace
26 26
 from kiloeyes.common import resource_api
27
-from kiloeyes.openstack.common import log
27
+from oslo_log import log
28 28
 
29 29
 
30 30
 try:

+ 1
- 1
kiloeyes/v2/elasticsearch/alarms.py View File

@@ -21,7 +21,7 @@ from stevedore import driver
21 21
 from kiloeyes.common import es_conn
22 22
 from kiloeyes.common import namespace
23 23
 from kiloeyes.common import resource_api
24
-from kiloeyes.openstack.common import log
24
+from oslo_log import log
25 25
 
26 26
 
27 27
 try:

+ 1
- 1
kiloeyes/v2/elasticsearch/metrics.py View File

@@ -17,6 +17,7 @@ import datetime
17 17
 import dateutil.parser
18 18
 import falcon
19 19
 from oslo_config import cfg
20
+from oslo_log import log
20 21
 import requests
21 22
 from stevedore import driver
22 23
 
@@ -24,7 +25,6 @@ from kiloeyes.common import es_conn
24 25
 from kiloeyes.common import kafka_conn
25 26
 from kiloeyes.common import namespace
26 27
 from kiloeyes.common import resource_api
27
-from kiloeyes.openstack.common import log
28 28
 from kiloeyes.openstack.common import timeutils as tu
29 29
 
30 30
 try:

+ 1
- 1
kiloeyes/v2/elasticsearch/notificationmethods.py View File

@@ -23,7 +23,7 @@ import uuid
23 23
 from kiloeyes.common import es_conn
24 24
 from kiloeyes.common import namespace
25 25
 from kiloeyes.common import resource_api
26
-from kiloeyes.openstack.common import log
26
+from oslo_log import log
27 27
 
28 28
 
29 29
 NOTIFICATION_METHOD_OPTS = [

+ 1
- 1
kiloeyes/v2/elasticsearch/versions.py View File

@@ -16,7 +16,7 @@ import datetime
16 16
 import falcon
17 17
 
18 18
 from kiloeyes.common import resource_api
19
-from kiloeyes.openstack.common import log
19
+from oslo_log import log
20 20
 
21 21
 try:
22 22
     import ujson as json

+ 2
- 0
requirements.txt View File

@@ -8,6 +8,8 @@ gunicorn>=19.1.0,<=19.2.1
8 8
 iso8601>=0.1.9
9 9
 kafka-python>=0.8.1
10 10
 oslo.config>=1.11.0
11
+oslo.log>=1.0.0
12
+oslo.service>=0.1.0
11 13
 pastedeploy>=1.3.3
12 14
 pbr>=0.6,!=0.7,<1.0
13 15
 python-dateutil>=1.5

Loading…
Cancel
Save