Migrate object to OVO (6)

This commit will migrate:
- ValidationError and ValidationErrorList

Co-authored-By: Nguyen Van Trung <trungnv@vn.fujitsu.com>

Change-Id: I00d72d83dafb28a2d94aeabd844559be92d131f2
Implements: blueprint designate-rolling-upgrade
This commit is contained in:
Dai Dang Van 2017-06-08 09:27:52 +07:00 committed by Graham Hayes
parent e9cc75ff01
commit f4c96aaae0
3 changed files with 22 additions and 13 deletions

View File

@ -21,6 +21,7 @@ from oslo_log import log as logging
from oslo_utils import timeutils
from designate import exceptions
from designate.objects import validation_error
from designate.schema import validators
from designate.schema import format
from designate.i18n import _
@ -311,10 +312,8 @@ class DesignateObject(object):
make_class_validator(self)
# NOTE(kiall): We make use of the Object registry here in order to
# avoid an impossible circular import.
ValidationErrorList = self.obj_cls_from_name('ValidationErrorList')
ValidationError = self.obj_cls_from_name('ValidationError')
ValidationErrorList = validation_error.ValidationErrorList
ValidationError = validation_error.ValidationError
errors = ValidationErrorList()

View File

@ -22,8 +22,6 @@ from oslo_versionedobjects.base import VersionedObjectDictCompat as DictObjectMi
from designate.i18n import _
from designate.i18n import _LE
from designate.objects import fields
from designate.objects.validation_error import ValidationError
from designate.objects.validation_error import ValidationErrorList
from designate import exceptions
LOG = logging.getLogger(__name__)
@ -210,6 +208,10 @@ class DesignateObject(base.VersionedObject):
return self._context
def validate(self):
# NOTE(kiall, daidv): We make use of the Object registry here
# in order to avoid an impossible circular import.
ValidationErrorList = self.obj_cls_from_name('ValidationErrorList')
ValidationError = self.obj_cls_from_name('ValidationError')
self.fields = self.FIELDS
for name in self.fields:
field = self.fields[name]

View File

@ -11,16 +11,19 @@
# 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 designate.objects import base
from designate.objects import ovo_base as base
from designate.objects import fields
@base.DesignateRegistry.register
class ValidationError(base.DesignateObject):
FIELDS = {
'path': {},
'message': {},
'validator': {},
'validator_value': {},
'raw': {},
fields = {
'path': fields.AnyField(nullable=True),
'message': fields.AnyField(nullable=True),
'validator': fields.AnyField(nullable=True),
'validator_value': fields.AnyField(nullable=True),
'raw': fields.AnyField(nullable=True),
}
@classmethod
@ -40,5 +43,10 @@ class ValidationError(base.DesignateObject):
return e
@base.DesignateRegistry.register
class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = ValidationError
fields = {
'objects': fields.ListOfObjectsField('ValidationError'),
}