Merge "FloatingIP to OVO"

This commit is contained in:
Jenkins 2017-07-27 17:19:41 +00:00 committed by Gerrit Code Review
commit cfb23d4e3e
7 changed files with 77 additions and 0 deletions

View File

@ -167,6 +167,10 @@ PORT_BINDING_STATUS_INACTIVE = 'INACTIVE'
PORT_BINDING_STATUSES = (PORT_BINDING_STATUS_ACTIVE,
PORT_BINDING_STATUS_INACTIVE)
VALID_FLOATINGIP_STATUS = (lib_constants.FLOATINGIP_STATUS_ACTIVE,
lib_constants.FLOATINGIP_STATUS_DOWN,
lib_constants.FLOATINGIP_STATUS_ERROR)
# Possible types of values (e.g. in QoS rule types)
VALUES_TYPE_CHOICES = "choices"
VALUES_TYPE_RANGE = "range"

View File

@ -302,3 +302,7 @@ class UUID(obj_fields.UUID):
class UUIDField(obj_fields.AutoTypedField):
AUTO_TYPE = UUID()
class FloatingIPStatusEnumField(obj_fields.AutoTypedField):
AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_FLOATINGIP_STATUS)

View File

@ -166,3 +166,48 @@ class DVRMacAddress(base.NeutronDbObject):
if 'mac_address' in fields:
result['mac_address'] = cls.filter_to_str(result['mac_address'])
return result
@obj_base.VersionedObjectRegistry.register
class FloatingIP(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
db_model = l3.FloatingIP
fields = {
'id': common_types.UUIDField(),
'project_id': obj_fields.StringField(nullable=True),
'floating_ip_address': obj_fields.IPAddressField(),
'floating_network_id': common_types.UUIDField(),
'floating_port_id': common_types.UUIDField(),
'fixed_port_id': common_types.UUIDField(nullable=True),
'fixed_ip_address': obj_fields.IPAddressField(nullable=True),
'router_id': common_types.UUIDField(nullable=True),
'last_known_router_id': common_types.UUIDField(nullable=True),
'status': common_types.FloatingIPStatusEnumField(nullable=True),
}
fields_no_update = ['project_id', 'floating_ip_address',
'floating_network_id', 'floating_port_id']
@classmethod
def modify_fields_from_db(cls, db_obj):
result = super(FloatingIP, cls).modify_fields_from_db(db_obj)
if 'fixed_ip_address' in result:
result['fixed_ip_address'] = netaddr.IPAddress(
result['fixed_ip_address'])
if 'floating_ip_address' in result:
result['floating_ip_address'] = netaddr.IPAddress(
result['floating_ip_address'])
return result
@classmethod
def modify_fields_to_db(cls, fields):
result = super(FloatingIP, cls).modify_fields_to_db(fields)
if 'fixed_ip_address' in result:
result['fixed_ip_address'] = cls.filter_to_str(
result['fixed_ip_address'])
if 'floating_ip_address' in result:
result['floating_ip_address'] = cls.filter_to_str(
result['floating_ip_address'])
return result

View File

@ -281,6 +281,10 @@ def get_random_ip_address(version=4):
return ip
def get_random_floatingip_status():
return random.choice(n_const.VALID_FLOATINGIP_STATUS)
def get_random_flow_direction():
return random.choice(n_const.VALID_DIRECTIONS)

View File

@ -450,6 +450,7 @@ FIELD_TYPE_VALUE_GENERATOR_MAP = {
common_types.DomainNameField: get_random_domain_name,
common_types.DscpMarkField: get_random_dscp_mark,
common_types.EtherTypeEnumField: tools.get_random_ether_type,
common_types.FloatingIPStatusEnumField: tools.get_random_floatingip_status,
common_types.FlowDirectionEnumField: tools.get_random_flow_direction,
common_types.IpamAllocationStatusEnumField: tools.get_random_ipam_status,
common_types.IPNetworkField: tools.get_random_ip_network,

View File

@ -39,6 +39,7 @@ object_data = {
'FlatAllocation': '1.0-bf666f24f4642b047eeca62311fbcb41',
'Flavor': '1.0-82194de5c9aafce08e8527bb7977f5c6',
'FlavorServiceProfileBinding': '1.0-a2c8731e16cefdac4571f80abf1f8930',
'FloatingIP': '1.0-ea69515cfe08b5efc0600e6446efe64f',
'FloatingIPDNS': '1.0-ee3db848500fa1825235f701828c06d5',
'GeneveAllocation': '1.0-d5f76e8eac60a778914d61dd8e23e90f',
'GeneveEndpoint': '1.0-040f026996b5952e2ae4ccd40ac61ca6',

View File

@ -76,3 +76,21 @@ class DVRMacAddressDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
testlib_api.SqlTestCase):
_test_class = router.DVRMacAddress
class FloatingIPIfaceObjectTestCase(obj_test_base.BaseObjectIfaceTestCase):
_test_class = router.FloatingIP
class FloatingIPDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
testlib_api.SqlTestCase):
_test_class = router.FloatingIP
def setUp(self):
super(FloatingIPDbObjectTestCase, self).setUp()
self.update_obj_fields(
{'floating_port_id': lambda: self._create_test_port_id(),
'fixed_port_id': lambda: self._create_test_port_id(),
'router_id': lambda: self._create_test_router_id()})