[OVO] Switch to use own registry

Neutron will now use own registry for versionedobjects.
It avoids problems with loading wrong OVO objects from
different projects (like os_vif) when names are the same.

Change-Id: I9d4fab591fbe52271c613251321a6d03078976f7
Closes-Bug: #1731948
This commit is contained in:
Sławek Kapłoński 2017-11-14 20:36:39 +00:00
parent dd06df8f04
commit 5e08a9b0e7
40 changed files with 203 additions and 141 deletions

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import address_scope as models
@ -20,7 +19,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class AddressScope(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -13,7 +13,6 @@
# under the License.
from neutron_lib import constants as const
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from sqlalchemy import func
@ -27,7 +26,7 @@ from neutron.objects import common_types
from neutron.objects import utils as obj_utils
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Agent(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.objects import base
@ -21,7 +20,7 @@ from neutron.objects import common_types
from neutron.services.auto_allocate import models
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class AutoAllocatedTopology(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -20,8 +20,11 @@ from neutron_lib import exceptions as n_exc
from neutron_lib.objects import exceptions as o_exc
from oslo_db import exception as obj_exc
from oslo_db.sqlalchemy import utils as db_utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import versionutils
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import exception as obj_exception
from oslo_versionedobjects import fields as obj_fields
import six
@ -31,6 +34,9 @@ from neutron.db import standard_attr
from neutron.objects.db import api as obj_db_api
from neutron.objects.extensions import standardattributes
LOG = logging.getLogger(__name__)
_NO_DB_MODEL = object()
@ -43,7 +49,7 @@ def get_updatable_fields(cls, fields):
def get_object_class_by_model(model):
for obj_class in obj_base.VersionedObjectRegistry.obj_classes().values():
for obj_class in NeutronObjectRegistry.obj_classes().values():
obj_class = obj_class[0]
if getattr(obj_class, 'db_model', _NO_DB_MODEL) is model:
return obj_class
@ -93,6 +99,34 @@ class Pager(object):
return self.__dict__ == other.__dict__
class NeutronObjectRegistry(obj_base.VersionedObjectRegistry):
_registry = None
def __new__(cls, *args, **kwargs):
# TODO(slaweq): this should be moved back to oslo.versionedobjects
# lib as soon as bug https://bugs.launchpad.net/neutron/+bug/1731948
# will be fixed and OVO's registry class will support defining custom
# registries for objects.
# NOTE(slaweq): it is overridden method
# oslo_versionedobjects.base.VersionedObjectRegistry.__new__
# We need to overwrite it to use separate registry for Neutron's
# objects.
# This is necessary to avoid clash in naming objects between Neutron
# and e.g. os-vif (for example Route or Subnet objects are used in
# both)
if not NeutronObjectRegistry._registry:
NeutronObjectRegistry._registry = object.__new__(
NeutronObjectRegistry, *args, **kwargs)
NeutronObjectRegistry._registry._obj_classes = \
collections.defaultdict(list)
self = object.__new__(cls, *args, **kwargs)
self._obj_classes = (
NeutronObjectRegistry._registry._obj_classes)
return self
@six.add_metaclass(abc.ABCMeta)
class NeutronObject(obj_base.VersionedObject,
obj_base.VersionedObjectDictCompat,
@ -143,6 +177,45 @@ class NeutronObject(obj_base.VersionedObject,
return (isinstance(cls.fields[field], obj_fields.ListOfObjectsField) or
isinstance(cls.fields[field], obj_fields.ObjectField))
@classmethod
def obj_class_from_name(cls, objname, objver):
"""Returns a class from the registry based on a name and version."""
# NOTE(slaweq): it is override method
# oslo_versionedobjects.base.VersionedObject.obj_class_from_name
# We need to override it to use Neutron's objects registry class
# (NeutronObjectRegistry) instead of original VersionedObjectRegistry
# class from oslo_versionedobjects
# This is necessary to avoid clash in naming objects between Neutron
# and e.g. os-vif (for example Route or Subnet objects are used in
# both)
if objname not in NeutronObjectRegistry.obj_classes():
LOG.error('Unable to instantiate unregistered object type '
'%(objtype)s', dict(objtype=objname))
raise obj_exception.UnsupportedObjectError(objtype=objname)
# NOTE(comstud): If there's not an exact match, return the highest
# compatible version. The objects stored in the class are sorted
# such that highest version is first, so only set compatible_match
# once below.
compatible_match = None
for objclass in NeutronObjectRegistry.obj_classes()[objname]:
if objclass.VERSION == objver:
return objclass
if (not compatible_match and
versionutils.is_compatible(objver, objclass.VERSION)):
compatible_match = objclass
if compatible_match:
return compatible_match
# As mentioned above, latest version is always first in the list.
latest_ver = (
NeutronObjectRegistry.obj_classes()[objname][0].VERSION)
raise obj_exception.IncompatibleObjectVersion(objname=objname,
objver=objver,
supported=latest_ver)
@classmethod
def clean_obj_from_primitive(cls, primitive, context=None):
obj = cls.obj_from_primitive(primitive, context)
@ -581,7 +654,7 @@ class NeutronDbObject(NeutronObject):
# subclasses=True
for field in self.synthetic_fields:
try:
objclasses = obj_base.VersionedObjectRegistry.obj_classes(
objclasses = NeutronObjectRegistry.obj_classes(
).get(self.fields[field].objname)
except AttributeError:
# NOTE(rossella_s) this is probably because this field is not

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import flavor as models
@ -21,7 +20,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class FlavorServiceProfileBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -36,7 +35,7 @@ class FlavorServiceProfileBinding(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class ServiceProfile(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -66,7 +65,7 @@ class ServiceProfile(base.NeutronDbObject):
self.obj_reset_changes(['flavor_ids'])
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Flavor(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,14 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from neutron.db.models import dns as models
from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class FloatingIPDNS(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -14,7 +14,6 @@
# under the License.
import netaddr
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.ipam.drivers.neutrondb_ipam import db_models
@ -22,7 +21,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class IpamAllocationPool(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -59,7 +58,7 @@ class IpamAllocationPool(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class IpamAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -89,7 +88,7 @@ class IpamAllocation(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class IpamSubnet(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.common import constants
@ -22,7 +21,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class L3HARouterAgentPortBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -53,7 +52,7 @@ class L3HARouterAgentPortBinding(base.NeutronDbObject):
return query.all()
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class L3HARouterNetwork(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -68,7 +67,7 @@ class L3HARouterNetwork(base.NeutronDbObject):
primary_keys = ['network_id', 'project_id']
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class L3HARouterVRIdAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
import sqlalchemy as sa
from sqlalchemy.orm import joinedload
@ -24,7 +23,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class RouterL3AgentBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import loggingapi as log_db
@ -23,7 +22,7 @@ from neutron.objects.logapi import event_types
from neutron.services.logapi.common import constants as log_const
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Log(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.common import utils
@ -21,7 +20,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class MeteringLabelRule(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -57,7 +56,7 @@ class MeteringLabelRule(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class MeteringLabel(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -14,7 +14,6 @@
from neutron_lib.api.definitions import availability_zone as az_def
from neutron_lib.api.validators import availability_zone as az_validator
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db import api as db_api
@ -33,7 +32,7 @@ from neutron.objects.qos import binding
from neutron.objects import rbac_db
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class NetworkDhcpAgentBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -57,7 +56,7 @@ class NetworkDhcpAgentBinding(base.NeutronDbObject):
return cls.get_objects(context, dhcp_agent_id=dhcp_agent_ids)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class NetworkSegment(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -145,7 +144,7 @@ class NetworkSegment(base.NeutronDbObject):
**kwargs)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class NetworkPortSecurity(base_ps._PortSecurity):
# Version 1.0: Initial version
VERSION = "1.0"
@ -155,7 +154,7 @@ class NetworkPortSecurity(base_ps._PortSecurity):
fields_need_translation = {'id': 'network_id'}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class ExternalNetwork(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -172,7 +171,7 @@ class ExternalNetwork(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Network(rbac_db.NeutronRbacObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -306,7 +305,7 @@ class Network(rbac_db.NeutronRbacObject):
return set()
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SegmentHostMapping(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -321,7 +320,7 @@ class SegmentHostMapping(base.NeutronDbObject):
primary_keys = ['segment_id', 'host']
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class NetworkDNSDomain(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -11,14 +11,13 @@
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models.plugins.ml2 import flatallocation
from neutron.objects import base
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class FlatAllocation(base.NeutronDbObject):
# Version 1.0: Initial Version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models.plugins.ml2 import geneveallocation
@ -20,7 +19,7 @@ from neutron.objects import base
from neutron.objects.plugins.ml2 import base as ml2_base
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class GeneveAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -35,7 +34,7 @@ class GeneveAllocation(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class GeneveEndpoint(ml2_base.EndpointBase):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models.plugins.ml2 import gre_allocation_endpoints as gre_model
@ -20,7 +19,7 @@ from neutron.objects import base
from neutron.objects.plugins.ml2 import base as ml2_base
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class GreAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -35,7 +34,7 @@ class GreAllocation(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class GreEndpoint(ml2_base.EndpointBase):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model
@ -20,7 +19,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class VlanAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models.plugins.ml2 import vxlanallocation as vxlan_model
@ -21,7 +20,7 @@ from neutron.objects import common_types
from neutron.objects.plugins.ml2 import base as ml2_base
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class VxlanAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -36,7 +35,7 @@ class VxlanAllocation(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class VxlanEndpoint(ml2_base.EndpointBase):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from neutron.common import utils
from neutron.db.models import allowed_address_pair as models
@ -18,7 +17,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class AllowedAddressPair(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import data_plane_status as db_models
@ -20,7 +19,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class PortDataPlaneStatus(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = "1.0"

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.extra_dhcp_opt import models
@ -18,7 +17,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class ExtraDhcpOpt(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -10,13 +10,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from neutron.db.port_security import models
from neutron.objects import base
from neutron.objects.extensions import port_security as base_ps
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class PortSecurity(base_ps._PortSecurity):
# Version 1.0: Initial version
VERSION = "1.0"

View File

@ -15,7 +15,6 @@
import netaddr
from neutron_lib import constants
from oslo_utils import versionutils
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.common import utils
@ -61,7 +60,7 @@ class PortBindingBase(base.NeutronDbObject):
return fields
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class PortBinding(PortBindingBase):
# Version 1.0: Initial version
VERSION = '1.0'
@ -82,7 +81,7 @@ class PortBinding(PortBindingBase):
primary_keys = ['port_id', 'host']
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class DistributedPortBinding(PortBindingBase):
# Version 1.0: Initial version
VERSION = '1.0'
@ -106,7 +105,7 @@ class DistributedPortBinding(PortBindingBase):
primary_keys = ['host', 'port_id']
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class PortBindingLevel(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -143,7 +142,7 @@ class PortBindingLevel(base.NeutronDbObject):
context, _pager, validate_filters, **kwargs)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class IPAllocation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -205,7 +204,7 @@ class IPAllocation(base.NeutronDbObject):
return True
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class PortDNS(base.NeutronDbObject):
# Version 1.0: Initial version
# Version 1.1: Add dns_domain attribute
@ -235,7 +234,7 @@ class PortDNS(base.NeutronDbObject):
primitive.pop('dns_domain', None)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Port(base.NeutronDbObject):
# Version 1.0: Initial version
# Version 1.1: Add data_plane_status field

View File

@ -10,14 +10,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import provisioning_block as pb_model
from neutron.objects import base
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class ProvisioningBlock(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from neutron.db.qos import models as qos_db_model
from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosPolicyPortBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -36,7 +35,7 @@ class QosPolicyPortBinding(base.NeutronDbObject):
fields_no_update = ['policy_id', 'port_id']
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosPolicyNetworkBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -18,7 +18,6 @@ import itertools
from neutron_lib import constants as n_const
from oslo_db import exception as db_exc
from oslo_utils import versionutils
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import exception
from oslo_versionedobjects import fields as obj_fields
@ -35,7 +34,7 @@ from neutron.objects.qos import rule as rule_obj_impl
from neutron.objects import rbac_db
@obj_base.VersionedObjectRegistry.register
@base_db.NeutronObjectRegistry.register
class QosPolicy(rbac_db.NeutronRbacObject):
# Version 1.0: Initial version
# Version 1.1: QosDscpMarkingRule introduced
@ -346,7 +345,7 @@ class QosPolicy(rbac_db.NeutronRbacObject):
primitive.pop('is_default', None)
@obj_base.VersionedObjectRegistry.register
@base_db.NeutronObjectRegistry.register
class QosPolicyDefault(base_db.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -20,7 +20,6 @@ from neutron_lib import constants
from neutron_lib.services.qos import constants as qos_consts
from neutron_lib.utils import helpers
from oslo_utils import versionutils
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import exception
from oslo_versionedobjects import fields as obj_fields
import six
@ -100,7 +99,7 @@ class QosRule(base.NeutronDbObject):
and is_network_policy_only))
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosBandwidthLimitRule(QosRule):
db_model = qos_db_model.QosBandwidthLimitRule
@ -124,7 +123,7 @@ class QosBandwidthLimitRule(QosRule):
objtype="QosBandwidthLimitRule")
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosDscpMarkingRule(QosRule):
db_model = qos_db_model.QosDscpMarkingRule
@ -143,7 +142,7 @@ class QosDscpMarkingRule(QosRule):
objname="QosDscpMarkingRule")
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosMinimumBandwidthRule(QosRule):
db_model = qos_db_model.QosMinimumBandwidthRule

View File

@ -15,7 +15,6 @@ from neutron_lib.plugins import directory
from neutron_lib.services.qos import constants as qos_consts
from oslo_log import log as logging
from oslo_utils import versionutils
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.objects import base
@ -32,7 +31,7 @@ class RuleTypeField(obj_fields.BaseEnumField):
super(RuleTypeField, self).__init__(**kwargs)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosRuleType(base.NeutronObject):
# Version 1.0: Initial version
# Version 1.1: Added QosDscpMarkingRule
@ -79,7 +78,7 @@ class QosRuleType(base.NeutronObject):
primitive.pop('drivers', None)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QosRuleTypeDriver(base.NeutronObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
import sqlalchemy as sa
from sqlalchemy import sql
@ -23,7 +22,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class ResourceDelta(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -41,7 +40,7 @@ class ResourceDelta(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Reservation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -108,7 +107,7 @@ class Reservation(base.NeutronDbObject):
for (resource, exp, total_reserved) in resv_query)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Quota(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -123,7 +122,7 @@ class Quota(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class QuotaUsage(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -14,7 +14,6 @@ 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 oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from sqlalchemy import func
@ -29,7 +28,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class RouterRoute(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -65,7 +64,7 @@ class RouterRoute(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class RouterExtraAttributes(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -124,7 +123,7 @@ class RouterExtraAttributes(base.NeutronDbObject):
return [(router, agent_count) for router, agent_count in query]
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class RouterPort(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -155,7 +154,7 @@ class RouterPort(base.NeutronDbObject):
return [r[0] for r in query]
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class DVRMacAddress(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -186,7 +185,7 @@ class DVRMacAddress(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class FloatingIP(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.common import utils
@ -20,7 +19,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SecurityGroup(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -65,7 +64,7 @@ class SecurityGroup(base.NeutronDbObject):
self.obj_reset_changes(['is_default'])
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class DefaultSecurityGroup(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -82,7 +81,7 @@ class DefaultSecurityGroup(base.NeutronDbObject):
primary_keys = ['project_id']
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SecurityGroupRule(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import servicetype as models
@ -21,7 +20,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class ProviderResourceAssociation(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -12,7 +12,6 @@
import netaddr
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.common import utils
@ -24,7 +23,7 @@ from neutron.objects import common_types
from neutron.objects import rbac_db
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class DNSNameServer(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -56,7 +55,7 @@ class DNSNameServer(base.NeutronDbObject):
**kwargs)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Route(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -95,7 +94,7 @@ class Route(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class IPAllocationPool(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -139,7 +138,7 @@ class IPAllocationPool(base.NeutronDbObject):
return result
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SubnetServiceType(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -163,7 +162,7 @@ class SubnetServiceType(base.NeutronDbObject):
# - added 'shared' to synthetic_fields
# - registered extra_filter_name for 'shared' attribute
# - added loading shared attribute based on network 'rbac_entries'
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Subnet(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -14,7 +14,6 @@
# under the License.
import netaddr
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db import api as db_api
@ -23,7 +22,7 @@ from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SubnetPool(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -86,7 +85,7 @@ class SubnetPool(base.NeutronDbObject):
self._attach_prefixes(fields['prefixes'])
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SubnetPoolPrefix(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -10,14 +10,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import tag as tag_model
from neutron.objects import base
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Tag(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'

View File

@ -17,7 +17,6 @@ from neutron_lib import exceptions as n_exc
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 base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db import api as db_api
@ -27,7 +26,7 @@ from neutron.services.trunk import exceptions as t_exc
from neutron.services.trunk import models
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class SubPort(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -82,7 +81,7 @@ class SubPort(base.NeutronDbObject):
trunk_id=self.trunk_id)
@obj_base.VersionedObjectRegistry.register
@base.NeutronObjectRegistry.register
class Trunk(base.NeutronDbObject):
# Version 1.0: Initial version
# Version 1.1: Changed tenant_id to project_id

View File

@ -17,7 +17,6 @@ import mock
from neutron_lib import context
from oslo_utils import uuidutils
from oslo_versionedobjects import fields as obj_fields
from oslo_versionedobjects import fixture
import testtools
from neutron.api.rpc.callbacks import resources
@ -27,6 +26,7 @@ from neutron.common import topics
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
TEST_EVENT = 'test_event'
@ -76,7 +76,7 @@ class ResourcesRpcBaseTestCase(base.BaseTestCase):
super(ResourcesRpcBaseTestCase, self).setUp()
self.obj_registry = self.useFixture(
fixture.VersionedObjectRegistryFixture())
objects_test_base.NeutronObjectRegistryFixture())
self.context = context.get_admin_context()
mock.patch.object(resources_rpc.resources,

View File

@ -13,7 +13,6 @@
# under the License.
from neutron_lib.db import model_base
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
import sqlalchemy as sa
@ -33,7 +32,7 @@ class FakeDbModelWithStandardAttributes(
tag_support = False
@obj_base.VersionedObjectRegistry.register_if(False)
@objects_base.NeutronObjectRegistry.register_if(False)
class FakeObjectWithStandardAttributes(objects_base.NeutronDbObject):
VERSION = '1.0'
db_model = FakeDbModelWithStandardAttributes

View File

@ -15,6 +15,7 @@ import copy
import itertools
import random
import fixtures
import mock
import netaddr
from neutron_lib import constants
@ -28,7 +29,6 @@ from oslo_utils import uuidutils
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import exception
from oslo_versionedobjects import fields as obj_fields
from oslo_versionedobjects import fixture
import testtools
from neutron.db import _model_query as model_query
@ -67,7 +67,7 @@ class ObjectFieldsModel(dict):
pass
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeSmallNeutronObject(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -89,7 +89,7 @@ class FakeSmallNeutronObject(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeSmallNeutronObjectWithMultipleParents(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -109,7 +109,7 @@ class FakeSmallNeutronObjectWithMultipleParents(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeParent(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -128,7 +128,7 @@ class FakeParent(base.NeutronDbObject):
synthetic_fields = ['children']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeWeirdKeySmallNeutronObject(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -148,7 +148,30 @@ class FakeWeirdKeySmallNeutronObject(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register_if(False)
class NeutronObjectRegistryFixture(fixtures.Fixture):
"""Use a NeutronObjectRegistry as a temp registry pattern fixture.
It is fixture similar to
oslo_versionedobjects.fixture.VersionedObjectRegistryFixture
but it uses Neutron's base registry class
"""
def setUp(self):
super(NeutronObjectRegistryFixture, self).setUp()
self._base_test_obj_backup = copy.deepcopy(
base.NeutronObjectRegistry._registry._obj_classes)
self.addCleanup(self._restore_obj_registry)
@staticmethod
def register(cls_name):
base.NeutronObjectRegistry.register(cls_name)
def _restore_obj_registry(self):
base.NeutronObjectRegistry._registry._obj_classes = \
self._base_test_obj_backup
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronDbObject(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -169,7 +192,7 @@ class FakeNeutronDbObject(base.NeutronDbObject):
synthetic_fields = ['obj_field']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectNonStandardPrimaryKey(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -189,7 +212,7 @@ class FakeNeutronObjectNonStandardPrimaryKey(base.NeutronDbObject):
synthetic_fields = ['obj_field', 'field2']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectCompositePrimaryKey(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -208,7 +231,7 @@ class FakeNeutronObjectCompositePrimaryKey(base.NeutronDbObject):
synthetic_fields = ['obj_field']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectUniqueKey(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -230,7 +253,7 @@ class FakeNeutronObjectUniqueKey(base.NeutronDbObject):
synthetic_fields = ['obj_field']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectRenamedField(base.NeutronDbObject):
"""
Testing renaming the parameter from DB to NeutronDbObject
@ -256,7 +279,7 @@ class FakeNeutronObjectRenamedField(base.NeutronDbObject):
fields_need_translation = {'field_ovo': 'field_db'}
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectCompositePrimaryKeyWithId(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -274,7 +297,7 @@ class FakeNeutronObjectCompositePrimaryKeyWithId(base.NeutronDbObject):
synthetic_fields = ['obj_field']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectMultipleForeignKeys(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -291,7 +314,7 @@ class FakeNeutronObjectMultipleForeignKeys(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectSyntheticField(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -307,7 +330,7 @@ class FakeNeutronObjectSyntheticField(base.NeutronDbObject):
synthetic_fields = ['obj_field']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectSyntheticField2(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -322,7 +345,7 @@ class FakeNeutronObjectSyntheticField2(base.NeutronDbObject):
synthetic_fields = ['obj_field']
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectWithProjectId(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -336,7 +359,7 @@ class FakeNeutronObjectWithProjectId(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObject(base.NeutronObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -363,7 +386,7 @@ class FakeNeutronObject(base.NeutronObject):
]
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectDictOfMiscValues(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -376,7 +399,7 @@ class FakeNeutronObjectDictOfMiscValues(base.NeutronDbObject):
}
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronObjectListOfDictOfMiscValues(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -543,7 +566,7 @@ class _BaseObjectTestCase(object):
self.valid_field_filter = {valid_field:
self.obj_fields[-1][valid_field]}
self.obj_registry = self.useFixture(
fixture.VersionedObjectRegistryFixture())
NeutronObjectRegistryFixture())
self.obj_registry.register(FakeSmallNeutronObject)
self.obj_registry.register(FakeWeirdKeySmallNeutronObject)
self.obj_registry.register(FakeNeutronObjectMultipleForeignKeys)
@ -649,7 +672,7 @@ class _BaseObjectTestCase(object):
def _get_ovo_object_class(self, objclass, field):
try:
name = objclass.fields[field].objname
return obj_base.VersionedObjectRegistry.obj_classes().get(name)[0]
return base.NeutronObjectRegistry.obj_classes().get(name)[0]
except TypeError:
# NOTE(korzen) some synthetic fields are not handled by
# this method, for example the ones that have subclasses, see
@ -1230,7 +1253,7 @@ class UniqueKeysTestCase(test_base.BaseTestCase):
get_unique_keys.return_value = [['field1'],
['field2', 'db_field3']]
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class UniqueKeysTestObject(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
@ -1932,7 +1955,7 @@ class UniqueObjectBase(test_base.BaseTestCase):
def setUp(self):
super(UniqueObjectBase, self).setUp()
obj_registry = self.useFixture(
fixture.VersionedObjectRegistryFixture())
NeutronObjectRegistryFixture())
self.db_model = FakeModel
class RegisteredObject(base.NeutronDbObject):

View File

@ -15,10 +15,10 @@
import os
import pprint
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fixture
from neutron import objects
from neutron.objects import base
from neutron.tests import base as test_base
@ -114,7 +114,7 @@ class TestObjectVersions(test_base.BaseTestCase):
def test_versions(self):
checker = fixture.ObjectVersionChecker(
obj_base.VersionedObjectRegistry.obj_classes())
base.NeutronObjectRegistry.obj_classes())
fingerprints = checker.get_hashes()
if os.getenv('GENERATE_HASHES'):

View File

@ -16,12 +16,12 @@ 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 oslo_versionedobjects import base as obj_base
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
@ -41,7 +41,7 @@ class FakeRbacModel(rbac_db_models.RBACColumns, model_base.BASEV2):
return (rbac_db_models.ACCESS_SHARED,)
@obj_base.VersionedObjectRegistry.register_if(False)
@base.NeutronObjectRegistry.register_if(False)
class FakeNeutronDbObject(rbac_db.NeutronRbacObject):
# Version 1.0: Initial version
VERSION = '1.0'