objects: update fields_no_update to reflect models
It will make sure that object update code won't mistakenly touch those attributes, triggering foreign key violations for linked resources. Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db Change-Id: I96a7c6fd15cf089d80d0c512e94e7fb9da6aba4d
This commit is contained in:
parent
8c907905b0
commit
caf32b69cd
neutron/objects
@ -35,3 +35,5 @@ class AutoAllocatedTopology(base.NeutronDbObject):
|
||||
'network_id': common_types.UUIDField(),
|
||||
'router_id': common_types.UUIDField(nullable=True),
|
||||
}
|
||||
|
||||
fields_no_update = ['network_id', 'router_id']
|
||||
|
@ -38,6 +38,8 @@ class IpamAllocationPool(base.NeutronDbObject):
|
||||
'last_ip': obj_fields.IPAddressField(),
|
||||
}
|
||||
|
||||
fields_no_update = ['ipam_subnet_id']
|
||||
|
||||
@classmethod
|
||||
def modify_fields_from_db(cls, db_obj):
|
||||
result = super(IpamAllocationPool, cls).modify_fields_from_db(db_obj)
|
||||
|
@ -38,6 +38,8 @@ class MeteringLabelRule(base.NeutronDbObject):
|
||||
'excluded': obj_fields.BooleanField(default=False),
|
||||
}
|
||||
|
||||
fields_no_update = ['metering_label_id']
|
||||
|
||||
@classmethod
|
||||
def modify_fields_from_db(cls, db_obj):
|
||||
result = super(MeteringLabelRule, cls).modify_fields_from_db(db_obj)
|
||||
|
@ -52,6 +52,8 @@ class NetworkSegment(base.NeutronDbObject):
|
||||
|
||||
synthetic_fields = ['hosts']
|
||||
|
||||
fields_no_update = ['network_id']
|
||||
|
||||
foreign_keys = {
|
||||
'Network': {'network_id': 'id'},
|
||||
'PortBindingLevel': {'id': 'segment_id'},
|
||||
|
@ -33,6 +33,8 @@ class ExtraDhcpOpt(base.NeutronDbObject):
|
||||
'ip_version': obj_fields.IntegerField(),
|
||||
}
|
||||
|
||||
fields_no_update = ['port_id']
|
||||
|
||||
foreign_keys = {
|
||||
'Port': {'port_id': 'id'},
|
||||
}
|
||||
|
@ -156,6 +156,8 @@ class IPAllocation(base.NeutronDbObject):
|
||||
'ip_address': obj_fields.IPAddressField(),
|
||||
}
|
||||
|
||||
fields_no_update = fields.keys()
|
||||
|
||||
primary_keys = ['subnet_id', 'network_id', 'ip_address']
|
||||
|
||||
foreign_keys = {
|
||||
@ -261,6 +263,8 @@ class Port(base.NeutronDbObject):
|
||||
# field in later object iterations
|
||||
}
|
||||
|
||||
fields_no_update = ['project_id', 'network_id']
|
||||
|
||||
synthetic_fields = [
|
||||
'allowed_address_pairs',
|
||||
'binding',
|
||||
|
@ -104,7 +104,7 @@ class SecurityGroupRule(base.NeutronDbObject):
|
||||
|
||||
foreign_keys = {'SecurityGroup': {'security_group_id': 'id'}}
|
||||
|
||||
fields_no_update = ['project_id', 'security_group_id']
|
||||
fields_no_update = ['project_id', 'security_group_id', 'remote_group_id']
|
||||
|
||||
# TODO(sayalilunkad): get rid of it once we switch the db model to using
|
||||
# custom types.
|
||||
|
@ -116,6 +116,8 @@ class IPAllocationPool(base.NeutronDbObject):
|
||||
'end': obj_fields.IPAddressField()
|
||||
}
|
||||
|
||||
fields_no_update = ['subnet_id']
|
||||
|
||||
@classmethod
|
||||
def modify_fields_from_db(cls, db_obj):
|
||||
# TODO(korzen) remove this method when IP and CIDR decorator ready
|
||||
@ -195,7 +197,7 @@ class Subnet(base.NeutronDbObject):
|
||||
|
||||
foreign_keys = {'Network': {'network_id': 'id'}}
|
||||
|
||||
fields_no_update = ['project_id']
|
||||
fields_no_update = ['project_id', 'network_id', 'segment_id']
|
||||
|
||||
fields_need_translation = {
|
||||
'host_routes': 'routes'
|
||||
|
@ -44,7 +44,7 @@ class SubPort(base.NeutronDbObject):
|
||||
'segmentation_id': obj_fields.IntegerField(),
|
||||
}
|
||||
|
||||
fields_no_update = ['segmentation_type', 'segmentation_id']
|
||||
fields_no_update = ['segmentation_type', 'segmentation_id', 'trunk_id']
|
||||
|
||||
def to_dict(self):
|
||||
_dict = super(SubPort, self).to_dict()
|
||||
|
Loading…
x
Reference in New Issue
Block a user