Use the declarative attribute `standard_attr_id`

In those Neutron objects and DB definitions where the declarative
attribute ``standard_attr_id`` is defined, use it instead of accessing
to the ``standard_attr`` child object.

Closes-Bug: #2081945
Change-Id: Iadfbeff79c0200c3a6b90f785b910dc391f9deb3
(cherry picked from commit 144e140e75)
This commit is contained in:
Rodolfo Alonso Hernandez 2024-09-25 07:17:07 +00:00
parent 5561387e16
commit f7ea84216d
5 changed files with 12 additions and 10 deletions

View File

@ -147,9 +147,9 @@ class DbBasePluginCommon(object):
def _make_subnet_dict(self, subnet, fields=None, context=None):
if isinstance(subnet, subnet_obj.Subnet):
standard_attr_id = subnet.db_obj.standard_attr.id
standard_attr_id = subnet.db_obj.standard_attr_id
else:
standard_attr_id = subnet.standard_attr.id
standard_attr_id = subnet.standard_attr_id
res = {'id': subnet['id'],
'name': subnet['name'],
@ -338,7 +338,7 @@ class DbBasePluginCommon(object):
'status': network['status'],
'subnets': [subnet['id']
for subnet in network['subnets']],
'standard_attr_id': network.standard_attr.id}
'standard_attr_id': network.standard_attr_id}
res['shared'] = self._is_network_shared(context, network.rbac_entries)
# Call auxiliary extend functions, if any
if process_extensions:

View File

@ -1245,7 +1245,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
'port_id': floatingip.fixed_port_id,
'fixed_ip_address': fixed_ip_address,
'status': floatingip.status,
'standard_attr_id': floatingip.db_obj.standard_attr.id,
'standard_attr_id': floatingip.db_obj.standard_attr_id,
}
# NOTE(mlavalle): The following assumes this mixin is used in a
# class inheriting from CommonDbMixin, which is true for all existing

View File

@ -326,7 +326,7 @@ class SecurityGroupDbMixin(
'stateful': security_group['stateful'],
'tenant_id': security_group['tenant_id'],
'description': security_group['description'],
'standard_attr_id': security_group.db_obj.standard_attr.id,
'standard_attr_id': security_group.db_obj.standard_attr_id,
'shared': security_group['shared'],
}
if security_group.rules:
@ -498,7 +498,7 @@ class SecurityGroupDbMixin(
'remote_address_group_id': rule_obj[
'remote_address_group_id'],
'remote_group_id': rule_obj['remote_group_id'],
'standard_attr_id': rule_obj.db_obj.standard_attr.id,
'standard_attr_id': rule_obj.db_obj.standard_attr_id,
'description': rule_obj['description'],
'used_in_default_sg': rule_obj['used_in_default_sg'],
'used_in_non_default_sg': rule_obj['used_in_non_default_sg']
@ -905,7 +905,7 @@ class SecurityGroupDbMixin(
'normalized_cidr': self._get_normalized_cidr_from_rule(
sg_rule_db),
'remote_group_id': sg_rule_db.remote_group_id,
'standard_attr_id': sg_rule_db.standard_attr.id,
'standard_attr_id': sg_rule_db.standard_attr_id,
'belongs_to_default_sg': belongs_to_default_sg,
}

View File

@ -61,7 +61,7 @@ class OvnDriver(base.L3ServiceProvider,
db_rev.create_initial_revision(
context, router_id, ovn_const.TYPE_ROUTERS,
std_attr_id=router_db.standard_attr.id)
std_attr_id=router_db.standard_attr_id)
@registry.receives(resources.ROUTER, [events.AFTER_CREATE])
def _process_router_create(self, resource, event, trigger, payload):
@ -167,7 +167,7 @@ class OvnDriver(base.L3ServiceProvider,
return
db_rev.create_initial_revision(
context, floatingip_db.id, ovn_const.TYPE_FLOATINGIPS,
may_exist=True, std_attr_id=floatingip_db.standard_attr.id)
may_exist=True, std_attr_id=floatingip_db.standard_attr_id)
@registry.receives(resources.FLOATING_IP,
[events.PRECOMMIT_CREATE, events.PRECOMMIT_UPDATE])

View File

@ -712,6 +712,7 @@ class FakeFloatingIp(object):
# Set default attributes.
fake_uuid = uuidutils.generate_uuid()
standard_attr = FakeStandardAttribute()
fip_attrs = {
'id': 'fip-id-' + fake_uuid,
'tenant_id': '',
@ -728,7 +729,8 @@ class FakeFloatingIp(object):
'dns_domain': '',
'dns_name': '',
'project_id': '',
'standard_attr': FakeStandardAttribute(),
'standard_attr': standard_attr,
'standard_attr_id': standard_attr.id,
'qos_policy_binding': FakeQosFIPPolicyBinding(),
'qos_network_policy_binding': FakeQosNetworkPolicyBinding(),
}