Fix resource schemas and releated get_sorts
test cases
When I'm trying to introduce a central sort-keys validation within patch [1] to `get_sorts` method in `neutron.api.api_common` module, I get blocked by some resource schemas and test cases. After reading neutron API docs and some inspection, I believe there exists uses of improper sort keys in test cases and some resource schemes need to keep aligned with offical documents. * Schemas of resource SecurityGroups/SG Rules/Segments don't provide `is_sort_key` flag for their sort key properties claimed in offical docs as neutron-lib does. See [2] for more details. * Test cases of resource NetworkSegmentRange use unsupported sort keys, e.g: physical_network. Replace it with `name` property. See [2] for more details. [1] https://review.opendev.org/#/c/653903/ [2] https://developer.openstack.org/api-ref/network/v2/index.html Conflicts: neutron/tests/unit/extensions/test_network_segment_range.py Change-Id: I45a51736e4075e3dbc16827486869d70b659622d (cherry picked from commit ed3f1087fa354a91721d3046ce134e18c86f22b3) (cherry picked from commit 874ffe0d6b362b19a22fdff1bbbb194687b9c1b8)
This commit is contained in:
parent
f38aee9555
commit
11b5ba0660
neutron/extensions
@ -223,13 +223,16 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': '', 'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {
|
||||
'type:name_not_default': db_const.NAME_FIELD_SIZE}},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True, 'is_filter': True},
|
||||
@ -241,39 +244,42 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'primary_key': True},
|
||||
'security_group_id': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'required_by_policy': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'remote_group_id': {'allow_post': True, 'allow_put': False,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'direction': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {'type:values': ['ingress', 'egress']}},
|
||||
'protocol': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': None,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True, 'is_filter': True,
|
||||
'convert_to': convert_protocol},
|
||||
'port_range_min': {'allow_post': True, 'allow_put': False,
|
||||
'convert_to': convert_validate_port_value,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'port_range_max': {'allow_post': True, 'allow_put': False,
|
||||
'convert_to': convert_validate_port_value,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'ethertype': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': 'IPv4',
|
||||
'is_filter': True,
|
||||
'is_filter': True, 'is_sort_key': True,
|
||||
'convert_to': convert_ethertype_to_case_insensitive,
|
||||
'validate': {'type:values': sg_supported_ethertypes}},
|
||||
'remote_ip_prefix': {'allow_post': True, 'allow_put': False,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True, 'is_filter': True,
|
||||
'convert_to': convert_ip_prefix_to_cidr},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True, 'is_filter': True},
|
||||
|
@ -45,17 +45,20 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'tenant_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string':
|
||||
db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_sort_key': True,
|
||||
'is_visible': False},
|
||||
'network_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
PHYSICAL_NETWORK: {'allow_post': True,
|
||||
'allow_put': False,
|
||||
@ -63,23 +66,27 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'validate': {'type:string':
|
||||
providernet.PHYSICAL_NETWORK_MAX_LEN},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
NETWORK_TYPE: {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string':
|
||||
providernet.NETWORK_TYPE_MAX_LEN},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
SEGMENTATION_ID: {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'default': constants.ATTR_NOT_SPECIFIED,
|
||||
'convert_to': converters.convert_to_int,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
'name': {'allow_post': True,
|
||||
'allow_put': True,
|
||||
'default': constants.ATTR_NOT_SPECIFIED,
|
||||
'validate': {'type:string_or_none': NAME_LEN},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True}
|
||||
},
|
||||
subnet_def.COLLECTION_NAME: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user