Merge "Provide object tagging using the tag plugin"

This commit is contained in:
Zuul 2021-01-26 13:23:26 +00:00 committed by Gerrit Code Review
commit 98d12b6f14
3 changed files with 10 additions and 21 deletions

View File

@ -15,7 +15,9 @@
import copy
import itertools
from neutron_lib.api.definitions import network_segment_range as nsr_def
from neutron_lib import constants
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions as n_exc
from neutron_lib.objects import common_types
@ -75,17 +77,12 @@ class NetworkSegmentRange(base.NeutronDbObject):
# fields
_dict.update({'available': self._get_available_allocation()})
_dict.update({'used': self._get_used_allocation_mapping()})
# TODO(kailun): For tag mechanism. This will be removed in bug/1704137
try:
_dict['tags'] = [t.tag for t in self.db_obj.standard_attr.tags]
except AttributeError:
# AttrtibuteError can be raised when accessing self.db_obj
# or self.db_obj.standard_attr
pass
# NOTE(ralonsoh): this workaround should be removed once the migration
# from "tenant_id" to "project_id" is finished.
_dict = db_utils.resource_fields(_dict, fields)
_dict.pop('tenant_id', None)
resource_extend.apply_funcs(nsr_def.COLLECTION_NAME, _dict,
self.db_obj)
return _dict
def _check_shared_project_id(self, action):

View File

@ -15,6 +15,8 @@
import itertools
from neutron_lib.api.definitions import qos as qos_def
from neutron_lib.db import resource_extend
from neutron_lib.exceptions import qos as qos_exc
from neutron_lib.objects import common_types
from oslo_db import exception as db_exc
@ -121,15 +123,9 @@ class QosPolicy(rbac_db.NeutronRbacObject):
raise qos_exc.QosRuleNotFound(policy_id=self.id,
rule_id=rule_id)
# TODO(hichihara): For tag mechanism. This will be removed in bug/1704137
def to_dict(self):
_dict = super(QosPolicy, self).to_dict()
try:
_dict['tags'] = [t.tag for t in self.db_obj.standard_attr.tags]
except AttributeError:
# AttrtibuteError can be raised when accessing self.db_obj
# or self.db_obj.standard_attr
pass
resource_extend.apply_funcs(qos_def.POLICIES, _dict, self.db_obj)
return _dict
@classmethod

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.api.definitions import trunk as trunk_def
from neutron_lib.db import resource_extend
from neutron_lib import exceptions as n_exc
from neutron_lib.objects import common_types
from neutron_lib.objects import exceptions as o_exc
@ -125,13 +127,7 @@ class Trunk(base.NeutronDbObject):
self.update_fields(kwargs)
super(Trunk, self).update()
# TODO(hichihara): For tag mechanism. This will be removed in bug/1704137
def to_dict(self):
_dict = super(Trunk, self).to_dict()
try:
_dict['tags'] = [t.tag for t in self.db_obj.standard_attr.tags]
except AttributeError:
# AttrtibuteError can be raised when accessing self.db_obj
# or self.db_obj.standard_attr
pass
resource_extend.apply_funcs(trunk_def.TRUNKS, _dict, self.db_obj)
return _dict