Restruct the project

Move all modules under the next structure:

- rally_openstack.common
- rally_openstack.enviromnet
- rally_openstack.task
- rally_openstack.verification

Change-Id: I41702d017cd49b117da3b8e12b19c7327229ae32
This commit is contained in:
Andrey Kurilin 2020-03-26 16:02:04 +02:00
parent e43b0728c8
commit d2f4e9717d
504 changed files with 1148 additions and 915 deletions

View File

@ -34,6 +34,30 @@ Changed
* Bump min supported Rally framework version (rally>=3.0.0)
Deprecated
~~~~~~~~~~
* a huge project restructure had happened. Old paths are deprecated now.
rally_openstack.cfg -> rally_openstack.common.cfg
rally_openstack.cleanup -> rally_openstack.task.cleanup
rally_openstack.consts -> rally_openstack.common.consts
rally_openstack.contexts -> rally_openstack.task.contexts
rally_openstack.credential -> rally_openstack.common.credential
rally_openstack.embedcharts -> rally_openstack.task.ui.charts
rally_openstack.exceptions -> rally_openstack.common.exceptions
rally_openstack.hook -> rally_openstack.task.hooks
rally_openstack.osclients -> rally_openstack.common.osclients
rally_openstack.platforms -> rally_openstack.environment.platforms
rally_openstack.scenario -> rally_openstack.task.scenario
rally_openstack.scenarios -> rally_openstack.task.scenarios
rally_openstack.service -> rally_openstack.common.service
rally_openstack.services -> rally_openstack.common.services
rally_openstack.types -> rally_openstack.task.types
rally_openstack.validators -> rally_openstack.common.validators
rally_openstack.wrappers -> rally_openstack.common.wrappers
Removed
~~~~~~~

View File

@ -15,9 +15,17 @@
import pbr.version
from rally.common import version as __rally_version__
from rally_openstack import _compat
__rally_version__ = __rally_version__.version_info.semantic_version()
__rally_version__ = __rally_version__.version_tuple()
__version_info__ = pbr.version.VersionInfo("rally-openstack")
__version__ = __version_info__.version_string()
__version_tuple__ = __version_info__.semantic_version().version_tuple()
# WARNING: IF YOU ARE LOOKING FOR SOME PHYSICALLY UNEXISTING MODULES THAT CAN
# BE IMPORTED (FOR BACKWARD COMPATIBILITY), PLEASE CHECK THE NEXT FUNCTION
# HAPPY DEBUGGING!!
_compat.init()

199
rally_openstack/_compat.py Normal file
View File

@ -0,0 +1,199 @@
# 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 importlib
import importlib.abc
import importlib.machinery
import importlib.util
import sys
import warnings
class _MoveSpec(object):
def __init__(self, deprecated, new, release):
"""init moved module info
:param deprecated: a module name that is deprecated
:param new: a module name that should be used instead
:param release: A release when the module was deprecated
"""
self.deprecated = deprecated
self.new = new
self.deprecated_path = self.deprecated.replace(".", "/")
self.new_path = self.new.replace(".", "/")
self.release = release
def get_new_name(self, fullname):
"""Get the new name for deprecated module."""
return fullname.replace(self.deprecated, self.new)
def get_deprecated_path(self, path):
"""Get a path to the deprecated module."""
return path.replace(self.new_path, self.deprecated_path)
_MOVES = [
_MoveSpec(
deprecated="rally_openstack.embedcharts",
new="rally_openstack.task.ui.charts",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.cleanup",
new="rally_openstack.task.cleanup",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.contexts",
new="rally_openstack.task.contexts",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.hook",
new="rally_openstack.task.hooks",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.scenario",
new="rally_openstack.task.scenario",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.scenarios",
new="rally_openstack.task.scenarios",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.types",
new="rally_openstack.task.types",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.platforms",
new="rally_openstack.environment.platforms",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.service",
new="rally_openstack.common.service",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.services",
new="rally_openstack.common.services",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.validators",
new="rally_openstack.common.validators",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.wrappers",
new="rally_openstack.common.wrappers",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.credential",
new="rally_openstack.common.credential",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.osclients",
new="rally_openstack.common.osclients",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.consts",
new="rally_openstack.common.consts",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.exceptions",
new="rally_openstack.common.exceptions",
release="2.0.0"
),
_MoveSpec(
deprecated="rally_openstack.cfg",
new="rally_openstack.common.cfg",
release="2.0.0"
),
]
class ModuleLoader(object):
def __init__(self, move_spec):
self.move_spec = move_spec
def create_module(self, spec):
# Python interpreter will use the default module creator in case of
# None return value.
return None
def exec_module(self, module):
"""Module executor."""
full_name = self.move_spec.get_new_name(module.__name__)
original_module = importlib.import_module(full_name)
if original_module.__file__.endswith("__init__.py"):
# NOTE(andreykurilin): In case we need to list submodules the
# next code can be used:
#
# import pkgutil
#
# for m in pkgutil.iter_modules(original_module.__path__):
# module.__dict__[m.name] = importlib.import_module(
# f"{full_name}.{m.name}")
module.__path__ = [
self.move_spec.get_deprecated_path(original_module.__path__[0])
]
for item in dir(original_module):
if item.startswith("_"):
continue
module.__dict__[item] = original_module.__dict__[item]
module.__file__ = self.move_spec.get_deprecated_path(
original_module.__file__)
return module
class ModulesMovementsHandler(importlib.abc.MetaPathFinder):
@classmethod
def _process_spec(cls, fullname, spec):
"""Make module spec and print warning message if needed."""
if spec.deprecated == fullname:
warnings.warn(
f"Module {fullname} is deprecated since rally-openstack "
f"{spec.release}. Use {spec.get_new_name(fullname)} instead.",
stacklevel=3
)
return importlib.machinery.ModuleSpec(fullname, ModuleLoader(spec))
@classmethod
def find_spec(cls, fullname, path=None, target=None):
"""This functions is what gets executed by the loader."""
for spec in _MOVES:
if spec.deprecated in fullname:
return cls._process_spec(fullname, spec)
def init():
"""Adds our custom module loader."""
sys.meta_path.append(ModulesMovementsHandler())

View File

@ -13,33 +13,33 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally_openstack.cfg import cinder
from rally_openstack.cfg import glance
from rally_openstack.cfg import heat
from rally_openstack.cfg import ironic
from rally_openstack.cfg import magnum
from rally_openstack.cfg import manila
from rally_openstack.cfg import mistral
from rally_openstack.cfg import monasca
from rally_openstack.cfg import murano
from rally_openstack.cfg import neutron
from rally_openstack.cfg import nova
from rally_openstack.cfg import octavia
from rally_openstack.cfg import osclients
from rally_openstack.cfg import profiler
from rally_openstack.cfg import sahara
from rally_openstack.cfg import senlin
from rally_openstack.cfg import vm
from rally_openstack.cfg import watcher
from rally_openstack.common.cfg import cinder
from rally_openstack.common.cfg import glance
from rally_openstack.common.cfg import heat
from rally_openstack.common.cfg import ironic
from rally_openstack.common.cfg import magnum
from rally_openstack.common.cfg import manila
from rally_openstack.common.cfg import mistral
from rally_openstack.common.cfg import monasca
from rally_openstack.common.cfg import murano
from rally_openstack.common.cfg import neutron
from rally_openstack.common.cfg import nova
from rally_openstack.common.cfg import octavia
from rally_openstack.common.cfg import osclients
from rally_openstack.common.cfg import profiler
from rally_openstack.common.cfg import sahara
from rally_openstack.common.cfg import senlin
from rally_openstack.common.cfg import vm
from rally_openstack.common.cfg import watcher
from rally_openstack.cfg import tempest
from rally_openstack.common.cfg import tempest
from rally_openstack.cfg import keystone_roles
from rally_openstack.cfg import keystone_users
from rally_openstack.common.cfg import keystone_roles
from rally_openstack.common.cfg import keystone_users
from rally_openstack.cfg import cleanup
from rally_openstack.common.cfg import cleanup
from rally_openstack.embedcharts import osprofilerchart
from rally_openstack.task.ui.charts import osprofilerchart
def list_opts():

View File

@ -76,7 +76,7 @@ class OpenStackCredential(dict):
# this method is mostly used by validation step. let's refactor it and
# deprecated this
def clients(self, api_info=None):
from rally_openstack import osclients
from rally_openstack.common import osclients
return osclients.Clients(self, api_info=api_info,
cache=self._clients_cache)

View File

@ -23,8 +23,8 @@ from rally.common import logging
from rally.common.plugin import plugin
from rally import exceptions
from rally_openstack import consts
from rally_openstack import credential as oscred
from rally_openstack.common import consts
from rally_openstack.common import credential as oscred
LOG = logging.getLogger(__name__)
@ -875,7 +875,7 @@ class Clients(object):
@classmethod
def create_from_env(cls):
from rally_openstack import credential
from rally_openstack.common import credential
from rally_openstack.platforms import existing
spec = existing.OpenStack.create_spec_from_sys_environ(os.environ)

View File

@ -14,8 +14,8 @@
from rally.task import atomic
from rally_openstack import osclients
from rally_openstack.services.identity import identity
from rally_openstack.common import osclients
from rally_openstack.common.services.identity import identity
class UnifiedKeystoneMixin(object):

View File

@ -16,9 +16,9 @@ import uuid
from rally.task import atomic
from rally_openstack import service
from rally_openstack.services.identity import identity
from rally_openstack.services.identity import keystone_common
from rally_openstack.common import service
from rally_openstack.common.services.identity import identity
from rally_openstack.common.services.identity import keystone_common
@service.service("keystone", service_type="identity", version="2")

View File

@ -16,9 +16,9 @@ from rally.common import logging
from rally import exceptions
from rally.task import atomic
from rally_openstack import service
from rally_openstack.services.identity import identity
from rally_openstack.services.identity import keystone_common
from rally_openstack.common import service
from rally_openstack.common.services.identity import identity
from rally_openstack.common.services.identity import keystone_common
LOG = logging.getLogger(__name__)

View File

@ -15,7 +15,7 @@
from rally import exceptions
from rally.task import atomic
from rally_openstack.services.image import image as image_service
from rally_openstack.common.services.image import image as image_service
class GlanceMixin(object):

View File

@ -19,9 +19,9 @@ from rally.common import utils as rutils
from rally.task import atomic
from rally.task import utils
from rally_openstack import service
from rally_openstack.services.image import glance_common
from rally_openstack.services.image import image
from rally_openstack.common import service
from rally_openstack.common.services.image import glance_common
from rally_openstack.common.services.image import image
CONF = cfg.CONF

View File

@ -21,9 +21,9 @@ from rally.task import atomic
from rally.task import utils
import requests
from rally_openstack import service
from rally_openstack.services.image import glance_common
from rally_openstack.services.image import image
from rally_openstack.common import service
from rally_openstack.common.services.image import glance_common
from rally_openstack.common.services.image import image
CONF = cfg.CONF

View File

@ -18,8 +18,8 @@ from rally import exceptions
from rally.task import atomic
from rally.task import utils as bench_utils
from rally_openstack.services.image import image
from rally_openstack.services.storage import block
from rally_openstack.common.services.image import image
from rally_openstack.common.services.storage import block
CONF = block.CONF

View File

@ -17,9 +17,9 @@ import random
from rally.common import utils as rutils
from rally.task import atomic
from rally_openstack import service
from rally_openstack.services.storage import block
from rally_openstack.services.storage import cinder_common
from rally_openstack.common import service
from rally_openstack.common.services.storage import block
from rally_openstack.common.services.storage import cinder_common
CONF = block.CONF

View File

@ -17,9 +17,9 @@ import random
from rally.common import utils as rutils
from rally.task import atomic
from rally_openstack import service
from rally_openstack.services.storage import block
from rally_openstack.services.storage import cinder_common
from rally_openstack.common import service
from rally_openstack.common.services.storage import block
from rally_openstack.common.services.storage import cinder_common
CONF = block.CONF

View File

@ -17,9 +17,9 @@ import random
from rally.common import utils as rutils
from rally.task import atomic
from rally_openstack import service
from rally_openstack.services.storage import block
from rally_openstack.services.storage import cinder_common
from rally_openstack.common import service
from rally_openstack.common.services.storage import block
from rally_openstack.common.services.storage import cinder_common
CONF = block.CONF

View File

@ -25,10 +25,10 @@ from rally import exceptions
from rally.plugins.common import validators
from rally.task import types
from rally_openstack import consts
from rally_openstack.contexts.keystone import roles
from rally_openstack.contexts.nova import flavors as flavors_ctx
from rally_openstack import types as openstack_types
from rally_openstack.common import consts
from rally_openstack.task.contexts.keystone import roles
from rally_openstack.task.contexts.nova import flavors as flavors_ctx
from rally_openstack.task import types as openstack_types
LOG = logging.getLogger(__name__)

View File

@ -23,7 +23,7 @@ from rally.common import logging
from rally.common import utils
from rally import exceptions
from rally_openstack import consts
from rally_openstack.common import consts
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ import traceback
from rally.common import cfg
from rally.common import logging
from rally.env import platform
from rally_openstack import osclients
from rally_openstack.common import osclients
LOG = logging.getLogger(__name__)

View File

@ -20,7 +20,7 @@ from rally.common import logging
from rally.common.plugin import discover
from rally.common.plugin import plugin
from rally.common import utils as rutils
from rally_openstack.cleanup import base
from rally_openstack.task.cleanup import base
LOG = logging.getLogger(__name__)

View File

@ -17,10 +17,10 @@ from rally.common import cfg
from rally.common import logging
from rally.task import utils as task_utils
from rally_openstack.cleanup import base
from rally_openstack.services.identity import identity
from rally_openstack.services.image import glance_v2
from rally_openstack.services.image import image
from rally_openstack.common.services.identity import identity
from rally_openstack.common.services.image import glance_v2
from rally_openstack.common.services.image import image
from rally_openstack.task.cleanup import base
CONF = cfg.CONF
@ -293,8 +293,8 @@ class OctaviaMixIn(NeutronMixin):
@property
def _client(self):
# TODO(andreykurilin): use proper helper class from
# rally_openstack.services as soon as it will have unified style
# of arguments across all methods
# rally_openstack.common.services as soon as it will have unified
# style of arguments across all methods
client = self.admin or self.user
return getattr(client, self._service)()

View File

@ -15,8 +15,8 @@ import random
from rally.common import validation
from rally import exceptions
from rally_openstack import consts
from rally_openstack import osclients
from rally_openstack.common import consts
from rally_openstack.common import osclients
from rally_openstack.task import context

View File

@ -18,9 +18,9 @@ from rally.common import logging
from rally.common import validation
from rally import exceptions
from rally_openstack import consts
from rally_openstack.scenarios.ceilometer import utils as ceilo_utils
from rally_openstack.common import consts
from rally_openstack.task import context
from rally_openstack.task.scenarios.ceilometer import utils as ceilo_utils
LOG = logging.getLogger(__name__)

View File

@ -16,10 +16,10 @@ from rally.common import logging
from rally.common import utils
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack import osclients
from rally_openstack.services.storage import block
from rally_openstack.common import consts
from rally_openstack.common import osclients
from rally_openstack.common.services.storage import block
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack import osclients
from rally_openstack.services.storage import block
from rally_openstack.common import consts
from rally_openstack.common import osclients
from rally_openstack.common.services.storage import block
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context

View File

@ -17,10 +17,10 @@ import sys
from rally.common import validation
from rally_openstack.cleanup import manager
from rally_openstack.contexts.cleanup import base
from rally_openstack import scenario
from rally_openstack.task.cleanup import manager
from rally_openstack.task import context
from rally_openstack.task.contexts.cleanup import base
from rally_openstack.task import scenario
@validation.add(name="check_cleanup_resources", admin_required=True)

View File

@ -15,8 +15,8 @@
from rally.common import validation
from rally_openstack.cleanup import manager
from rally_openstack import consts
from rally_openstack.common import consts
from rally_openstack.task.cleanup import manager
@validation.configure("check_cleanup_resources")

View File

@ -17,10 +17,10 @@ import sys
from rally.common import validation
from rally_openstack.cleanup import manager
from rally_openstack.contexts.cleanup import base
from rally_openstack import scenario
from rally_openstack.task.cleanup import manager
from rally_openstack.task import context
from rally_openstack.task.contexts.cleanup import base
from rally_openstack.task import scenario
@validation.add(name="check_cleanup_resources", admin_required=False)

View File

@ -19,11 +19,11 @@ from rally.common import utils as rutils
from rally.common import validation
from rally import exceptions
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack import osclients
from rally_openstack.scenarios.heat import utils as heat_utils
from rally_openstack.common import consts
from rally_openstack.common import osclients
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.scenarios.heat import utils as heat_utils
def get_data(filename_or_resource):

View File

@ -14,10 +14,10 @@
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack.scenarios.designate import utils
from rally_openstack.common import consts
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.scenarios.designate import utils
@validation.add("required_platform", platform="openstack", users=True)

View File

@ -17,10 +17,10 @@ from rally.common import logging
from rally.common import utils as rutils
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack import osclients
from rally_openstack.services.image import image
from rally_openstack.common import consts
from rally_openstack.common import osclients
from rally_openstack.common.services.image import image
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context

View File

@ -15,10 +15,10 @@
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack.scenarios.heat import utils as heat_utils
from rally_openstack.common import consts
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.scenarios.heat import utils as heat_utils
@validation.add("required_platform", platform="openstack", users=True)

View File

@ -19,9 +19,9 @@ from rally.common import logging
from rally.common import validation
from rally import exceptions
from rally_openstack import consts
from rally_openstack import osclients
from rally_openstack.services.identity import identity
from rally_openstack.common import consts
from rally_openstack.common import osclients
from rally_openstack.common.services.identity import identity
from rally_openstack.task import context

View File

@ -23,12 +23,12 @@ from rally.common import logging
from rally.common import validation
from rally import exceptions
from rally_openstack import consts
from rally_openstack import credential
from rally_openstack import osclients
from rally_openstack.services.identity import identity
from rally_openstack.common import consts
from rally_openstack.common import credential
from rally_openstack.common import osclients
from rally_openstack.common.services.identity import identity
from rally_openstack.common.wrappers import network
from rally_openstack.task import context
from rally_openstack.wrappers import network
LOG = logging.getLogger(__name__)

View File

@ -17,9 +17,9 @@ import os
from rally.common import utils as rutils
from rally.common import validation
from rally_openstack import consts
from rally_openstack.scenarios.magnum import utils as magnum_utils
from rally_openstack.common import consts
from rally_openstack.task import context
from rally_openstack.task.scenarios.magnum import utils as magnum_utils
@validation.add("required_platform", platform="openstack", users=True)

View File

@ -14,10 +14,10 @@
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack.scenarios.magnum import utils as magnum_utils
from rally_openstack.common import consts
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.scenarios.magnum import utils as magnum_utils
@validation.add("required_platform", platform="openstack", users=True)

View File

@ -14,11 +14,11 @@
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack.scenarios.magnum import utils as magnum_utils
from rally_openstack.scenarios.nova import utils as nova_utils
from rally_openstack.common import consts
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.scenarios.magnum import utils as magnum_utils
from rally_openstack.task.scenarios.nova import utils as nova_utils
@validation.add("required_platform", platform="openstack", users=True)

View File

@ -16,11 +16,11 @@
from rally.common import cfg
from rally.common import validation
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts as rally_consts
from rally_openstack.contexts.manila import consts
from rally_openstack.scenarios.manila import utils as manila_utils
from rally_openstack.common import consts as rally_consts
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.contexts.manila import consts
from rally_openstack.task.scenarios.manila import utils as manila_utils
CONF = cfg.CONF

View File

@ -18,11 +18,11 @@ from rally.common import logging
from rally.common import validation
from rally import exceptions
from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts as rally_consts
from rally_openstack.contexts.manila import consts
from rally_openstack.scenarios.manila import utils as manila_utils
from rally_openstack.common import consts as rally_consts
from rally_openstack.task.cleanup import manager as resource_manager
from rally_openstack.task import context
from rally_openstack.task.contexts.manila import consts
from rally_openstack.task.scenarios.manila import utils as manila_utils
CONF = cfg.CONF

Some files were not shown because too many files have changed in this diff Show More