Migrate object to OVO (5)

This commit will migrate:
- Blacklist object
- Quota objects
- Floating_IP objects

Co-authored-By: Dai Dang Van <daidv@vn.fujitsu.com>

Change-Id: I85455e7cbf24da4c7c6302060d5c3d203fdf2fc5
Implements: blueprint designate-rolling-upgrade
This commit is contained in:
Nguyen Van Trung 2017-06-07 17:01:55 +07:00 committed by Graham Hayes
parent 274c2cb82c
commit e9cc75ff01
4 changed files with 49 additions and 77 deletions

View File

@ -12,28 +12,16 @@
# 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 Blacklist(base.DictObjectMixin, base.PersistentObjectMixin,
base.DesignateObject):
FIELDS = {
'pattern': {
'schema': {
'type': 'string',
'description': 'Regex for blacklisted zone name',
'format': 'regex',
'maxLength': 255,
},
'required': True
},
'description': {
'schema': {
'type': ['string', 'null'],
'description': 'Description for the blacklisted zone',
'maxLength': 160
}
}
fields = {
'pattern': fields.StringFields(maxLength=255),
'description': fields.StringFields(maxLength=160, nullable=True),
}
STRING_KEYS = [
@ -41,5 +29,10 @@ class Blacklist(base.DictObjectMixin, base.PersistentObjectMixin,
]
@base.DesignateRegistry.register
class BlacklistList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = Blacklist
fields = {
'objects': fields.ListOfObjectsField('Blacklist'),
}

View File

@ -175,6 +175,8 @@ class DomainField(StringFields):
def coerce(self, obj, attr, value):
value = super(DomainField, self).coerce(obj, attr, value)
if value is None:
return
domain = value.split('.')
for host in domain:
if len(host) > 63:
@ -206,6 +208,8 @@ class HostField(StringFields):
def coerce(self, obj, attr, value):
value = super(HostField, self).coerce(obj, attr, value)
if value is None:
return
hostname = value.split('.')
for host in hostname:
if len(host) > 63:
@ -223,6 +227,8 @@ class SRVField(StringFields):
def coerce(self, obj, attr, value):
value = super(SRVField, self).coerce(obj, attr, value)
if value is None:
return
srvtype = value.split('.')
for host in srvtype:
if len(host) > 63:
@ -302,6 +308,4 @@ class IPOrHost(IPV4AndV6AddressField):
except ValueError:
if not re.match(StringFields.RE_ZONENAME, value):
raise ValueError("%s is not IP address or host name" % value)
# we use this field as a string, not need a netaddr.IPAdress
# as oslo.versionedobjects is using
return str(value)
return value

View File

@ -13,61 +13,24 @@
# 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 FloatingIP(base.DictObjectMixin, base.PersistentObjectMixin,
base.DesignateObject):
FIELDS = {
"address": {
'schema': {
'type': 'string',
'format': ['ipv4', 'ipv6']
},
},
"description": {
'schema': {
'type': ['string', 'null'],
'maxLength': 160
},
},
"id": {
'schema': {
'type': 'string',
'format': 'uuid'
}
},
"ptrdname": {
'schema': {
'type': ['string', 'null'],
'format': 'domainname'
}
},
"ttl": {
'schema': {
'type': ['integer', 'null'],
'minimum': 1,
'maximum': 2147483647
}
},
"region": {
'schema': {
'type': ['string', 'null'],
}
},
"action": {
'schema': {
'type': 'string',
'enum': ['CREATE', 'DELETE', 'UPDATE', 'NONE'],
}
},
"status": {
'schema': {
'type': 'string',
'enum': ['ACTIVE', 'PENDING', 'ERROR'],
}
}
fields = {
"address": fields.IPV4AddressField(nullable=True),
"description": fields.StringFields(nullable=True, maxLength=160),
"ptrdname": fields.DomainField(nullable=True),
"ttl": fields.IntegerFields(nullable=True,
minimum=1, maximum=2147483647),
"region": fields.StringFields(nullable=True),
"action": fields.EnumField(['CREATE', 'DELETE',
'UPDATE', 'NONE'], nullable=True),
"status": fields.EnumField(['ACTIVE',
'PENDING', 'ERROR'], nullable=True)
}
STRING_KEYS = [
@ -79,5 +42,10 @@ class FloatingIP(base.DictObjectMixin, base.PersistentObjectMixin,
return '%s:%s' % (self.region, self.id)
@base.DesignateRegistry.register
class FloatingIPList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = FloatingIP
fields = {
'objects': fields.ListOfObjectsField('FloatingIP'),
}

View File

@ -12,15 +12,17 @@
# 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 Quota(base.DictObjectMixin, base.PersistentObjectMixin,
base.DesignateObject):
FIELDS = {
'tenant_id': {},
'resource': {},
'hard_limit': {}
fields = {
'tenant_id': fields.AnyField(nullable=True),
'resource': fields.AnyField(nullable=True),
'hard_limit': fields.AnyField(nullable=True)
}
STRING_KEYS = [
@ -28,9 +30,14 @@ class Quota(base.DictObjectMixin, base.PersistentObjectMixin,
]
@base.DesignateRegistry.register
class QuotaList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = Quota
fields = {
'objects': fields.ListOfObjectsField('Quota'),
}
@classmethod
def from_dict(cls, _dict):