Use modules for import not objects

As stated by the document [1], imports should use modules, not objects

[1] http://docs.openstack.org/developer/hacking/#imports

Change-Id: If37db5b501ffc297f583406e01a692379450ee47
This commit is contained in:
Cuong Nguyen 2016-12-09 17:11:30 +07:00
parent f5a9fbe617
commit b136cdbe20
15 changed files with 39 additions and 39 deletions

View File

@ -15,7 +15,7 @@
# under the License.
from oslo_log import log as logging
from designate.backend.base import Backend
from designate.backend import base
LOG = logging.getLogger(__name__)
@ -24,6 +24,6 @@ def get_backend(type_, target):
# TODO(kiall): Type is attached to the target, use it.
LOG.debug("Loading backend driver: %s" % type_)
cls = Backend.get_driver(type_)
cls = base.Backend.get_driver(type_)
return cls(target)

View File

@ -15,7 +15,7 @@
# under the License.
from oslo_log import log as logging
from designate.backend.agent_backend.base import AgentBackend
from designate.backend.agent_backend import base
LOG = logging.getLogger(__name__)
@ -23,6 +23,6 @@ LOG = logging.getLogger(__name__)
def get_backend(backend_driver, agent_service):
LOG.debug("Loading backend driver: %s" % backend_driver)
cls = AgentBackend.get_driver(backend_driver)
cls = base.AgentBackend.get_driver(backend_driver)
return cls(agent_service)

View File

@ -17,7 +17,7 @@
from oslo_config import cfg
from oslo_log import log
from designate.network_api.base import NetworkAPI
from designate.network_api import base
LOG = log.getLogger(__name__)
@ -30,6 +30,6 @@ cfg.CONF.register_opts([
def get_network_api(network_api_driver):
LOG.debug("Loading network_api driver: %s", network_api_driver)
cls = NetworkAPI.get_driver(network_api_driver)
cls = base.NetworkAPI.get_driver(network_api_driver)
return cls()

View File

@ -18,7 +18,7 @@ import uuid
import six
from oslo_log import log as logging
from designate.network_api.base import NetworkAPI
from designate.network_api import base
LOG = logging.getLogger(__name__)
@ -70,7 +70,7 @@ def reset_floatingips():
POOL[key] = allocated.pop(key)
class FakeNetworkAPI(NetworkAPI):
class FakeNetworkAPI(base.NetworkAPI):
__plugin_name__ = 'fake'
def list_floatingips(self, context, region=None):

View File

@ -24,7 +24,7 @@ from oslo_service import threadgroup
from designate import exceptions
from designate.i18n import _LW
from designate.i18n import _LE
from designate.network_api.base import NetworkAPI
from designate.network_api import base
CONF = cfg.CONF
@ -84,7 +84,7 @@ def get_client(context, endpoint):
return clientv20.Client(**params)
class NeutronNetworkAPI(NetworkAPI):
class NeutronNetworkAPI(base.NetworkAPI):
"""
Interact with the Neutron API
"""

View File

@ -16,7 +16,7 @@
from oslo_log import log
from designate.notification_handler.base import NotificationHandler
from designate.notification_handler import base
LOG = log.getLogger(__name__)
@ -25,6 +25,6 @@ LOG = log.getLogger(__name__)
def get_notification_handlers(enabled_extensions):
LOG.debug("Loading notification handlers")
extensions = NotificationHandler.get_extensions(enabled_extensions)
extensions = base.NotificationHandler.get_extensions(enabled_extensions)
return [e() for e in extensions]

View File

@ -16,7 +16,7 @@
from oslo_config import cfg
from oslo_log import log as logging
from designate.notification_handler.base import BaseAddressHandler
from designate.notification_handler import base
LOG = logging.getLogger(__name__)
@ -38,7 +38,7 @@ cfg.CONF.register_opts([
], group='handler:neutron_floatingip')
class NeutronFloatingHandler(BaseAddressHandler):
class NeutronFloatingHandler(base.BaseAddressHandler):
"""Handler for Neutron's notifications"""
__plugin_name__ = 'neutron_floatingip'

View File

@ -15,13 +15,13 @@
# under the License.
from oslo_log import log as logging
from designate.pool_manager.cache.base import PoolManagerCache
from designate.pool_manager.cache import base
LOG = logging.getLogger(__name__)
def get_pool_manager_cache(cache_driver):
"""Return the engine class from the provided engine name"""
cls = PoolManagerCache.get_driver(cache_driver)
cls = base.PoolManagerCache.get_driver(cache_driver)
return cls()

View File

@ -16,7 +16,7 @@
from oslo_config import cfg
from oslo_log import log as logging
from designate.quota.base import Quota
from designate.quota import base
LOG = logging.getLogger(__name__)
@ -42,6 +42,6 @@ def get_quota():
LOG.debug("Loading quota driver: %s" % quota_driver)
cls = Quota.get_driver(quota_driver)
cls = base.Quota.get_driver(quota_driver)
return cls()

View File

@ -15,12 +15,12 @@
# under the License.
from oslo_log import log as logging
from designate.quota.base import Quota
from designate.quota import base
LOG = logging.getLogger(__name__)
class NoopQuota(Quota):
class NoopQuota(base.Quota):
__plugin_name__ = 'noop'
def _get_quotas(self, context, tenant_id):

View File

@ -20,14 +20,14 @@ from oslo_log import log as logging
from designate import exceptions
from designate import storage
from designate import objects
from designate.quota.base import Quota
from designate.quota import base
from designate.storage import transaction
LOG = logging.getLogger(__name__)
class StorageQuota(Quota):
class StorageQuota(base.Quota):
__plugin_name__ = 'storage'
def __init__(self):

View File

@ -23,7 +23,7 @@ from oslo_log import log as logging
from oslo_db import exception as db_exception
from oslo_utils import excutils
from designate.storage.base import Storage
from designate.storage import base
from designate.i18n import _LW
@ -33,7 +33,7 @@ RETRY_STATE = threading.local()
def get_storage(storage_driver):
"""Return the engine class from the provided engine name"""
cls = Storage.get_driver(storage_driver)
cls = base.Storage.get_driver(storage_driver)
return cls()

View File

@ -17,7 +17,7 @@ import testtools
from designate import exceptions
from designate import objects
from designate.pool_manager.cache.base import PoolManagerCache
from designate.pool_manager.cache import base
class PoolManagerCacheTestCase(object):
@ -32,7 +32,7 @@ class PoolManagerCacheTestCase(object):
return objects.PoolManagerStatus.from_dict(values)
def test_interface(self):
self._ensure_interface(PoolManagerCache, self.cache.__class__)
self._ensure_interface(base.PoolManagerCache, self.cache.__class__)
def test_store_and_clear_and_retrieve(self):
expected = self.create_pool_manager_status()

View File

@ -216,8 +216,8 @@ class DesignateObjectTest(oslotest.base.BaseTestCase):
@unittest.expectedFailure # bug
def test__schema_ref_resolver(self):
from designate.objects.base import _schema_ref_resolver
_schema_ref_resolver(
from designate.objects import base
base._schema_ref_resolver(
'obj://TestValidatableObject#/subpathA/subpathB')
def test_init_invalid(self):

View File

@ -17,21 +17,21 @@ limitations under the License.
from oslo_config import cfg
from tempest.lib import exceptions
from functionaltests.api.v2.clients.quotas_client import QuotasClient
from functionaltests.api.v2.clients.tld_client import TLDClient
from functionaltests.api.v2.models.quotas_model import QuotasModel
from functionaltests.api.v2.models.tld_model import TLDModel
from functionaltests.common.base import BaseDesignateTest
from functionaltests.api.v2.clients import quotas_client
from functionaltests.api.v2.clients import tld_client
from functionaltests.api.v2.models import quotas_model
from functionaltests.api.v2.models import tld_model
from functionaltests.common import base
class DesignateV2Test(BaseDesignateTest):
class DesignateV2Test(base.BaseDesignateTest):
def increase_quotas(self, user):
if cfg.CONF.testconfig.no_admin_setup:
return
QuotasClient.as_user('admin').patch_quotas(
QuotasClient.as_user(user).tenant_id,
QuotasModel.from_dict({
quotas_client.QuotasClient.as_user('admin').patch_quotas(
quotas_client.QuotasClient.as_user(user).tenant_id,
quotas_model.QuotasModel.from_dict({
'quota': {
'zones': 9999999,
'recordset_records': 9999999,
@ -45,8 +45,8 @@ class DesignateV2Test(BaseDesignateTest):
if cfg.CONF.testconfig.no_admin_setup:
return
try:
tld_model = TLDModel.from_dict({'name': tld})
TLDClient.as_user('admin').post_tld(tld_model)
_tld_model = tld_model.TLDModel.from_dict({'name': tld})
tld_client.TLDClient.as_user('admin').post_tld(_tld_model)
except exceptions.Conflict:
pass