Browse Source

Remove imports from oslo namespaces

Oslo team is recommending everyone to use the direct imports and
not use the Oslo namespaces. So switch all our code to use oslo_*
instead of "from oslo." or "import oslo" or "from oslo"

NOTE: some of the tests still have mocks referring to oslo.utils
@mock.patch('oslo.utils.timeutils.utcnow')
as the tests break otherwise. We should do this later.

Closes-bug: #1419385
Change-Id: I8e3fbeb833cddc3f55674a0e781ffe69d5033ad4
changes/05/153805/4
Davanum Srinivas 8 years ago committed by Davanum Srinivas (dims)
parent
commit
17c5711c55
  1. 2
      magnum/api/app.py
  2. 2
      magnum/api/auth.py
  3. 2
      magnum/api/controllers/v1/types.py
  4. 2
      magnum/api/controllers/v1/utils.py
  5. 4
      magnum/api/hooks.py
  6. 2
      magnum/cmd/api.py
  7. 2
      magnum/cmd/conductor.py
  8. 6
      magnum/cmd/db_manage.py
  9. 2
      magnum/common/clients.py
  10. 2
      magnum/common/config.py
  11. 4
      magnum/common/exception.py
  12. 4
      magnum/common/magnum_keystoneclient.py
  13. 2
      magnum/common/paths.py
  14. 4
      magnum/common/rpc.py
  15. 4
      magnum/common/rpc_service.py
  16. 2
      magnum/common/service.py
  17. 2
      magnum/common/urlfetch.py
  18. 4
      magnum/common/utils.py
  19. 2
      magnum/conductor/api.py
  20. 2
      magnum/conductor/config.py
  21. 2
      magnum/conductor/handlers/bay_k8s_heat.py
  22. 2
      magnum/conductor/handlers/common/docker_client.py
  23. 2
      magnum/conductor/handlers/docker_conductor.py
  24. 2
      magnum/conductor/handlers/kube.py
  25. 2
      magnum/config.py
  26. 4
      magnum/db/api.py
  27. 4
      magnum/db/migration.py
  28. 10
      magnum/db/sqlalchemy/api.py
  29. 2
      magnum/db/sqlalchemy/migration.py
  30. 6
      magnum/db/sqlalchemy/models.py
  31. 2
      magnum/objects/base.py
  32. 2
      magnum/objects/utils.py
  33. 2
      magnum/openstack/common/eventlet_backdoor.py
  34. 4
      magnum/openstack/common/log.py
  35. 2
      magnum/openstack/common/periodic_task.py
  36. 2
      magnum/openstack/common/service.py
  37. 2
      magnum/tests/__init__.py
  38. 2
      magnum/tests/api/base.py
  39. 8
      magnum/tests/api/controllers/v1/test_bay.py
  40. 8
      magnum/tests/api/controllers/v1/test_baymodel.py
  41. 8
      magnum/tests/api/controllers/v1/test_node.py
  42. 8
      magnum/tests/api/controllers/v1/test_pod.py
  43. 8
      magnum/tests/api/controllers/v1/test_replicationcontroller.py
  44. 6
      magnum/tests/api/controllers/v1/test_service.py
  45. 2
      magnum/tests/api/controllers/v1/test_utils.py
  46. 2
      magnum/tests/api/test_auth.py
  47. 4
      magnum/tests/api/test_hooks.py
  48. 2
      magnum/tests/base.py
  49. 2
      magnum/tests/common/test_magnum_keystoneclient.py
  50. 2
      magnum/tests/common/test_urlfetch.py
  51. 2
      magnum/tests/common/test_utils.py
  52. 2
      magnum/tests/conductor/handlers/test_kube.py
  53. 2
      magnum/tests/conf_fixture.py
  54. 2
      magnum/tests/db/base.py
  55. 2
      magnum/tests/db/sqlalchemy/test_types.py
  56. 2
      magnum/tests/objects/test_objects.py
  57. 4
      magnum/tests/utils.py

2
magnum/api/app.py

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from oslo_config import cfg
import pecan
from magnum.api import auth

2
magnum/api/auth.py

@ -15,7 +15,7 @@
# under the License.
"""Access Control Lists (ACL's) control access the API server."""
from oslo.config import cfg
from oslo_config import cfg
from magnum.api.middleware import auth_token

2
magnum/api/controllers/v1/types.py

@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import strutils
from oslo_utils import strutils
import wsme
from wsme import types as wtypes

2
magnum/api/controllers/v1/utils.py

@ -14,7 +14,7 @@
# under the License.
import jsonpatch
from oslo.config import cfg
from oslo_config import cfg
import wsme
from magnum.openstack.common._i18n import _

4
magnum/api/hooks.py

@ -15,8 +15,8 @@
# under the License.
from oslo.config import cfg
from oslo.utils import importutils
from oslo_config import cfg
from oslo_utils import importutils
from pecan import hooks
from magnum.common import context

2
magnum/cmd/api.py

@ -19,7 +19,7 @@ import os
import sys
from wsgiref import simple_server
from oslo.config import cfg
from oslo_config import cfg
from magnum.api import app as api_app
from magnum.common import service

2
magnum/cmd/conductor.py

@ -18,7 +18,7 @@ import logging as std_logging
import os
import sys
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import rpc_service as service
from magnum.conductor.handlers import bay_k8s_heat

6
magnum/cmd/db_manage.py

@ -15,9 +15,9 @@
import os
from oslo.config import cfg
from oslo.db import options
from oslo.db.sqlalchemy.migration_cli import manager
from oslo_config import cfg
from oslo_db import options
from oslo_db.sqlalchemy.migration_cli import manager
from magnum.openstack.common import log as logging

2
magnum/common/clients.py

@ -13,7 +13,7 @@
# under the License.
from heatclient.v1 import client as heatclient
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import exception
from magnum.common import magnum_keystoneclient

2
magnum/common/config.py

@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import rpc
from magnum import version

4
magnum/common/exception.py

@ -23,8 +23,8 @@ import sys
import uuid
from keystoneclient import exceptions as keystone_exceptions
from oslo.config import cfg
from oslo.utils import excutils
from oslo_config import cfg
from oslo_utils import excutils
import pecan
import six
import wsme

4
magnum/common/magnum_keystoneclient.py

@ -16,8 +16,8 @@ import copy
import keystoneclient.exceptions as kc_exception
from keystoneclient.v3 import client as kc_v3
from oslo.config import cfg
from oslo.utils import importutils
from oslo_config import cfg
from oslo_utils import importutils
from magnum.common import context
from magnum.common import exception

2
magnum/common/paths.py

@ -17,7 +17,7 @@
import os
from oslo.config import cfg
from oslo_config import cfg
PATH_OPTS = [
cfg.StrOpt('pybasedir',

4
magnum/common/rpc.py

@ -27,8 +27,8 @@ __all__ = [
'TRANSPORT_ALIASES',
]
from oslo.config import cfg
from oslo import messaging
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_serialization import jsonutils
from magnum.common import context as magnum_context

4
magnum/common/rpc_service.py

@ -15,8 +15,8 @@
"""Common RPC service and API tools for Magnum."""
import eventlet
from oslo.config import cfg
from oslo import messaging
from oslo_config import cfg
import oslo_messaging as messaging
import magnum.common.context
from magnum.objects import base as objects_base

2
magnum/common/service.py

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from oslo_config import cfg
from magnum.openstack.common import log as logging

2
magnum/common/urlfetch.py

@ -13,7 +13,7 @@
"""Utility for fetching a resource (e.g. a manifest) from a URL."""
from oslo.config import cfg
from oslo_config import cfg
import requests
from requests import exceptions
from six.moves import urllib

4
magnum/common/utils.py

@ -29,9 +29,9 @@ import tempfile
import uuid
import netaddr
from oslo.config import cfg
from oslo.utils import excutils
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_utils import excutils
import paramiko
import six

2
magnum/conductor/api.py

@ -11,7 +11,7 @@
# limitations under the License.
"""API for interfacing with Magnum Backend."""
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import rpc_service
from magnum import objects

2
magnum/conductor/config.py

@ -15,7 +15,7 @@
"""Config options for Magnum Backend service."""
from oslo.config import cfg
from oslo_config import cfg
SERVICE_OPTS = [
cfg.StrOpt('topic',

2
magnum/conductor/handlers/bay_k8s_heat.py

@ -14,7 +14,7 @@
from heatclient.common import template_utils
from heatclient import exc
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import clients
from magnum.common import short_id

2
magnum/conductor/handlers/common/docker_client.py

@ -14,7 +14,7 @@
from docker import client
from docker import tls
from oslo.config import cfg
from oslo_config import cfg
from magnum.openstack.common import log as logging

2
magnum/conductor/handlers/docker_conductor.py

@ -13,7 +13,7 @@
"""Magnum Docker RPC handler."""
from docker import errors
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import docker_utils
from magnum.conductor.handlers.common import docker_client

2
magnum/conductor/handlers/kube.py

@ -12,7 +12,7 @@
"""Magnum Kubernetes RPC handler."""
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import clients
from magnum.conductor.handlers.common import kube_utils

2
magnum/config.py

@ -14,7 +14,7 @@
"""Magnum specific config handling."""
from oslo.config import cfg
from oslo_config import cfg
from magnum import version

4
magnum/db/api.py

@ -19,8 +19,8 @@ Base classes for storage engines
import abc
from oslo.config import cfg
from oslo.db import api as db_api
from oslo_config import cfg
from oslo_db import api as db_api
import six

4
magnum/db/migration.py

@ -16,7 +16,7 @@
"""Database setup and migration commands."""
from oslo.config import cfg
from oslo_config import cfg
from stevedore import driver
_IMPL = None
@ -25,7 +25,7 @@ _IMPL = None
def get_backend():
global _IMPL
if not _IMPL:
cfg.CONF.import_opt('backend', 'oslo.db.options', group='database')
cfg.CONF.import_opt('backend', 'oslo_db.options', group='database')
_IMPL = driver.DriverManager("magnum.database.migration_backend",
cfg.CONF.database.backend).driver
return _IMPL

10
magnum/db/sqlalchemy/api.py

@ -16,11 +16,11 @@
"""SQLAlchemy storage backend."""
from oslo.config import cfg
from oslo.db import exception as db_exc
from oslo.db.sqlalchemy import session as db_session
from oslo.db.sqlalchemy import utils as db_utils
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import session as db_session
from oslo_db.sqlalchemy import utils as db_utils
from oslo_utils import timeutils
from sqlalchemy.orm.exc import NoResultFound
from magnum.common import exception

2
magnum/db/sqlalchemy/migration.py

@ -19,7 +19,7 @@ import os
import alembic
from alembic import config as alembic_config
import alembic.migration as alembic_migration
from oslo.db import exception as db_exc
from oslo_db import exception as db_exc
from magnum.db.sqlalchemy import api as sqla_api
from magnum.db.sqlalchemy import models

6
magnum/db/sqlalchemy/models.py

@ -20,9 +20,9 @@ SQLAlchemy models for container service
import json
from oslo.config import cfg
from oslo.db import options as db_options
from oslo.db.sqlalchemy import models
from oslo_config import cfg
from oslo_db import options as db_options
from oslo_db.sqlalchemy import models
import six.moves.urllib.parse as urlparse
from sqlalchemy import Column
from sqlalchemy.ext.declarative import declarative_base

2
magnum/objects/base.py

@ -17,8 +17,8 @@
import collections
import copy
from oslo import messaging
from oslo_context import context
import oslo_messaging as messaging
import six
from magnum.common import exception

2
magnum/objects/utils.py

@ -19,7 +19,7 @@ import datetime
import iso8601
import netaddr
from oslo.utils import timeutils
from oslo_utils import timeutils
import six
from magnum.openstack.common._i18n import _

2
magnum/openstack/common/eventlet_backdoor.py

@ -28,7 +28,7 @@ import traceback
import eventlet
import eventlet.backdoor
import greenlet
from oslo.config import cfg
from oslo_config import cfg
from magnum.openstack.common._i18n import _LI
from magnum.openstack.common import log as logging

4
magnum/openstack/common/log.py

@ -38,9 +38,9 @@ import socket
import sys
import traceback
from oslo.config import cfg
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo.utils import importutils
from oslo_utils import importutils
import six
from six import moves

2
magnum/openstack/common/periodic_task.py

@ -15,7 +15,7 @@ import copy
import random
import time
from oslo.config import cfg
from oslo_config import cfg
import six
from magnum.openstack.common._i18n import _, _LE, _LI

2
magnum/openstack/common/service.py

@ -35,7 +35,7 @@ except ImportError:
import eventlet
from eventlet import event
from oslo.config import cfg
from oslo_config import cfg
from magnum.openstack.common import eventlet_backdoor
from magnum.openstack.common._i18n import _LE, _LI, _LW

2
magnum/tests/__init__.py

@ -13,7 +13,7 @@
import os
import unittest
from oslo.config import cfg
from oslo_config import cfg
import pecan
from pecan import testing

2
magnum/tests/api/base.py

@ -22,7 +22,7 @@
# NOTE(deva): import auth_token so we can override a config option
from keystonemiddleware import auth_token # noqa
from oslo.config import cfg
from oslo_config import cfg
import pecan
import pecan.testing
from six.moves.urllib import parse as urlparse

8
magnum/tests/api/controllers/v1/test_bay.py

@ -13,8 +13,8 @@
import datetime
import mock
from oslo.config import cfg
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
@ -130,7 +130,7 @@ class TestPatch(api_base.FunctionalTest):
name='bay_example_A',
node_count=3)
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_replace_ok(self, mock_utcnow):
name = 'bay_example_B'
test_time = datetime.datetime(2000, 1, 1, 0, 0)
@ -293,7 +293,7 @@ class TestPost(api_base.FunctionalTest):
bay.create()
return bay
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_create_bay(self, mock_utcnow):
bdict = apiutils.bay_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)

8
magnum/tests/api/controllers/v1/test_baymodel.py

@ -13,8 +13,8 @@
import datetime
import mock
from oslo.config import cfg
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
@ -138,7 +138,7 @@ class TestPatch(api_base.FunctionalTest):
self.assertEqual('application/json', response.content_type)
self.assertTrue(response.json['error_message'])
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_replace_singular(self, mock_utcnow):
name = 'bay_model_example_B'
test_time = datetime.datetime(2000, 1, 1, 0, 0)
@ -249,7 +249,7 @@ class TestPost(api_base.FunctionalTest):
def setUp(self):
super(TestPost, self).setUp()
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_create_baymodel(self, mock_utcnow):
cdict = apiutils.baymodel_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)

8
magnum/tests/api/controllers/v1/test_node.py

@ -13,8 +13,8 @@
import datetime
import mock
from oslo.config import cfg
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
@ -120,7 +120,7 @@ class TestPatch(api_base.FunctionalTest):
super(TestPatch, self).setUp()
self.node = obj_utils.create_test_node(self.context, image_id='Fedora')
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_replace_ok(self, mock_utcnow):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
@ -199,7 +199,7 @@ class TestPatch(api_base.FunctionalTest):
class TestPost(api_base.FunctionalTest):
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_create_node(self, mock_utcnow):
node_dict = apiutils.node_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)

8
magnum/tests/api/controllers/v1/test_pod.py

@ -13,8 +13,8 @@
import datetime
import mock
from oslo.config import cfg
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
@ -129,7 +129,7 @@ class TestPatch(api_base.FunctionalTest):
desc='pod_example_A_desc',
status='Running')
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_replace_ok(self, mock_utcnow):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
@ -293,7 +293,7 @@ class TestPost(api_base.FunctionalTest):
pod.create()
return pod
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_create_pod(self, mock_utcnow):
pdict = apiutils.pod_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)

8
magnum/tests/api/controllers/v1/test_replicationcontroller.py

@ -13,8 +13,8 @@
import datetime
import mock
from oslo.config import cfg
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
@ -129,7 +129,7 @@ class TestPatch(api_base.FunctionalTest):
self.rc = obj_utils.create_test_rc(self.context,
images=['rc_example_A_image'])
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_replace_ok(self, mock_utcnow):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
@ -269,7 +269,7 @@ class TestPost(api_base.FunctionalTest):
rc.create(self.context)
return rc
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_create_rc(self, mock_utcnow):
rc_dict = apiutils.rc_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)

6
magnum/tests/api/controllers/v1/test_service.py

@ -13,8 +13,8 @@
import datetime
import mock
from oslo.config import cfg
from oslo.utils import timeutils
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
@ -225,7 +225,7 @@ class TestPost(api_base.FunctionalTest):
service.create()
return service
@mock.patch.object(timeutils, 'utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_create_service(self, mock_utcnow):
sdict = apiutils.service_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)

2
magnum/tests/api/controllers/v1/test_utils.py

@ -18,7 +18,7 @@ import wsme
from magnum.api.controllers.v1 import utils
from magnum.tests.api import base
from oslo.config import cfg
from oslo_config import cfg
CONF = cfg.CONF

2
magnum/tests/api/test_auth.py

@ -14,7 +14,7 @@
# limitations under the License.
import mock
from oslo.config import fixture
from oslo_config import fixture
from magnum.api import auth
from magnum.tests import base

4
magnum/tests/api/test_hooks.py

@ -16,8 +16,8 @@
import json
import mock
from oslo.config import cfg
from oslo import messaging
from oslo_config import cfg
import oslo_messaging as messaging
from magnum.api.controllers import root
from magnum.api import hooks

2
magnum/tests/base.py

@ -19,7 +19,7 @@ import copy
import os
import mock
from oslo.config import cfg
from oslo_config import cfg
from oslotest import base
import pecan
from pecan import testing

2
magnum/tests/common/test_magnum_keystoneclient.py

@ -13,7 +13,7 @@
# under the License.
import mock
from oslo.config import cfg
from oslo_config import cfg
cfg.CONF.import_group('keystone_authtoken',
'keystonemiddleware.auth_token')

2
magnum/tests/common/test_urlfetch.py

@ -12,7 +12,7 @@
import mock
from mock import patch
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import urlfetch
from magnum.tests import base

2
magnum/tests/common/test_utils.py

@ -23,8 +23,8 @@ import uuid
import mock
import netaddr
from oslo.config import cfg
from oslo_concurrency import processutils
from oslo_config import cfg
import six
import six.moves.builtins as __builtin__

2
magnum/tests/conductor/handlers/test_kube.py

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
from magnum.conductor.handlers import kube
from magnum import objects

2
magnum/tests/conf_fixture.py

@ -15,7 +15,7 @@
# under the License.
import fixtures
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import config

2
magnum/tests/db/base.py

@ -19,7 +19,7 @@ import os
import shutil
import fixtures
from oslo.config import cfg
from oslo_config import cfg
from magnum.common import paths
from magnum.db import api as dbapi

2
magnum/tests/db/sqlalchemy/test_types.py

@ -12,7 +12,7 @@
"""Tests for custom SQLAlchemy types via Magnum DB."""
from oslo.db import exception as db_exc
from oslo_db import exception as db_exc
from magnum.common import utils as magnum_utils
from magnum.db import api as dbapi

2
magnum/tests/objects/test_objects.py

@ -17,7 +17,7 @@ import gettext
import iso8601
import netaddr
from oslo.utils import timeutils
from oslo_utils import timeutils
import six
from magnum.common import context

4
magnum/tests/utils.py

@ -15,8 +15,8 @@
import tempfile
import fixtures
from oslo.config import cfg
from oslo.db import options
from oslo_config import cfg
from oslo_db import options
from magnum.common import context
from magnum.db import api as db_api

Loading…
Cancel
Save