summaryrefslogtreecommitdiff
path: root/ironic/api/controllers/base.py
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2020-01-23 10:52:56 +1300
committerSteve Baker <sbaker@redhat.com>2020-01-23 11:35:07 +1300
commit0c6521804d539f8ace57eb9e56e7e604d08bcea5 (patch)
tree2906f75a8e571cd230d4387544f446e77a46e07e /ironic/api/controllers/base.py
parentf192f2c45d5d89f64159a20d0dc8c7d743885ece (diff)
downloadironic-0c6521804d539f8ace57eb9e56e7e604d08bcea5.tar.gz
Clean up api controller base classes
The parent class of APIBase is no longer wsme.types.Base. Instead there is a new ironic.api.controllers.base.Base as the parent. This new Base class keeps the __init__() from wsme.types.Base, but not the __registry__ registration. As far as I can tell[1], this type registry is used to allow the wsproperty datatype value to be a string, but all of our uses of wsproperty use the real type types.uuid, so this registry is just overhead. The other changes are for some existing classes to extend the new Base class instead of APIBase or wsme.types.Base. APIBase is now used only by classes which represent real database objects, which is the only situation where having a created_at, updated_at makes sense. DeployStepType is excluded from this change as it will require extra work to change its parent class. Story: 1651346 [1] https://opendev.org/x/wsme/src/branch/master/wsme/types.py#L507 Change-Id: Ie687c270ed13b99486496a84df34e5973af1b9cd
Diffstat (limited to 'ironic/api/controllers/base.py')
-rw-r--r--ironic/api/controllers/base.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/ironic/api/controllers/base.py b/ironic/api/controllers/base.py
index 41ddf31e5..73d7f9a08 100644
--- a/ironic/api/controllers/base.py
+++ b/ironic/api/controllers/base.py
@@ -17,7 +17,6 @@ import functools
from webob import exc
import wsme
-from wsme import types as wtypes
from ironic.common.i18n import _
@@ -43,13 +42,12 @@ class AsDictMixin(object):
and getattr(self, k) != wsme.Unset)
-class APIBase(wtypes.Base, AsDictMixin):
-
- created_at = wsme.wsattr(datetime.datetime, readonly=True)
- """The time in UTC at which the object is created"""
-
- updated_at = wsme.wsattr(datetime.datetime, readonly=True)
- """The time in UTC at which the object is updated"""
+class Base(AsDictMixin):
+ """Base type for complex types"""
+ def __init__(self, **kw):
+ for key, value in kw.items():
+ if hasattr(self, key):
+ setattr(self, key, value)
def unset_fields_except(self, except_list=None):
"""Unset fields so they don't appear in the message body.
@@ -65,6 +63,15 @@ class APIBase(wtypes.Base, AsDictMixin):
setattr(self, k, wsme.Unset)
+class APIBase(Base):
+
+ created_at = wsme.wsattr(datetime.datetime, readonly=True)
+ """The time in UTC at which the object is created"""
+
+ updated_at = wsme.wsattr(datetime.datetime, readonly=True)
+ """The time in UTC at which the object is updated"""
+
+
@functools.total_ordering
class Version(object):
"""API Version object."""