use objects common_types from neutron-lib
This patch consumes the neutron-lib OVO common_types module by removing it from neutron and switching imports over to use neutron-lib instead. NeutronLibImpact Change-Id: Ic9819a27e3e72038b819ab2fe845c26fc63b26d5
This commit is contained in:
parent
2a8b70d2db
commit
b4972e246d
neutron
objects
address_scope.pyagent.pyauto_allocate.pycommon_types.pyconntrack_helper.py
extensions
flavor.pyfloatingip.pyipam.pyl3_hamode.pyl3agent.pylogapi
metering.pynetwork.pynetwork_segment_range.pyplugins/ml2
port/extensions
port_forwarding.pyports.pyqos
quota.pyrbac.pyrouter.pysecuritygroup.pyservicetype.pysubnet.pysubnetpool.pytrunk.pytests/unit
@ -12,12 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import address_scope as models
|
||||
from neutron.db import models_v2
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.objects import utils as obj_utils
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
@ -24,7 +25,6 @@ from neutron.db.models import l3agent as rb_model
|
||||
from neutron.db.models import l3ha as l3ha_model
|
||||
from neutron.db import models_v2
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -13,10 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.services.auto_allocate import models
|
||||
|
||||
|
||||
|
@ -1,319 +0,0 @@
|
||||
# Copyright 2016 OpenStack Foundation
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import itertools
|
||||
import uuid
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import constants as lib_db_const
|
||||
from neutron_lib.objects import exceptions as o_exc
|
||||
from neutron_lib.utils import net as net_utils
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
|
||||
|
||||
class HARouterEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_HA_STATES)
|
||||
|
||||
|
||||
class IPV6ModeEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.IPV6_MODES)
|
||||
|
||||
|
||||
class RangeConstrainedInteger(obj_fields.Integer):
|
||||
def __init__(self, start, end, **kwargs):
|
||||
try:
|
||||
self._start = int(start)
|
||||
self._end = int(end)
|
||||
except (TypeError, ValueError):
|
||||
raise o_exc.NeutronRangeConstrainedIntegerInvalidLimit(
|
||||
start=start, end=end)
|
||||
super(RangeConstrainedInteger, self).__init__(**kwargs)
|
||||
|
||||
def coerce(self, obj, attr, value):
|
||||
if not isinstance(value, six.integer_types):
|
||||
msg = _("Field value %s is not an integer") % value
|
||||
raise ValueError(msg)
|
||||
if not self._start <= value <= self._end:
|
||||
msg = _("Field value %s is invalid") % value
|
||||
raise ValueError(msg)
|
||||
return super(RangeConstrainedInteger, self).coerce(obj, attr, value)
|
||||
|
||||
|
||||
class IPNetworkPrefixLen(RangeConstrainedInteger):
|
||||
"""IP network (CIDR) prefix length custom Enum"""
|
||||
def __init__(self, **kwargs):
|
||||
super(IPNetworkPrefixLen, self).__init__(
|
||||
start=0, end=constants.IPv6_BITS,
|
||||
**kwargs)
|
||||
|
||||
|
||||
class IPNetworkPrefixLenField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = IPNetworkPrefixLen()
|
||||
|
||||
|
||||
class PortRange(RangeConstrainedInteger):
|
||||
def __init__(self, start=constants.PORT_RANGE_MIN, **kwargs):
|
||||
super(PortRange, self).__init__(start=start,
|
||||
end=constants.PORT_RANGE_MAX, **kwargs)
|
||||
|
||||
|
||||
class PortRangeField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = PortRange()
|
||||
|
||||
|
||||
class PortRangeWith0Field(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = PortRange(start=0)
|
||||
|
||||
|
||||
class VlanIdRange(RangeConstrainedInteger):
|
||||
def __init__(self, **kwargs):
|
||||
super(VlanIdRange, self).__init__(start=constants.MIN_VLAN_TAG,
|
||||
end=constants.MAX_VLAN_TAG,
|
||||
**kwargs)
|
||||
|
||||
|
||||
class VlanIdRangeField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = VlanIdRange()
|
||||
|
||||
|
||||
class ListOfIPNetworksField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.List(obj_fields.IPNetwork())
|
||||
|
||||
|
||||
class SetOfUUIDsField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Set(obj_fields.UUID())
|
||||
|
||||
|
||||
class DomainName(obj_fields.String):
|
||||
def coerce(self, obj, attr, value):
|
||||
if not isinstance(value, six.string_types):
|
||||
msg = _("Field value %s is not a string") % value
|
||||
raise ValueError(msg)
|
||||
if len(value) > lib_db_const.FQDN_FIELD_SIZE:
|
||||
msg = _("Domain name %s is too long") % value
|
||||
raise ValueError(msg)
|
||||
return super(DomainName, self).coerce(obj, attr, value)
|
||||
|
||||
|
||||
class DomainNameField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = DomainName()
|
||||
|
||||
|
||||
class IntegerEnum(obj_fields.Integer):
|
||||
def __init__(self, valid_values=None, **kwargs):
|
||||
if not valid_values:
|
||||
msg = _("No possible values specified")
|
||||
raise ValueError(msg)
|
||||
for value in valid_values:
|
||||
if not isinstance(value, six.integer_types):
|
||||
msg = _("Possible value %s is not an integer") % value
|
||||
raise ValueError(msg)
|
||||
self._valid_values = valid_values
|
||||
super(IntegerEnum, self).__init__(**kwargs)
|
||||
|
||||
def coerce(self, obj, attr, value):
|
||||
if not isinstance(value, six.integer_types):
|
||||
msg = _("Field value %s is not an integer") % value
|
||||
raise ValueError(msg)
|
||||
if value not in self._valid_values:
|
||||
msg = (
|
||||
_("Field value %(value)s is not in the list "
|
||||
"of valid values: %(values)s") %
|
||||
{'value': value, 'values': self._valid_values}
|
||||
)
|
||||
raise ValueError(msg)
|
||||
return super(IntegerEnum, self).coerce(obj, attr, value)
|
||||
|
||||
|
||||
class IPVersionEnum(IntegerEnum):
|
||||
"""IP version integer Enum"""
|
||||
def __init__(self, **kwargs):
|
||||
super(IPVersionEnum, self).__init__(
|
||||
valid_values=constants.IP_ALLOWED_VERSIONS, **kwargs)
|
||||
|
||||
|
||||
class IPVersionEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = IPVersionEnum()
|
||||
|
||||
|
||||
class DscpMark(IntegerEnum):
|
||||
def __init__(self, valid_values=None, **kwargs):
|
||||
super(DscpMark, self).__init__(
|
||||
valid_values=constants.VALID_DSCP_MARKS)
|
||||
|
||||
|
||||
class DscpMarkField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = DscpMark()
|
||||
|
||||
|
||||
class FlowDirectionEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_DIRECTIONS)
|
||||
|
||||
|
||||
class IpamAllocationStatusEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(
|
||||
valid_values=constants.VALID_IPAM_ALLOCATION_STATUSES)
|
||||
|
||||
|
||||
class EtherTypeEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_ETHERTYPES)
|
||||
|
||||
|
||||
class IpProtocolEnum(obj_fields.Enum):
|
||||
"""IP protocol number Enum"""
|
||||
def __init__(self, **kwargs):
|
||||
super(IpProtocolEnum, self).__init__(
|
||||
valid_values=list(
|
||||
itertools.chain(
|
||||
constants.IP_PROTOCOL_MAP.keys(),
|
||||
[str(v) for v in range(256)]
|
||||
)
|
||||
),
|
||||
**kwargs)
|
||||
|
||||
|
||||
class PortBindingStatusEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.PORT_BINDING_STATUSES)
|
||||
|
||||
|
||||
class IpProtocolEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = IpProtocolEnum()
|
||||
|
||||
|
||||
class MACAddress(obj_fields.FieldType):
|
||||
"""MACAddress custom field.
|
||||
|
||||
This custom field is different from the one provided by
|
||||
oslo.versionedobjects library: it uses netaddr.EUI type instead of strings.
|
||||
"""
|
||||
def coerce(self, obj, attr, value):
|
||||
if not isinstance(value, netaddr.EUI):
|
||||
msg = _("Field value %s is not a netaddr.EUI") % value
|
||||
raise ValueError(msg)
|
||||
return super(MACAddress, self).coerce(obj, attr, value)
|
||||
|
||||
@staticmethod
|
||||
def to_primitive(obj, attr, value):
|
||||
return str(value)
|
||||
|
||||
@staticmethod
|
||||
def from_primitive(obj, attr, value):
|
||||
try:
|
||||
return net_utils.AuthenticEUI(value)
|
||||
except Exception:
|
||||
msg = _("Field value %s is not a netaddr.EUI") % value
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
class MACAddressField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = MACAddress()
|
||||
|
||||
|
||||
class DictOfMiscValues(obj_fields.FieldType):
|
||||
"""DictOfMiscValues custom field
|
||||
|
||||
This custom field is handling dictionary with miscellaneous value types,
|
||||
including integer, float, boolean and list and nested dictionaries.
|
||||
"""
|
||||
@staticmethod
|
||||
def coerce(obj, attr, value):
|
||||
if isinstance(value, dict):
|
||||
return value
|
||||
if isinstance(value, six.string_types):
|
||||
try:
|
||||
return jsonutils.loads(value)
|
||||
except Exception:
|
||||
msg = _("Field value %s is not stringified JSON") % value
|
||||
raise ValueError(msg)
|
||||
msg = (_("Field value %s is not type of dict or stringified JSON")
|
||||
% value)
|
||||
raise ValueError(msg)
|
||||
|
||||
@staticmethod
|
||||
def from_primitive(obj, attr, value):
|
||||
return DictOfMiscValues.coerce(obj, attr, value)
|
||||
|
||||
@staticmethod
|
||||
def to_primitive(obj, attr, value):
|
||||
return jsonutils.dumps(value)
|
||||
|
||||
@staticmethod
|
||||
def stringify(value):
|
||||
return jsonutils.dumps(value)
|
||||
|
||||
|
||||
class DictOfMiscValuesField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = DictOfMiscValues
|
||||
|
||||
|
||||
class ListOfDictOfMiscValuesField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.List(DictOfMiscValuesField())
|
||||
|
||||
|
||||
class IPNetwork(obj_fields.FieldType):
|
||||
"""IPNetwork custom field.
|
||||
|
||||
This custom field is different from the one provided by
|
||||
oslo.versionedobjects library: it does not reset string representation for
|
||||
the field.
|
||||
"""
|
||||
def coerce(self, obj, attr, value):
|
||||
if not isinstance(value, netaddr.IPNetwork):
|
||||
msg = _("Field value %s is not a netaddr.IPNetwork") % value
|
||||
raise ValueError(msg)
|
||||
return super(IPNetwork, self).coerce(obj, attr, value)
|
||||
|
||||
@staticmethod
|
||||
def to_primitive(obj, attr, value):
|
||||
return str(value)
|
||||
|
||||
@staticmethod
|
||||
def from_primitive(obj, attr, value):
|
||||
try:
|
||||
return net_utils.AuthenticIPNetwork(value)
|
||||
except Exception:
|
||||
msg = _("Field value %s is not a netaddr.IPNetwork") % value
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
class IPNetworkField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = IPNetwork()
|
||||
|
||||
|
||||
class UUID(obj_fields.UUID):
|
||||
def coerce(self, obj, attr, value):
|
||||
uuid.UUID(str(value))
|
||||
return str(value)
|
||||
|
||||
|
||||
class UUIDField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = UUID()
|
||||
|
||||
|
||||
class FloatingIPStatusEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_FLOATINGIP_STATUS)
|
||||
|
||||
|
||||
class RouterStatusEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_ROUTER_STATUS)
|
||||
|
||||
|
||||
class NetworkSegmentRangeNetworkTypeEnumField(obj_fields.AutoTypedField):
|
||||
AUTO_TYPE = obj_fields.Enum(
|
||||
valid_values=constants.NETWORK_SEGMENT_RANGE_TYPES)
|
@ -12,11 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import conntrack_helper as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -11,10 +11,10 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api.definitions import port_security
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
class _PortSecurity(base.NeutronDbObject):
|
||||
|
@ -13,11 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import flavor as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -12,10 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
|
||||
from neutron.db.models import dns as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -14,11 +14,11 @@
|
||||
# under the License.
|
||||
|
||||
import netaddr
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.ipam.drivers.neutrondb_ipam import db_models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -13,12 +13,12 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import agent as agent_model
|
||||
from neutron.db.models import l3ha
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.orm import joinedload
|
||||
@ -20,7 +21,6 @@ from neutron.db.models import agent as agent_model
|
||||
from neutron.db.models import l3_attrs
|
||||
from neutron.db.models import l3agent
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -13,13 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.objects.logapi import event_types
|
||||
from neutron_lib.services.logapi import constants as log_const
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import loggingapi as log_db
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -12,12 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.utils import net as net_utils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import metering as metering_models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -15,6 +15,7 @@
|
||||
from neutron_lib.api.definitions import availability_zone as az_def
|
||||
from neutron_lib.api.validators import availability_zone as az_validator
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import exception
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
@ -29,7 +30,6 @@ from neutron.db.port_security import models as ps_models
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron.objects import agent as agent_obj
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects.extensions import port_security as base_ps
|
||||
from neutron.objects.qos import binding
|
||||
from neutron.objects import rbac
|
||||
|
@ -15,6 +15,7 @@
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import utils as db_utils
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import not_
|
||||
@ -30,7 +31,6 @@ from neutron.db.models.plugins.ml2 import vxlanallocation as vxlan_alloc_model
|
||||
from neutron.db.models import segment as segments_model
|
||||
from neutron.db import models_v2
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
models_map = {
|
||||
|
@ -12,11 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -12,11 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models.plugins.ml2 import vxlanallocation as vxlan_model
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects.plugins.ml2 import base as ml2_base
|
||||
|
||||
|
||||
|
@ -10,11 +10,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.utils import net as net_utils
|
||||
|
||||
from neutron.db.models import allowed_address_pair as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -12,11 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import data_plane_status as db_models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -10,11 +10,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.extra_dhcp_opt import models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -10,11 +10,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import uplink_status_propagation as db_models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -15,11 +15,11 @@
|
||||
import itertools
|
||||
|
||||
import netaddr
|
||||
from neutron_lib.objects import common_types
|
||||
|
||||
from neutron.db.models import l3
|
||||
from neutron.db.models import port_forwarding as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects import router
|
||||
from neutron_lib import constants as lib_const
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.utils import net as net_utils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import versionutils
|
||||
@ -24,7 +25,6 @@ from neutron.db.models import l3
|
||||
from neutron.db.models import securitygroup as sg_models
|
||||
from neutron.db import models_v2
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects.db import api as obj_db_api
|
||||
from neutron.objects.qos import binding
|
||||
from neutron.plugins.ml2 import models as ml2_models
|
||||
|
@ -13,10 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
|
||||
from neutron.db.qos import models as qos_db_model
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -16,6 +16,7 @@
|
||||
import itertools
|
||||
|
||||
from neutron_lib.exceptions import qos as qos_exc
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import exception
|
||||
@ -26,7 +27,6 @@ from neutron.db import models_v2
|
||||
from neutron.db.qos import models as qos_db_model
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron.objects import base as base_db
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects.db import api as obj_db_api
|
||||
from neutron.objects.qos import binding
|
||||
from neutron.objects.qos import rule as rule_obj_impl
|
||||
|
@ -17,6 +17,7 @@ import abc
|
||||
import sys
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.services.qos import constants as qos_consts
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_utils import versionutils
|
||||
@ -26,7 +27,6 @@ import six
|
||||
|
||||
from neutron.db.qos import models as qos_db_model
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
DSCP_MARK = 'dscp_mark'
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.plugins import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.services.qos import constants as qos_consts
|
||||
@ -18,7 +19,6 @@ from oslo_versionedobjects import exception
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
class RuleTypeField(obj_fields.BaseEnumField):
|
||||
|
@ -12,13 +12,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron.db.quota import models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
import abc
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
from six import add_metaclass
|
||||
from sqlalchemy import and_
|
||||
|
||||
from neutron.db import rbac_db_models as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@add_metaclass(abc.ABCMeta)
|
||||
|
@ -17,6 +17,7 @@ import netaddr
|
||||
from neutron_lib.api.definitions import availability_zone as az_def
|
||||
from neutron_lib.api.validators import availability_zone as az_validator
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.utils import net as net_utils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
import six
|
||||
@ -28,7 +29,6 @@ from neutron.db.models import l3_attrs
|
||||
from neutron.db.models import l3agent as rb_model
|
||||
from neutron.db import models_v2
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.utils import net as net_utils
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
@ -17,7 +18,6 @@ from oslo_versionedobjects import fields as obj_fields
|
||||
from neutron.db.models import securitygroup as sg_models
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects import ports
|
||||
from neutron.objects import rbac
|
||||
from neutron.objects import rbac_db
|
||||
|
@ -13,11 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db.models import servicetype as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -14,6 +14,7 @@ import netaddr
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.db import model_query
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.utils import net as net_utils
|
||||
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
@ -24,7 +25,6 @@ from neutron.db.models import subnet_service_type
|
||||
from neutron.db import models_v2
|
||||
from neutron.ipam import exceptions as ipam_exceptions
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects import network
|
||||
from neutron.objects import rbac_db
|
||||
from neutron.services.segments import exceptions as segment_exc
|
||||
|
@ -14,11 +14,11 @@
|
||||
# under the License.
|
||||
|
||||
import netaddr
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.db import models_v2 as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
|
@ -14,13 +14,13 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.objects import exceptions as o_exc
|
||||
from oslo_db import exception as o_db_exc
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.services.trunk import exceptions as t_exc
|
||||
from neutron.services.trunk import models
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
import mock
|
||||
from neutron_lib.agent import topics
|
||||
from neutron_lib import context
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
import testtools
|
||||
@ -24,7 +25,6 @@ from neutron.api.rpc.callbacks import resources
|
||||
from neutron.api.rpc.callbacks import version_manager
|
||||
from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron.objects import base as objects_base
|
||||
from neutron.objects import common_types
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit.objects import test_base as objects_test_base
|
||||
|
||||
|
@ -23,6 +23,7 @@ from neutron_lib import context
|
||||
from neutron_lib.db import api as db_api
|
||||
from neutron_lib.db import model_query
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.objects import common_types
|
||||
from neutron_lib.objects import exceptions as o_exc
|
||||
from neutron_lib.objects.logapi import event_types
|
||||
from neutron_lib.objects import utils as obj_utils
|
||||
@ -40,7 +41,6 @@ import testtools
|
||||
from neutron import objects
|
||||
from neutron.objects import agent
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects.db import api as obj_db_api
|
||||
from neutron.objects import flavor
|
||||
from neutron.objects import network as net_obj
|
||||
|
@ -1,303 +0,0 @@
|
||||
# Copyright 2016 OpenStack Foundation
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import itertools
|
||||
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.tests import tools
|
||||
from neutron_lib.utils import net
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from neutron.objects import common_types
|
||||
from neutron.tests import base as test_base
|
||||
|
||||
|
||||
class TestField(object):
|
||||
|
||||
def test_coerce_good_values(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual(out_val, self.field.coerce('obj', 'attr', in_val))
|
||||
|
||||
def test_coerce_bad_values(self):
|
||||
for in_val in self.coerce_bad_values:
|
||||
self.assertRaises((TypeError, ValueError),
|
||||
self.field.coerce, 'obj', 'attr', in_val)
|
||||
|
||||
def test_to_primitive(self):
|
||||
for in_val, prim_val in self.to_primitive_values:
|
||||
self.assertEqual(prim_val, self.field.to_primitive('obj', 'attr',
|
||||
in_val))
|
||||
|
||||
def test_to_primitive_json_serializable(self):
|
||||
for in_val, _ in self.to_primitive_values:
|
||||
prim = self.field.to_primitive('obj', 'attr', in_val)
|
||||
jsencoded = jsonutils.dumps(prim)
|
||||
self.assertEqual(prim, jsonutils.loads(jsencoded))
|
||||
|
||||
def test_from_primitive(self):
|
||||
class ObjectLikeThing(object):
|
||||
_context = 'context'
|
||||
|
||||
for prim_val, out_val in self.from_primitive_values:
|
||||
from_prim = self.field.from_primitive(ObjectLikeThing, 'attr',
|
||||
prim_val)
|
||||
self.assertEqual(out_val, from_prim)
|
||||
# ensure it's coercable for sanity
|
||||
self.field.coerce('obj', 'attr', from_prim)
|
||||
|
||||
@abc.abstractmethod
|
||||
def test_stringify(self):
|
||||
'''This test should validate stringify() format for new field types.'''
|
||||
|
||||
|
||||
class IPV6ModeEnumFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(IPV6ModeEnumFieldTest, self).setUp()
|
||||
self.field = common_types.IPV6ModeEnumField()
|
||||
self.coerce_good_values = [(mode, mode)
|
||||
for mode in const.IPV6_MODES]
|
||||
self.coerce_bad_values = ['6', 4, 'type', 'slaacc']
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("'%s'" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class DscpMarkFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(DscpMarkFieldTest, self).setUp()
|
||||
self.field = common_types.DscpMarkField()
|
||||
self.coerce_good_values = [(val, val)
|
||||
for val in const.VALID_DSCP_MARKS]
|
||||
self.coerce_bad_values = ['6', 'str', [], {}, object()]
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("%s" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class IPNetworkPrefixLenFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(IPNetworkPrefixLenFieldTest, self).setUp()
|
||||
self.field = common_types.IPNetworkPrefixLenField()
|
||||
self.coerce_good_values = [(x, x) for x in (0, 32, 128, 42)]
|
||||
self.coerce_bad_values = ['len', '1', 129, -1]
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("%s" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class MACAddressFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(MACAddressFieldTest, self).setUp()
|
||||
self.field = common_types.MACAddressField()
|
||||
mac1 = tools.get_random_EUI()
|
||||
mac2 = tools.get_random_EUI()
|
||||
self.coerce_good_values = [(mac1, mac1), (mac2, mac2)]
|
||||
self.coerce_bad_values = [
|
||||
'XXXX', 'ypp', 'g3:vvv',
|
||||
# the field type is strict and does not allow to pass strings, even
|
||||
# if they represent a valid MAC address
|
||||
net.get_random_mac('fe:16:3e:00:00:00'.split(':')),
|
||||
]
|
||||
self.to_primitive_values = ((a1, str(a2))
|
||||
for a1, a2 in self.coerce_good_values)
|
||||
self.from_primitive_values = ((a2, a1)
|
||||
for a1, a2 in self.to_primitive_values)
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual('%s' % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class IPNetworkFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(IPNetworkFieldTest, self).setUp()
|
||||
self.field = common_types.IPNetworkField()
|
||||
addrs = [
|
||||
tools.get_random_ip_network(version=ip_version)
|
||||
for ip_version in const.IP_ALLOWED_VERSIONS
|
||||
]
|
||||
self.coerce_good_values = [(addr, addr) for addr in addrs]
|
||||
self.coerce_bad_values = [
|
||||
'ypp', 'g3:vvv',
|
||||
# the field type is strict and does not allow to pass strings, even
|
||||
# if they represent a valid IP network
|
||||
'10.0.0.0/24',
|
||||
]
|
||||
self.to_primitive_values = ((a1, str(a2))
|
||||
for a1, a2 in self.coerce_good_values)
|
||||
self.from_primitive_values = ((a2, a1)
|
||||
for a1, a2 in self.to_primitive_values)
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual('%s' % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class IPVersionEnumFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(IPVersionEnumFieldTest, self).setUp()
|
||||
self.field = common_types.IPVersionEnumField()
|
||||
self.coerce_good_values = [(val, val)
|
||||
for val in const.IP_ALLOWED_VERSIONS]
|
||||
self.coerce_bad_values = [5, 0, -1, 'str']
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("%s" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class FlowDirectionEnumFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(FlowDirectionEnumFieldTest, self).setUp()
|
||||
self.field = common_types.FlowDirectionEnumField()
|
||||
self.coerce_good_values = [(val, val)
|
||||
for val in const.VALID_DIRECTIONS]
|
||||
self.coerce_bad_values = ['test', '8', 10, []]
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("'%s'" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class DomainNameFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(DomainNameFieldTest, self).setUp()
|
||||
self.field = common_types.DomainNameField()
|
||||
self.coerce_good_values = [
|
||||
(val, val)
|
||||
for val in ('www.google.com', 'hostname', '1abc.com')
|
||||
]
|
||||
self.coerce_bad_values = ['x' * (db_const.FQDN_FIELD_SIZE + 1), 10, []]
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("'%s'" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class EtherTypeEnumFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(EtherTypeEnumFieldTest, self).setUp()
|
||||
self.field = common_types.EtherTypeEnumField()
|
||||
self.coerce_good_values = [(val, val)
|
||||
for val in const.VALID_ETHERTYPES]
|
||||
self.coerce_bad_values = ['IpV4', 8, 'str', 'ipv6']
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("'%s'" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class IpProtocolEnumFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(IpProtocolEnumFieldTest, self).setUp()
|
||||
self.field = common_types.IpProtocolEnumField()
|
||||
self.coerce_good_values = [
|
||||
(val, val)
|
||||
for val in itertools.chain(
|
||||
const.IP_PROTOCOL_MAP.keys(),
|
||||
[str(v) for v in range(256)]
|
||||
)
|
||||
]
|
||||
self.coerce_bad_values = ['test', 'Udp', 256]
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("'%s'" % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class UUIDFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(UUIDFieldTest, self).setUp()
|
||||
self.field = common_types.UUIDField()
|
||||
self.coerce_good_values = [
|
||||
('f1d9cb3f-c263-45d3-907c-d12a9ef1629e',
|
||||
'f1d9cb3f-c263-45d3-907c-d12a9ef1629e'),
|
||||
('7188f6637cbd4097a3b1d1bb7897c7c0',
|
||||
'7188f6637cbd4097a3b1d1bb7897c7c0')]
|
||||
self.coerce_bad_values = [
|
||||
'f1d9cb3f-c263-45d3-907c-d12a9ef16zzz',
|
||||
'7188f6637cbd4097a3b1d1bb7897']
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual('%s' % in_val, self.field.stringify(in_val))
|
||||
|
||||
|
||||
class DictOfMiscValuesFieldTest(test_base.BaseTestCase, TestField):
|
||||
def setUp(self):
|
||||
super(DictOfMiscValuesFieldTest, self).setUp()
|
||||
self.field = common_types.DictOfMiscValues
|
||||
test_dict_1 = {'a': True,
|
||||
'b': 1.23,
|
||||
'c': ['1', 1.23, True],
|
||||
'd': {'aa': 'zz'},
|
||||
'e': '10.0.0.1'}
|
||||
test_dict_str = jsonutils.dumps(test_dict_1)
|
||||
self.coerce_good_values = [
|
||||
(test_dict_1, test_dict_1),
|
||||
(test_dict_str, test_dict_1)
|
||||
]
|
||||
self.coerce_bad_values = [str(test_dict_1), '{"a":}']
|
||||
self.to_primitive_values = [
|
||||
(test_dict_1, test_dict_str)
|
||||
]
|
||||
self.from_primitive_values = [
|
||||
(test_dict_str, test_dict_1)
|
||||
]
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual(jsonutils.dumps(in_val),
|
||||
self.field.stringify(in_val))
|
||||
|
||||
|
||||
class NetworkSegmentRangeNetworkTypeEnumFieldTest(test_base.BaseTestCase,
|
||||
TestField):
|
||||
def setUp(self):
|
||||
super(NetworkSegmentRangeNetworkTypeEnumFieldTest, self).setUp()
|
||||
self.field = common_types.NetworkSegmentRangeNetworkTypeEnumField()
|
||||
self.coerce_good_values = [(val, val)
|
||||
for val in [const.TYPE_VLAN,
|
||||
const.TYPE_VXLAN,
|
||||
const.TYPE_GRE,
|
||||
const.TYPE_GENEVE]]
|
||||
self.coerce_bad_values = [const.TYPE_FLAT, 'foo-network-type']
|
||||
self.to_primitive_values = self.coerce_good_values
|
||||
self.from_primitive_values = self.coerce_good_values
|
||||
|
||||
def test_stringify(self):
|
||||
for in_val, out_val in self.coerce_good_values:
|
||||
self.assertEqual("'%s'" % in_val, self.field.stringify(in_val))
|
@ -16,13 +16,13 @@ from neutron_lib.callbacks import events
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib.db import model_base
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron.extensions import rbac as ext_rbac
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
from neutron.objects.db import api as obj_db_api
|
||||
from neutron.objects import rbac_db
|
||||
from neutron.tests.unit.objects import test_rbac
|
||||
|
Loading…
x
Reference in New Issue
Block a user