Update all Oslo module use

Use graduated libraries where available and update the incubated modules
that remain.

Update imports for libraries that were being used already to avoid the
'oslo' namespace package.

Update config file for creating example configuration files and provide
a new sample file based on the options defined in the libraries.

Note: because of the number of libraries involved there is no real way
to break this change up into smaller pieces. Fortunately, most of the
changes are just to import statements.

Change-Id: Ia0de957b681cb924a57af98d99a9389ee234ed5b
changes/49/163549/2
Doug Hellmann 8 years ago
parent 7ff8f0e45a
commit 583ce2c043
  1. 44
      etc/tempest.conf.sample
  2. 4
      openstack-common.conf
  3. 5
      requirements.txt
  4. 3
      tempest/api/baremetal/admin/test_nodestates.py
  5. 2
      tempest/api/compute/admin/test_agents.py
  6. 2
      tempest/api/compute/admin/test_quotas.py
  7. 4
      tempest/api/compute/base.py
  8. 2
      tempest/api/compute/images/test_images_oneserver.py
  9. 2
      tempest/api/compute/images/test_images_oneserver_negative.py
  10. 2
      tempest/api/compute/images/test_list_image_filters.py
  11. 2
      tempest/api/compute/test_authorization.py
  12. 2
      tempest/api/compute/test_extensions.py
  13. 3
      tempest/api/database/base.py
  14. 2
      tempest/api/identity/__init__.py
  15. 2
      tempest/api/identity/admin/v3/test_trusts.py
  16. 2
      tempest/api/identity/base.py
  17. 2
      tempest/api/image/base.py
  18. 2
      tempest/api/messaging/base.py
  19. 2
      tempest/api/network/base.py
  20. 2
      tempest/api/network/test_metering_extensions.py
  21. 2
      tempest/api/orchestration/base.py
  22. 2
      tempest/api/orchestration/stacks/test_soft_conf.py
  23. 2
      tempest/api/orchestration/stacks/test_stacks.py
  24. 2
      tempest/api/telemetry/base.py
  25. 2
      tempest/api/volume/admin/test_multi_backend.py
  26. 2
      tempest/api/volume/admin/test_volumes_backup.py
  27. 2
      tempest/api/volume/base.py
  28. 2
      tempest/api/volume/test_extensions.py
  29. 2
      tempest/api/volume/test_volumes_list.py
  30. 2
      tempest/api/volume/test_volumes_snapshots.py
  31. 2
      tempest/auth.py
  32. 2
      tempest/cli/simple_read_only/image/test_glance.py
  33. 2
      tempest/cli/simple_read_only/network/test_neutron.py
  34. 2
      tempest/cli/simple_read_only/orchestration/test_heat.py
  35. 3
      tempest/cli/simple_read_only/telemetry/test_ceilometer.py
  36. 3
      tempest/clients.py
  37. 3
      tempest/cmd/cleanup.py
  38. 3
      tempest/cmd/cleanup_service.py
  39. 6
      tempest/cmd/javelin.py
  40. 2
      tempest/cmd/run_stress.py
  41. 13
      tempest/common/accounts.py
  42. 2
      tempest/common/commands.py
  43. 2
      tempest/common/cred_provider.py
  44. 2
      tempest/common/generator/base_generator.py
  45. 3
      tempest/common/generator/negative_generator.py
  46. 3
      tempest/common/generator/valid_generator.py
  47. 2
      tempest/common/glance_http.py
  48. 2
      tempest/common/isolated_creds.py
  49. 2
      tempest/common/ssh.py
  50. 2
      tempest/common/tempest_fixtures.py
  51. 2
      tempest/common/waiters.py
  52. 30
      tempest/config.py
  53. 6
      tempest/openstack/common/_i18n.py
  54. 99
      tempest/openstack/common/excutils.py
  55. 137
      tempest/openstack/common/fileutils.py
  56. 0
      tempest/openstack/common/fixture/__init__.py
  57. 45
      tempest/openstack/common/fixture/config.py
  58. 51
      tempest/openstack/common/fixture/lockutils.py
  59. 50
      tempest/openstack/common/fixture/mockpatch.py
  60. 32
      tempest/openstack/common/fixture/moxstubout.py
  61. 479
      tempest/openstack/common/gettextutils.py
  62. 73
      tempest/openstack/common/importutils.py
  63. 190
      tempest/openstack/common/jsonutils.py
  64. 45
      tempest/openstack/common/local.py
  65. 303
      tempest/openstack/common/lockutils.py
  66. 710
      tempest/openstack/common/log.py
  67. 295
      tempest/openstack/common/strutils.py
  68. 210
      tempest/openstack/common/timeutils.py
  69. 141
      tempest/openstack/common/versionutils.py
  70. 2
      tempest/scenario/manager.py
  71. 2
      tempest/scenario/test_aggregates_basic_ops.py
  72. 3
      tempest/scenario/test_baremetal_basic_ops.py
  73. 2
      tempest/scenario/test_large_ops.py
  74. 3
      tempest/scenario/test_minimum_basic.py
  75. 2
      tempest/scenario/test_network_advanced_server_ops.py
  76. 2
      tempest/scenario/test_network_basic_ops.py
  77. 4
      tempest/scenario/test_network_v6.py
  78. 2
      tempest/scenario/test_security_groups_basic_ops.py
  79. 2
      tempest/scenario/test_server_advanced_ops.py
  80. 3
      tempest/scenario/test_server_basic_ops.py
  81. 2
      tempest/scenario/test_shelve_instance.py
  82. 2
      tempest/scenario/test_snapshot_pattern.py
  83. 2
      tempest/scenario/test_stamp_pattern.py
  84. 3
      tempest/scenario/test_swift_basic_ops.py
  85. 2
      tempest/scenario/test_swift_telemetry_middleware.py
  86. 2
      tempest/scenario/test_volume_boot_pattern.py
  87. 2
      tempest/services/image/v1/json/image_client.py
  88. 3
      tempest/services/telemetry/json/telemetry_client.py
  89. 3
      tempest/services/volume/json/admin/volume_quotas_client.py
  90. 2
      tempest/services/volume/json/snapshots_client.py
  91. 5
      tempest/stress/actions/unit_test.py
  92. 3
      tempest/stress/cleanup.py
  93. 4
      tempest/stress/driver.py
  94. 2
      tempest/stress/stressaction.py
  95. 4
      tempest/test.py
  96. 2
      tempest/tests/cmd/test_verify_tempest_config.py
  97. 64
      tempest/tests/common/test_accounts.py
  98. 2
      tempest/tests/common/test_cred_provider.py
  99. 4
      tempest/tests/common/utils/linux/test_remote_client.py
  100. 13
      tempest/tests/fake_config.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,17 +1,7 @@
[DEFAULT]
#
# From tempest.config
#
# Whether to disable inter-process locks (boolean value)
#disable_process_locking = false
# Directory to use for lock files. (string value)
#lock_path = <None>
#
# From tempest.config
# From oslo.log
#
# Print debugging output (set logging level to DEBUG instead of
@ -22,10 +12,6 @@
# default WARNING level). (boolean value)
#verbose = false
#
# From tempest.config
#
# The name of a logging configuration file. This file is appended to
# any existing logging configuration files. For details about logging
# configuration files, see the Python logging module documentation.
@ -66,17 +52,9 @@
# Syslog facility to receive log lines. (string value)
#syslog_log_facility = LOG_USER
#
# From tempest.config
#
# Log output to standard error. (boolean value)
#use_stderr = true
#
# From tempest.config
#
# Format string to use for log messages with context. (string value)
#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
@ -92,7 +70,7 @@
#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s
# List of logger=LEVEL pairs. (list value)
#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN
#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN
# Enables or disables publication of error events. (boolean value)
#publish_errors = false
@ -917,6 +895,24 @@
#max_resources_per_stack = 1000
[oslo_concurrency]
#
# From oslo.concurrency
#
# Enables or disables inter-process locks. (boolean value)
# Deprecated group/name - [DEFAULT]/disable_process_locking
#disable_process_locking = false
# Directory to use for lock files. For security, the specified
# directory should only be writable by the user running the processes
# that need locking. Defaults to environment variable OSLO_LOCK_PATH.
# If external locks are used, a lock path must be set. (string value)
# Deprecated group/name - [DEFAULT]/lock_path
#lock_path = <None>
[scenario]
#

@ -2,10 +2,6 @@
# The list of modules to copy from openstack-common
module=install_venv_common
module=lockutils
module=log
module=importlib
module=fixture
module=versionutils
# The base module to hold the copy of openstack.common

@ -19,7 +19,12 @@ python-ironicclient>=0.2.1
python-saharaclient>=0.7.6
python-swiftclient>=2.2.0
testrepository>=0.0.18
oslo.concurrency>=1.4.1 # Apache-2.0
oslo.config>=1.6.0 # Apache-2.0
oslo.i18n>=1.3.0 # Apache-2.0
oslo.log>=0.4.0 # Apache-2.0
oslo.serialization>=1.2.0 # Apache-2.0
oslo.utils>=1.2.0 # Apache-2.0
six>=1.9.0
iso8601>=0.1.9
fixtures>=0.3.14

@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import timeutils
from tempest.api.baremetal.admin import base
from tempest import exceptions
from tempest.openstack.common import timeutils
from tempest import test

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest.openstack.common import log
from tempest import test
LOG = log.getLogger(__name__)

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
import six
from tempest_lib.common.utils import data_utils
from testtools import matchers
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
from tempest.openstack.common import log as logging
from tempest import test
LOG = logging.getLogger(__name__)

@ -15,6 +15,8 @@
import time
from oslo_log import log as logging
from oslo_utils import excutils
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
@ -22,8 +24,6 @@ from tempest import clients
from tempest.common import credentials
from tempest import config
from tempest import exceptions
from tempest.openstack.common import excutils
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest.api.compute import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -16,12 +16,12 @@
import StringIO
import time
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
import testtools
from tempest.api.compute import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -15,13 +15,13 @@
import StringIO
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest import clients
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest.api.compute import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest import config
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest.openstack.common import log as logging
from oslo_log import log as logging
LOG = logging.getLogger(__name__)

@ -13,6 +13,7 @@
import datetime
import re
from oslo_utils import timeutils
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
@ -20,7 +21,6 @@ from tempest.api.identity import base
from tempest import clients
from tempest.common import cred_provider
from tempest import config
from tempest.openstack.common import timeutils
from tempest import test
CONF = config.CONF

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest.common import cred_provider
from tempest import config
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -14,13 +14,13 @@
import cStringIO as StringIO
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest.common import credentials
from tempest import config
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -14,13 +14,13 @@
# under the License.
import netaddr
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest.api.network import base
from tempest.openstack.common import log as logging
from tempest import test

@ -12,13 +12,13 @@
import os.path
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
import yaml
from tempest import clients
from tempest import config
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -10,12 +10,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.orchestration import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
LOG = logging.getLogger(__name__)

@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest.api.orchestration import base
from tempest.openstack.common import log as logging
from tempest import test

@ -12,12 +12,12 @@
import time
from oslo_utils import timeutils
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest import config
from tempest import exceptions
from tempest.openstack.common import timeutils
import tempest.test
CONF = config.CONF

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
CONF = config.CONF

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest.api.volume import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -15,11 +15,11 @@
# under the License.
import operator
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from testtools import matchers
from tempest.api.volume import base
from tempest.openstack.common import log as logging
from tempest import test
LOG = logging.getLogger(__name__)

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
LOG = logging.getLogger(__name__)

@ -22,7 +22,7 @@ import urlparse
import six
from tempest.openstack.common import log as logging
from oslo_log import log as logging
from tempest.services.identity.v2.json import token_client as json_v2id
from tempest.services.identity.v3.json import token_client as json_v3id

@ -15,11 +15,11 @@
import re
from oslo_log import log as logging
from tempest_lib import exceptions
from tempest import cli
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -15,11 +15,11 @@
import re
from oslo_log import log as logging
from tempest_lib import exceptions
from tempest import cli
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -13,11 +13,11 @@
import json
import os
from oslo_log import log as logging
import yaml
import tempest.cli
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest import cli
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
CONF = config.CONF

@ -15,11 +15,12 @@
import copy
from oslo_log import log as logging
from tempest.common import cred_provider
from tempest.common import negative_rest_client
from tempest import config
from tempest import manager
from tempest.openstack.common import log as logging
from tempest.services.baremetal.v1.json.baremetal_client import \
BaremetalClientJSON
from tempest.services import botoclients

@ -54,11 +54,12 @@ import argparse
import json
import sys
from oslo_log import log as logging
from tempest import clients
from tempest.cmd import cleanup_service
from tempest.common import cred_provider
from tempest import config
from tempest.openstack.common import log as logging
SAVED_STATE_JSON = "saved_state.json"
DRY_RUN_JSON = "dry_run.json"

@ -14,9 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest import clients
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
LOG = logging.getLogger(__name__)

@ -110,13 +110,13 @@ import sys
import unittest
import netaddr
from oslo_log import log as logging
from oslo_utils import timeutils
from tempest_lib import exceptions as lib_exc
import yaml
import tempest.auth
from tempest import config
from tempest.openstack.common import log as logging
from tempest.openstack.common import timeutils
from tempest.services.compute.json import flavors_client
from tempest.services.compute.json import security_groups_client
from tempest.services.compute.json import servers_client
@ -1038,7 +1038,7 @@ def get_options():
def setup_logging():
global LOG
logging.setup(__name__)
logging.setup(CONF, __name__)
LOG = logging.getLogger(__name__)

@ -26,7 +26,7 @@ except ImportError:
from testtools import testsuite
from tempest.openstack.common import log as logging
from oslo_log import log as logging
from tempest.stress import driver
LOG = logging.getLogger(__name__)

@ -15,13 +15,13 @@
import hashlib
import os
from oslo_concurrency import lockutils
from oslo_log import log as logging
import yaml
from tempest.common import cred_provider
from tempest import config
from tempest import exceptions
from tempest.openstack.common import lockutils
from tempest.openstack.common import log as logging
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -45,7 +45,14 @@ class Accounts(cred_provider.CredentialProvider):
accounts = {}
self.use_default_creds = True
self.hash_dict = self.get_hash_dict(accounts)
self.accounts_dir = os.path.join(CONF.lock_path, 'test_accounts')
# FIXME(dhellmann): The configuration option is not part of
# the API of the library, because if we change the option name
# or group it will break this use. Tempest needs to set this
# value somewhere that it owns, and then use
# lockutils.set_defaults() to tell oslo.concurrency what value
# to use.
self.accounts_dir = os.path.join(CONF.oslo_concurrency.lock_path,
'test_accounts')
self.isolated_creds = {}
@classmethod

@ -15,7 +15,7 @@
import shlex
import subprocess
from tempest.openstack.common import log as logging
from oslo_log import log as logging
LOG = logging.getLogger(__name__)

@ -14,12 +14,12 @@
import abc
from oslo_log import log as logging
import six
from tempest import auth
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
CONF = config.CONF
LOG = logging.getLogger(__name__)

@ -18,7 +18,7 @@ import functools
import jsonschema
from tempest.openstack.common import log as logging
from oslo_log import log as logging
LOG = logging.getLogger(__name__)

@ -15,9 +15,10 @@
import copy
from oslo_log import log as logging
import tempest.common.generator.base_generator as base
import tempest.common.generator.valid_generator as valid
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
import tempest.common.generator.base_generator as base
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)

@ -28,11 +28,11 @@ import urlparse
import OpenSSL
from oslo_log import log as logging
from six import moves
from tempest_lib import exceptions as lib_exc
from tempest import exceptions as exc
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)
USER_AGENT = 'tempest'

@ -13,6 +13,7 @@
# under the License.
import netaddr
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
@ -20,7 +21,6 @@ from tempest import clients
from tempest.common import cred_provider
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
CONF = config.CONF
LOG = logging.getLogger(__name__)

@ -20,10 +20,10 @@ import socket
import time
import warnings
from oslo_log import log as logging
import six
from tempest import exceptions
from tempest.openstack.common import log as logging
with warnings.catch_warnings():

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest.openstack.common.fixture import lockutils
from oslo_concurrency.fixture import lockutils
class LockFixture(lockutils.LockFixture):

@ -13,11 +13,11 @@
import time
from oslo_log import log as logging
from tempest_lib.common.utils import misc as misc_utils
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
CONF = config.CONF
LOG = logging.getLogger(__name__)

@ -18,10 +18,9 @@ from __future__ import print_function
import logging as std_logging
import os
from oslo.config import cfg
from oslo_config import cfg
from tempest.openstack.common import lockutils
from tempest.openstack.common import log as logging
from oslo_log import log as logging
def register_opt_group(conf, opt_group, options):
@ -1102,16 +1101,7 @@ def list_opts():
The purpose of this is to allow tools like the Oslo sample config file
generator to discover the options exposed to users.
"""
optlist = [(g.name, o) for g, o in _opts]
# NOTE(jgrimm): Can be removed once oslo-incubator/oslo changes happen.
optlist.append((None, lockutils.util_opts))
optlist.append((None, logging.common_cli_opts))
optlist.append((None, logging.logging_cli_opts))
optlist.append((None, logging.generic_log_opts))
optlist.append((None, logging.log_opts))
return optlist
return [(g.name, o) for g, o in _opts]
# this should never be called outside of this class
@ -1190,11 +1180,12 @@ class TempestConfigPrivate(object):
# to remove an issue with the config file up to date checker.
if parse_conf:
config_files.append(path)
logging.register_options(cfg.CONF)
if os.path.isfile(path):
cfg.CONF([], project='tempest', default_config_files=config_files)
else:
cfg.CONF([], project='tempest')
logging.setup('tempest')
logging.setup(cfg.CONF, 'tempest')
LOG = logging.getLogger('tempest')
LOG.info("Using tempest config file %s" % path)
register_opts()
@ -1208,16 +1199,15 @@ class TempestConfigProxy(object):
_path = None
_extra_log_defaults = [
'keystoneclient.session=INFO',
'paramiko.transport=INFO',
'requests.packages.urllib3.connectionpool=WARN'
('keystoneclient.session', std_logging.INFO),
('paramiko.transport', std_logging.INFO),
('requests.packages.urllib3.connectionpool', std_logging.WARN),
]
def _fix_log_levels(self):
"""Tweak the oslo log defaults."""
for opt in logging.log_opts:
if opt.dest == 'default_log_levels':
opt.default.extend(self._extra_log_defaults)
for name, level in self._extra_log_defaults:
std_logging.getLogger(name).setLevel(level)
def __getattr__(self, attr):
if not self._config:

@ -17,14 +17,14 @@ See http://docs.openstack.org/developer/oslo.i18n/usage.html
"""
try:
import oslo.i18n
import oslo_i18n
# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
# application name when this module is synced into the separate
# repository. It is OK to have more than one translation function
# using the same domain, since there will still only be one message
# catalog.
_translators = oslo.i18n.TranslatorFactory(domain='tempest')
_translators = oslo_i18n.TranslatorFactory(domain='tempest')
# The primary translation function using the well-known name "_"
_ = _translators.primary
@ -40,6 +40,6 @@ try:
_LC = _translators.log_critical
except ImportError:
# NOTE(dims): Support for cases where a project wants to use
# code from tempest-incubator, but is not ready to be internationalized
# code from oslo-incubator, but is not ready to be internationalized
# (like tempest)
_ = _LI = _LW = _LE = _LC = lambda x: x

@ -1,99 +0,0 @@
# Copyright 2011 OpenStack Foundation.
# Copyright 2012, Red Hat, Inc.
#
# 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.
"""
Exception related utilities.
"""
import logging
import sys
import time
import traceback
import six
from tempest.openstack.common.gettextutils import _
class save_and_reraise_exception(object):
"""Save current exception, run some code and then re-raise.
In some cases the exception context can be cleared, resulting in None
being attempted to be re-raised after an exception handler is run. This
can happen when eventlet switches greenthreads or when running an
exception handler, code raises and catches an exception. In both
cases the exception context will be cleared.
To work around this, we save the exception state, run handler code, and
then re-raise the original exception. If another exception occurs, the
saved exception is logged and the new exception is re-raised.
In some cases the caller may not want to re-raise the exception, and
for those circumstances this context provides a reraise flag that
can be used to suppress the exception. For example::
except Exception:
with save_and_reraise_exception() as ctxt:
decide_if_need_reraise()
if not should_be_reraised:
ctxt.reraise = False
"""
def __init__(self):
self.reraise = True
def __enter__(self):
self.type_, self.value, self.tb, = sys.exc_info()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is not None:
logging.error(_('Original exception being dropped: %s'),
traceback.format_exception(self.type_,
self.value,
self.tb))
return False
if self.reraise:
six.reraise(self.type_, self.value, self.tb)
def forever_retry_uncaught_exceptions(infunc):
def inner_func(*args, **kwargs):
last_log_time = 0
last_exc_message = None
exc_count = 0
while True:
try:
return infunc(*args, **kwargs)
except Exception as exc:
this_exc_message = six.u(str(exc))
if this_exc_message == last_exc_message:
exc_count += 1
else:
exc_count = 1
# Do not log any more frequently than once a minute unless
# the exception message changes
cur_time = int(time.time())
if (cur_time - last_log_time > 60 or
this_exc_message != last_exc_message):
logging.exception(
_('Unexpected exception occurred %d time(s)... '
'retrying.') % exc_count)
last_log_time = cur_time
last_exc_message = this_exc_message
exc_count = 0
# This should be a very rare event. In case it isn't, do
# a sleep.
time.sleep(1)
return inner_func

<
@ -1,137 +0,0 @@
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# 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 contextlib
import errno
import os
import tempfile
from tempest.openstack.common import excutils
from tempest.openstack.common.gettextutils import _
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)
_FILE_CACHE = {}
def ensure_tree(path):
"""Create a directory (and any ancestor directories required)
:param path: Directory to create
"""
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST:
if not os.path.isdir(path):
raise
else:
raise
def read_cached_file(filename, force_reload=False):
"""Read from a file if it has been modified.
:param force_reload: Whether to reload the file.
:returns: A tuple with a boolean specifying if the data is fresh
or not.
"""
global _FILE_CACHE
if force_reload and filename in _FILE_CACHE:
del _FILE_CACHE[filename]
reloaded = False
mtime = os.path.getmtime(filename)
cache_info = _FILE_CACHE.setdefault(filename, {})
if not cache_info or mtime > cache_info.get('mtime', 0):
LOG.debug(_("Reloading cached file %s") % filename)
with open(filename) as fap:
cache_info['data'] = fap.read()
cache_info['mtime'] = mtime
reloaded = True
return (reloaded, cache_info['data'])
def delete_if_exists(path, remove=os.unlink):
"""Delete a file, but ignore file not found error.
:param path: File to delete
:param remove: Optional function to remove passed path
"""
try:
remove(path)
except OSError as e:
if e.errno != errno.ENOENT:
raise
@contextlib.contextmanager
def remove_path_on_error(path, remove=delete_if_exists):
"""Protect code that wants to operate on PATH atomically.
Any exception will cause PATH to be removed.
:param path: File to work with
:param remove: Optional function to remove passed path
"""
try:
yield
except Exception:
with excutils.save_and_reraise_exception():
remove(path)
def file_open(*args, **kwargs):
"""Open file
see built-in file() documentation for more details
Note: The reason this is kept in a separate module is to easily
be able to provide a stub module that doesn't alter system
state at all (for unit tests)
"""
return file(*args, **kwargs)