Add standard attributes to segment resource
Standard attributes (i.e. revision_number, created_at, updated_at) are missing in the segment resource. This is because the controller doesn't process extensions on rendering the response. This patch fixes it. In particular, this patch does the following: * Process extensions when making the segment dict. This allows other extensions to add attributes to segment response. * Make segment extension implement update_attributes_map. Tempest test: https://review.openstack.org/#/c/558609/ APIImpact update api reference of segments Closes-Bug: #1760902 Change-Id: I3c93818002c2d7753454547231ba08544b6fa1c0
This commit is contained in:
parent
d3db4250be
commit
4d84c10ba4
@ -122,6 +122,10 @@ class Segment(api_extensions.ExtensionDescriptor):
|
||||
controller,
|
||||
attr_map=resource_attributes)]
|
||||
|
||||
def update_attributes_map(self, attributes):
|
||||
super(Segment, self).update_attributes_map(
|
||||
attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP)
|
||||
|
||||
def get_extended_resources(self, version):
|
||||
if version == "2.0":
|
||||
return RESOURCE_ATTRIBUTE_MAP
|
||||
|
@ -25,6 +25,7 @@ from oslo_db import exception as db_exc
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.db import _resource_extend as resource_extend
|
||||
from neutron.db import _utils as db_utils
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import common_db_mixin
|
||||
@ -50,6 +51,7 @@ class SegmentDbMixin(common_db_mixin.CommonDbMixin):
|
||||
db.SEGMENTATION_ID: segment_obj[db.SEGMENTATION_ID],
|
||||
'hosts': segment_obj['hosts'],
|
||||
'segment_index': segment_obj['segment_index']}
|
||||
resource_extend.apply_funcs('segments', res, segment_obj.db_obj)
|
||||
return db_utils.resource_fields(res, fields)
|
||||
|
||||
def _get_segment(self, context, segment_id):
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix an issue that standard attributes, such as ``created_at``,
|
||||
``updated_at`` and ``revision_number``, are not rendered in the response
|
||||
of segment resource.
|
Loading…
Reference in New Issue
Block a user