Migrate object to OVO (3)

This commit will migrate:
- Server and ServerList
- ServiceStatus and ServiceStatusList
- Tenant and TenantList
- Tld and TldList
- TsigKey and TsigKeyList

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

Change-Id: I2d6ec85e0c47b2e129bc55616ad92f53a2298940
Implements: blueprint designate-rolling-upgrade
This commit is contained in:
Dai Dang Van 2017-06-06 16:17:53 +07:00 committed by Graham Hayes
parent e9ebf92fbe
commit aac3812c1a
5 changed files with 94 additions and 118 deletions

View File

@ -12,22 +12,18 @@
# 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 Server(base.DictObjectMixin, base.PersistentObjectMixin,
base.DesignateObject):
FIELDS = {
'name': {
'schema': {
'type': 'string',
'description': 'Zone name',
'format': 'domainname',
'maxLength': 255,
},
'immutable': True,
'required': True
}
def __init__(self, *args, **kwargs):
super(Server, self).__init__(*args, **kwargs)
fields = {
'name': fields.DomainField(maxLength=255),
}
STRING_KEYS = [
@ -35,5 +31,10 @@ class Server(base.DictObjectMixin, base.PersistentObjectMixin,
]
@base.DesignateRegistry.register
class ServerList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = Server
fields = {
'objects': fields.ListOfObjectsField('Server'),
}

View File

@ -11,45 +11,26 @@
# 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
class ServiceStatus(base.PersistentObjectMixin,
base.DictObjectMixin,
base.DesignateObject):
FIELDS = {
"service_name": {
"schema": {
"type": "string"
}
},
"hostname": {
"schema": {
"type": "string"
}
},
"heartbeated_at": {
"schema": {
'type': ['string', 'null'],
'format': 'date-time'
}
},
"status": {
"schema": {
"type": "string",
"enum": ["UP", "DOWN", "WARNING"]
}
},
"stats": {
"schema": {
"type": "object",
}
},
"capabilities": {
"schema": {
"type": "object"
}
}
@base.DesignateRegistry.register
class ServiceStatus(base.DesignateObject, base.DictObjectMixin,
base.PersistentObjectMixin):
def __init__(self, *args, **kwargs):
super(ServiceStatus, self).__init__(*args, **kwargs)
fields = {
"service_name": fields.StringFields(),
"hostname": fields.StringFields(nullable=True),
"heartbeated_at": fields.DateTimeField(nullable=True),
"status": fields.EnumField(nullable=True, valid_values=[
"UP", "DOWN", "WARNING"
]),
"stats": fields.BaseObjectField(nullable=True),
"capabilities": fields.BaseObjectField(nullable=True),
}
STRING_KEYS = [
@ -57,5 +38,10 @@ class ServiceStatus(base.PersistentObjectMixin,
]
@base.DesignateRegistry.register
class ServiceStatusList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = ServiceStatus
fields = {
'objects': fields.ListOfObjectsField('ServiceStatus'),
}

View File

@ -12,14 +12,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
class Tenant(base.DictObjectMixin, base.DesignateObject):
FIELDS = {
'id': {},
'zone_count': {},
'zones': {}
@base.DesignateRegistry.register
class Tenant(base.DesignateObject, base.DictObjectMixin):
def __init__(self, *args, **kwargs):
super(Tenant, self).__init__(*args, **kwargs)
fields = {
'id': fields.AnyField(nullable=True),
'zone_count': fields.AnyField(nullable=True),
'zones': fields.AnyField(nullable=True)
}
STRING_KEYS = [
@ -27,5 +32,10 @@ class Tenant(base.DictObjectMixin, base.DesignateObject):
]
@base.DesignateRegistry.register
class TenantList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = Tenant
fields = {
'objects': fields.ListOfObjectsField('Tenant'),
}

View File

@ -12,27 +12,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 Tld(base.DictObjectMixin, base.PersistentObjectMixin,
base.DesignateObject):
FIELDS = {
'name': {
'schema': {
'type': 'string',
'format': 'tldname',
'maxLength': 255,
},
'immutable': True,
'required': True
},
'description': {
'schema': {
'type': ['string', 'null'],
'maxLength': 160
},
}
def __init__(self, *args, **kwargs):
super(Tld, self).__init__(*args, **kwargs)
fields = {
'name': fields.TldField(maxLength=255),
'description': fields.StringFields(nullable=True, maxLength=160)
}
STRING_KEYS = [
@ -40,8 +32,13 @@ class Tld(base.DictObjectMixin, base.PersistentObjectMixin,
]
@base.DesignateRegistry.register
class TldList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = Tld
fields = {
'objects': fields.ListOfObjectsField('Tld'),
}
def __contains__(self, key):
return bool(list(filter(lambda tld: tld.name == key, self.objects)))

View File

@ -12,56 +12,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 TsigKey(base.DictObjectMixin, base.PersistentObjectMixin,
base.DesignateObject):
FIELDS = {
'name': {
'schema': {
'type': 'string',
'maxLength': 160,
'format': 'domainnamne'
},
'required': True
},
'algorithm': {
'schema': {
'type': 'string',
'enum': [
'hmac-md5',
'hmac-sha1',
'hmac-sha224',
'hmac-sha256',
'hmac-sha384',
'hmac-sha512'
]
},
'required': True
},
'secret': {
'schema': {
'type': 'string',
'maxLength': 160
},
'required': True
},
'scope': {
'schema': {
'type': 'string',
'enum': ['POOL', 'ZONE'],
},
'required': True
},
'resource_id': {
'schema': {
'type': 'string',
'format': 'uuid'
},
'read_only': True,
'required': True
},
def __init__(self, *args, **kwargs):
super(TsigKey, self).__init__(*args, **kwargs)
fields = {
'name': fields.StringFields(nullable=False, maxLength=160),
'algorithm': fields.EnumField(nullable=False,
valid_values=[
'hmac-md5',
'hmac-sha1',
'hmac-sha224',
'hmac-sha256',
'hmac-sha384',
'hmac-sha512'
]
),
'secret': fields.StringFields(maxLength=160),
'scope': fields.EnumField(nullable=False,
valid_values=['POOL', 'ZONE']
),
'resource_id': fields.UUIDFields(nullable=False)
}
STRING_KEYS = [
@ -69,5 +46,10 @@ class TsigKey(base.DictObjectMixin, base.PersistentObjectMixin,
]
@base.DesignateRegistry.register
class TsigKeyList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = TsigKey
fields = {
'objects': fields.ListOfObjectsField('TsigKey'),
}