summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Betts <sam@code-smash.net>2016-09-13 15:55:44 +0100
committerSam Betts <sam@code-smash.net>2016-09-13 15:55:44 +0100
commit57d4e0ce3d18f738c1fbe7453421833f9712f534 (patch)
tree48c02585111ebbff01990d6bff476cd78bbdaea5
parent991d3a9f2b410ae09fd500f4b557a59350363a2e (diff)
downloadironic-57d4e0ce3d18f738c1fbe7453421833f9712f534.tar.gz
Remove cyclic import between rpcapi and objects.base
There was a cyclic import between conductor.rpcapi and objects.base, this was initally fixed by doing an import at runtime. This patch fixes the import cycle for good. Change-Id: I8ee8c47652de75430312f77ddee08adc7a237d2b Closes-Bug: #1623074
-rw-r--r--ironic/cmd/api.py4
-rw-r--r--ironic/objects/base.py30
-rw-r--r--ironic/objects/indirection.py43
3 files changed, 46 insertions, 31 deletions
diff --git a/ironic/cmd/api.py b/ironic/cmd/api.py
index c205a1566..fe2a058eb 100644
--- a/ironic/cmd/api.py
+++ b/ironic/cmd/api.py
@@ -23,6 +23,7 @@ from oslo_config import cfg
from ironic.common import service as ironic_service
from ironic.objects import base
+from ironic.objects import indirection
CONF = cfg.CONF
@@ -32,7 +33,8 @@ def main():
ironic_service.prepare_service(sys.argv)
# Enable object backporting via the conductor
- base.IronicObject.indirection_api = base.IronicObjectIndirectionAPI()
+ base.IronicObject.indirection_api = (
+ indirection.IronicObjectIndirectionAPI())
# Build and start the WSGI app
launcher = ironic_service.process_launcher()
diff --git a/ironic/objects/base.py b/ironic/objects/base.py
index 61af72b10..84ac7ebc7 100644
--- a/ironic/objects/base.py
+++ b/ironic/objects/base.py
@@ -90,36 +90,6 @@ class IronicObject(object_base.VersionedObject):
return obj
-class IronicObjectIndirectionAPI(object_base.VersionedObjectIndirectionAPI):
- def __init__(self):
- super(IronicObjectIndirectionAPI, self).__init__()
- # FIXME(xek): importing here due to a cyclical import error
- from ironic.conductor import rpcapi as conductor_api
- self._conductor = conductor_api.ConductorAPI()
-
- def object_action(self, context, objinst, objmethod, args, kwargs):
- return self._conductor.object_action(context, objinst, objmethod,
- args, kwargs)
-
- def object_class_action(self, context, objname, objmethod, objver,
- args, kwargs):
- # NOTE(xek): This method is implemented for compatibility with
- # oslo.versionedobjects 0.10.0 and older. It will be replaced by
- # object_class_action_versions.
- versions = object_base.obj_tree_get_versions(objname)
- return self.object_class_action_versions(
- context, objname, objmethod, versions, args, kwargs)
-
- def object_class_action_versions(self, context, objname, objmethod,
- object_versions, args, kwargs):
- return self._conductor.object_class_action_versions(
- context, objname, objmethod, object_versions, args, kwargs)
-
- def object_backport_versions(self, context, objinst, object_versions):
- return self._conductor.object_backport_versions(context, objinst,
- object_versions)
-
-
class IronicObjectSerializer(object_base.VersionedObjectSerializer):
# Base class to use for object hydration
OBJ_BASE_CLASS = IronicObject
diff --git a/ironic/objects/indirection.py b/ironic/objects/indirection.py
new file mode 100644
index 000000000..b306820c4
--- /dev/null
+++ b/ironic/objects/indirection.py
@@ -0,0 +1,43 @@
+# 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.
+
+from oslo_versionedobjects import base as object_base
+
+from ironic.conductor import rpcapi as conductor_api
+
+
+class IronicObjectIndirectionAPI(object_base.VersionedObjectIndirectionAPI):
+ def __init__(self):
+ super(IronicObjectIndirectionAPI, self).__init__()
+ self._conductor = conductor_api.ConductorAPI()
+
+ def object_action(self, context, objinst, objmethod, args, kwargs):
+ return self._conductor.object_action(context, objinst, objmethod,
+ args, kwargs)
+
+ def object_class_action(self, context, objname, objmethod, objver,
+ args, kwargs):
+ # NOTE(xek): This method is implemented for compatibility with
+ # oslo.versionedobjects 0.10.0 and older. It will be replaced by
+ # object_class_action_versions.
+ versions = object_base.obj_tree_get_versions(objname)
+ return self.object_class_action_versions(
+ context, objname, objmethod, versions, args, kwargs)
+
+ def object_class_action_versions(self, context, objname, objmethod,
+ object_versions, args, kwargs):
+ return self._conductor.object_class_action_versions(
+ context, objname, objmethod, object_versions, args, kwargs)
+
+ def object_backport_versions(self, context, objinst, object_versions):
+ return self._conductor.object_backport_versions(context, objinst,
+ object_versions)