From 52634f55fdab470492ed68095e8f465e173a909c Mon Sep 17 00:00:00 2001 From: Tetsuro Nakamura Date: Sun, 17 Jun 2018 16:38:32 +0900 Subject: [PATCH] Fix directory structure This patch creates - `blazar/api/v1/leases` - `blazar/tests/api/v1/leases` - `blazar/manager/leases` and move related files there to keep symmetric structure between oshosts and leases API. This patch also moves test_physical_host_plugin.py from `blazar/tests/plugins/` to `blazar/tests/plugins/oshosts/`. Change-Id: Ib5ae4e291a9e47459f7aeee3d7570688bd8b1648 --- blazar/api/v1/app.py | 4 ++-- blazar/{tests/plugins => api/v1/leases}/__init__.py | 0 blazar/api/v1/{ => leases}/service.py | 2 +- blazar/api/v1/{ => leases}/v1_0.py | 2 +- blazar/api/v2/hooks.py | 4 ++-- blazar/manager/leases/__init__.py | 0 blazar/manager/{ => leases}/rpcapi.py | 0 blazar/tests/api/__init__.py | 4 ++-- blazar/tests/api/v1/leases/__init__.py | 0 blazar/tests/api/v1/{ => leases}/test_service.py | 2 +- blazar/tests/api/v1/{ => leases}/test_v1_0.py | 4 ++-- blazar/tests/api/v1/test_validation.py | 2 +- blazar/tests/manager/test_rpcapi.py | 2 +- .../tests/plugins/{ => oshosts}/test_physical_host_plugin.py | 0 14 files changed, 13 insertions(+), 13 deletions(-) rename blazar/{tests/plugins => api/v1/leases}/__init__.py (100%) rename blazar/api/v1/{ => leases}/service.py (97%) rename blazar/api/v1/{ => leases}/v1_0.py (97%) create mode 100644 blazar/manager/leases/__init__.py rename blazar/manager/{ => leases}/rpcapi.py (100%) create mode 100644 blazar/tests/api/v1/leases/__init__.py rename blazar/tests/api/v1/{ => leases}/test_service.py (96%) rename blazar/tests/api/v1/{ => leases}/test_v1_0.py (95%) rename blazar/tests/plugins/{ => oshosts}/test_physical_host_plugin.py (100%) diff --git a/blazar/api/v1/app.py b/blazar/api/v1/app.py index 88a4b03f..492a5da0 100644 --- a/blazar/api/v1/app.py +++ b/blazar/api/v1/app.py @@ -24,9 +24,9 @@ from oslo_log import log as logging from oslo_middleware import debug from werkzeug import exceptions as werkzeug_exceptions +from blazar.api.v1.leases import v1_0 as leases_api_v1_0 from blazar.api.v1.oshosts import v1_0 as host_api_v1_0 from blazar.api.v1 import utils as api_utils -from blazar.api.v1 import v1_0 as api_v1_0 LOG = logging.getLogger(__name__) @@ -69,7 +69,7 @@ def make_app(): app.route('/', methods=['GET'])(version_list) app.route('/versions', methods=['GET'])(version_list) - app.register_blueprint(api_v1_0.rest, url_prefix='/v1') + app.register_blueprint(leases_api_v1_0.rest, url_prefix='/v1') LOG.debug("List of plugins: %s", cfg.CONF.manager.plugins) # TODO(sbauza) : Change this whole crap by removing hardcoded values and diff --git a/blazar/tests/plugins/__init__.py b/blazar/api/v1/leases/__init__.py similarity index 100% rename from blazar/tests/plugins/__init__.py rename to blazar/api/v1/leases/__init__.py diff --git a/blazar/api/v1/service.py b/blazar/api/v1/leases/service.py similarity index 97% rename from blazar/api/v1/service.py rename to blazar/api/v1/leases/service.py index 704666e3..e35f257e 100644 --- a/blazar/api/v1/service.py +++ b/blazar/api/v1/leases/service.py @@ -16,7 +16,7 @@ from oslo_log import log as logging from blazar import context -from blazar.manager import rpcapi as manager_rpcapi +from blazar.manager.leases import rpcapi as manager_rpcapi from blazar import policy from blazar.utils import trusts diff --git a/blazar/api/v1/v1_0.py b/blazar/api/v1/leases/v1_0.py similarity index 97% rename from blazar/api/v1/v1_0.py rename to blazar/api/v1/leases/v1_0.py index b42aed66..e78e6e9a 100644 --- a/blazar/api/v1/v1_0.py +++ b/blazar/api/v1/leases/v1_0.py @@ -15,7 +15,7 @@ from oslo_log import log as logging -from blazar.api.v1 import service +from blazar.api.v1.leases import service from blazar.api.v1 import utils as api_utils from blazar.api.v1 import validation from blazar import utils diff --git a/blazar/api/v2/hooks.py b/blazar/api/v2/hooks.py index 34cb1fe6..788ed451 100644 --- a/blazar/api/v2/hooks.py +++ b/blazar/api/v2/hooks.py @@ -19,8 +19,8 @@ from pecan import hooks from blazar.api import context from blazar.db import api as dbapi +from blazar.manager.leases import rpcapi as leases_rpcapi from blazar.manager.oshosts import rpcapi as hosts_rpcapi -from blazar.manager import rpcapi LOG = logging.getLogger(__name__) @@ -64,5 +64,5 @@ class RPCHook(hooks.PecanHook): """Attach the rpcapi object to the request so controllers can get to it.""" def before(self, state): - state.request.rpcapi = rpcapi.ManagerRPCAPI() + state.request.rpcapi = leases_rpcapi.ManagerRPCAPI() state.request.hosts_rpcapi = hosts_rpcapi.ManagerRPCAPI() diff --git a/blazar/manager/leases/__init__.py b/blazar/manager/leases/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/blazar/manager/rpcapi.py b/blazar/manager/leases/rpcapi.py similarity index 100% rename from blazar/manager/rpcapi.py rename to blazar/manager/leases/rpcapi.py diff --git a/blazar/tests/api/__init__.py b/blazar/tests/api/__init__.py index 07832777..9d28ab01 100644 --- a/blazar/tests/api/__init__.py +++ b/blazar/tests/api/__init__.py @@ -22,8 +22,8 @@ import six from blazar.api import context as api_context from blazar import context +from blazar.manager.leases import rpcapi as leases_api from blazar.manager.oshosts import rpcapi as hosts_rpcapi -from blazar.manager import rpcapi from blazar import tests PATH_PREFIX = '/v2' @@ -65,7 +65,7 @@ class APITest(tests.TestCase): 'ctx_from_headers') self.fake_ctx_from_headers.side_effect = fake_ctx_from_headers - self.rpcapi = rpcapi.ManagerRPCAPI + self.rpcapi = leases_api.ManagerRPCAPI self.hosts_rpcapi = hosts_rpcapi.ManagerRPCAPI # self.patch(rpcapi.ManagerRPCAPI, 'list_leases').return_value = [] diff --git a/blazar/tests/api/v1/leases/__init__.py b/blazar/tests/api/v1/leases/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/blazar/tests/api/v1/test_service.py b/blazar/tests/api/v1/leases/test_service.py similarity index 96% rename from blazar/tests/api/v1/test_service.py rename to blazar/tests/api/v1/leases/test_service.py index 28c941c8..aeb57f9f 100644 --- a/blazar/tests/api/v1/test_service.py +++ b/blazar/tests/api/v1/leases/test_service.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from blazar.api.v1 import service as service_api +from blazar.api.v1.leases import service as service_api from blazar import tests diff --git a/blazar/tests/api/v1/test_v1_0.py b/blazar/tests/api/v1/leases/test_v1_0.py similarity index 95% rename from blazar/tests/api/v1/test_v1_0.py rename to blazar/tests/api/v1/leases/test_v1_0.py index efcfb5ae..74918e7c 100644 --- a/blazar/tests/api/v1/test_v1_0.py +++ b/blazar/tests/api/v1/leases/test_v1_0.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from blazar.api.v1 import service as service_api +from blazar.api.v1.leases import service as service_api +from blazar.api.v1.leases import v1_0 as api from blazar.api.v1 import utils as utils_api -from blazar.api.v1 import v1_0 as api from blazar import tests diff --git a/blazar/tests/api/v1/test_validation.py b/blazar/tests/api/v1/test_validation.py index 15b150da..7feac5e3 100644 --- a/blazar/tests/api/v1/test_validation.py +++ b/blazar/tests/api/v1/test_validation.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from blazar.api.v1 import service as service_api +from blazar.api.v1.leases import service as service_api from blazar.api.v1 import utils as api_utils from blazar.api.v1 import validation as validation_api from blazar import exceptions diff --git a/blazar/tests/manager/test_rpcapi.py b/blazar/tests/manager/test_rpcapi.py index 131c6712..9babaa6e 100644 --- a/blazar/tests/manager/test_rpcapi.py +++ b/blazar/tests/manager/test_rpcapi.py @@ -14,7 +14,7 @@ # limitations under the License. -from blazar.manager import rpcapi +from blazar.manager.leases import rpcapi from blazar import tests diff --git a/blazar/tests/plugins/test_physical_host_plugin.py b/blazar/tests/plugins/oshosts/test_physical_host_plugin.py similarity index 100% rename from blazar/tests/plugins/test_physical_host_plugin.py rename to blazar/tests/plugins/oshosts/test_physical_host_plugin.py