diff --git a/designate/notifications.py b/designate/notifications.py index d9d480385..f53c22611 100644 --- a/designate/notifications.py +++ b/designate/notifications.py @@ -19,6 +19,7 @@ import abc from oslo_config import cfg from oslo_log import log as logging +import six from designate.i18n import _LW from designate.plugin import DriverPlugin @@ -159,8 +160,9 @@ class Audit(NotificationPlugin): new_value = getattr(arg, change) # Just in case something odd makes it here - if any(type(val) not in - (int, float, bool, str, type(None)) + if any(not isinstance(val, + (int, float, bool, + six.string_types, type(None))) for val in (old_value, new_value)): old_value, new_value = None, None msg = _LW("Nulling notification values after " diff --git a/designate/objects/zone_export.py b/designate/objects/zone_export.py index d5446a36b..a2e5afcd8 100644 --- a/designate/objects/zone_export.py +++ b/designate/objects/zone_export.py @@ -13,56 +13,33 @@ # 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 ZoneExport(base.DictObjectMixin, base.PersistentObjectMixin, base.DesignateObject): - FIELDS = { - 'status': { - 'schema': { - "type": "string", - "enum": ["ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE"], - }, - 'read_only': True - }, - 'task_type': { - 'schema': { - "type": "string", - "enum": ["EXPORT"], - }, - 'read_only': True - }, - 'tenant_id': { - 'schema': { - 'type': 'string', - }, - 'read_only': True - }, - 'location': { - 'schema': { - 'type': ['string', 'null'], - 'maxLength': 160 - }, - 'read_only': True - }, - 'message': { - 'schema': { - 'type': ['string', 'null'], - 'maxLength': 160 - }, - 'read_only': True - }, - 'zone_id': { - 'schema': { - "type": "string", - "format": "uuid" - }, - 'read_only': True - }, + fields = { + 'status': fields.EnumField( + valid_values=["ACTIVE", "PENDING", + "DELETED", "ERROR", "COMPLETE"] + ), + 'task_type': fields.EnumField( + valid_values=["EXPORT"] + ), + 'tenant_id': fields.StringFields(nullable=True), + 'location': fields.StringFields(nullable=True), + 'message': fields.StringFields(nullable=True, maxLength=160), + 'zone_id': fields.UUIDFields(nullable=True) } +@base.DesignateRegistry.register class ZoneExportList(base.ListObjectMixin, base.DesignateObject, base.PagedListObjectMixin): LIST_ITEM_TYPE = ZoneExport + + fields = { + 'objects': fields.ListOfObjectsField('ZoneExport'), + } diff --git a/designate/objects/zone_import.py b/designate/objects/zone_import.py index 27d10d3e1..ed91f9466 100644 --- a/designate/objects/zone_import.py +++ b/designate/objects/zone_import.py @@ -13,49 +13,32 @@ # 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 ZoneImport(base.DictObjectMixin, base.PersistentObjectMixin, base.DesignateObject): - FIELDS = { - 'status': { - 'schema': { - "type": "string", - "enum": ["ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE"], - }, - 'read_only': True - }, - 'task_type': { - 'schema': { - "type": "string", - "enum": ["IMPORT"], - }, - 'read_only': True - }, - 'tenant_id': { - 'schema': { - 'type': 'string', - }, - 'read_only': True - }, - 'message': { - 'schema': { - 'type': ['string', 'null'], - 'maxLength': 160 - }, - 'read_only': True - }, - 'zone_id': { - 'schema': { - "type": "string", - "format": "uuid" - }, - 'read_only': True - }, + fields = { + 'status': fields.EnumField( + valid_values=["ACTIVE", "PENDING", + "DELETED", "ERROR", "COMPLETE"] + ), + 'task_type': fields.EnumField( + valid_values=["IMPORT"] + ), + 'tenant_id': fields.StringFields(nullable=True), + 'message': fields.StringFields(nullable=True, maxLength=160), + 'zone_id': fields.UUIDFields(nullable=True) } +@base.DesignateRegistry.register class ZoneImportList(base.ListObjectMixin, base.DesignateObject, base.PagedListObjectMixin): LIST_ITEM_TYPE = ZoneImport + + fields = { + 'objects': fields.ListOfObjectsField('ZoneImport'), + } diff --git a/designate/objects/zone_transfer_accept.py b/designate/objects/zone_transfer_accept.py index ac793101c..d2b15d800 100644 --- a/designate/objects/zone_transfer_accept.py +++ b/designate/objects/zone_transfer_accept.py @@ -13,46 +13,21 @@ # 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 ZoneTransferAccept(base.DictObjectMixin, base.PersistentObjectMixin, base.DesignateObject): - FIELDS = { - 'zone_transfer_request_id': { - 'schema': { - "type": "string", - "format": "uuid" - }, - "immutable": True - }, - 'tenant_id': { - 'schema': { - 'type': 'string', - }, - 'read_only': True - }, - 'status': { - 'schema': { - "type": "string", - "enum": ["ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE"], - }, - 'read_only': True - }, - 'key': { - 'schema': { - "type": "string", - "maxLength": 160 - }, - 'required': True - }, - 'zone_id': { - 'schema': { - "type": "string", - "format": "uuid" - }, - "immutable": True - }, + fields = { + 'zone_transfer_request_id': fields.UUIDFields(nullable=True), + 'tenant_id': fields.StringFields(nullable=True), + 'status': fields.EnumField(nullable=True, valid_values=[ + "ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE" + ]), + 'key': fields.StringFields(maxLength=160), + 'zone_id': fields.UUIDFields(nullable=True), } STRING_KEYS = [ @@ -60,6 +35,11 @@ class ZoneTransferAccept(base.DictObjectMixin, base.PersistentObjectMixin, ] +@base.DesignateRegistry.register class ZoneTransferAcceptList(base.ListObjectMixin, base.DesignateObject, base.PagedListObjectMixin): LIST_ITEM_TYPE = ZoneTransferAccept + + fields = { + 'objects': fields.ListOfObjectsField('ZoneTransferAccept'), + } diff --git a/designate/objects/zone_transfer_request.py b/designate/objects/zone_transfer_request.py index 584f6187b..9fff1a112 100644 --- a/designate/objects/zone_transfer_request.py +++ b/designate/objects/zone_transfer_request.py @@ -13,57 +13,22 @@ # 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 ZoneTransferRequest(base.DictObjectMixin, base.PersistentObjectMixin, - base.DesignateObject,): - FIELDS = { - 'key': { - 'schema': { - "type": "string", - "maxLength": 160 - }, - }, - 'zone_id': { - 'schema': { - "type": "string", - "description": "Zone identifier", - "format": "uuid" - }, - "immutable": True - }, - 'description': { - 'schema': { - "type": ["string", "null"], - "maxLength": 160 - } - }, - 'tenant_id': { - 'schema': { - 'type': 'string', - }, - 'read_only': True - }, - 'target_tenant_id': { - 'schema': { - 'type': ['string', 'null'], - }, - 'immutable': True - }, - 'status': { - 'schema': { - "type": "string", - "enum": ["ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE"], - } - }, - 'zone_name': { - 'schema': { - "type": ["string", "null"], - "maxLength": 255, - }, - 'read_only': True - }, + base.DesignateObject, ): + fields = { + 'key': fields.StringFields(nullable=True, maxLength=160), + 'zone_id': fields.UUIDFields(nullable=True), + 'description': fields.StringFields(nullable=True, maxLength=160), + 'tenant_id': fields.StringFields(nullable=True), + 'target_tenant_id': fields.StringFields(nullable=True), + 'status': fields.EnumField(nullable=True, valid_values=[ + "ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE"]), + 'zone_name': fields.StringFields(nullable=True, maxLength=255), } STRING_KEYS = [ @@ -71,5 +36,9 @@ class ZoneTransferRequest(base.DictObjectMixin, base.PersistentObjectMixin, ] +@base.DesignateRegistry.register class ZoneTransferRequestList(base.ListObjectMixin, base.DesignateObject): LIST_ITEM_TYPE = ZoneTransferRequest + fields = { + 'objects': fields.ListOfObjectsField('ZoneTransferRequest'), + }