Neutron agent-list API added with sort_key keyword
Defining a API Extention for enabling sorting in agent -list attributes. Added "is_sort_key" keyword for attributes of agent. Neutron API can use "sort_key" and "sort_dir" for sorting on resulted list. Change-Id: I3155a4f1de664e4ff8e32ccc4314927ea462048c Related-Bug: #1877254
This commit is contained in:
parent
1361d8cfa4
commit
5b035972e5
@ -51,6 +51,8 @@ Request
|
||||
- id: id-query
|
||||
- topic: topic-query
|
||||
- fields: fields
|
||||
- sort_dir: sort_dir
|
||||
- sort_key: agent-sort_key
|
||||
|
||||
Response Parameters
|
||||
-------------------
|
||||
|
@ -327,6 +327,25 @@ admin_state_up_trunk-query:
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
agent-sort_key:
|
||||
description: |
|
||||
Sorts by agent attributes. You can specify multiple pairs of sort key
|
||||
and sort direction query parameters. The sort keys are limited to:
|
||||
|
||||
- ``admin_state_up``
|
||||
- ``agent_type``
|
||||
- ``alive``
|
||||
- ``binary``
|
||||
- ``created_at``
|
||||
- ``description``
|
||||
- ``heartbeat_timestamp``
|
||||
- ``host``
|
||||
- ``id``
|
||||
- ``started_at``
|
||||
- ``topic``
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
agent_type-query:
|
||||
description: |
|
||||
Filter the list result by the type of agent such as ``Open vSwitch agent``
|
||||
|
@ -13,6 +13,7 @@
|
||||
from neutron_lib.api.definitions import address_scope
|
||||
from neutron_lib.api.definitions import agent
|
||||
from neutron_lib.api.definitions import agent_resources_synced
|
||||
from neutron_lib.api.definitions import agent_sort_key
|
||||
from neutron_lib.api.definitions import allowedaddresspairs
|
||||
from neutron_lib.api.definitions import auto_allocated_topology
|
||||
from neutron_lib.api.definitions import availability_zone
|
||||
@ -124,6 +125,7 @@ _ALL_API_DEFINITIONS = {
|
||||
address_scope,
|
||||
agent,
|
||||
agent_resources_synced,
|
||||
agent_sort_key,
|
||||
allowedaddresspairs,
|
||||
auto_allocated_topology,
|
||||
availability_zone,
|
||||
|
36
neutron_lib/api/definitions/agent_sort_key.py
Normal file
36
neutron_lib/api/definitions/agent_sort_key.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Copyright (c) 2013 OpenStack Foundation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from neutron_lib.api.definitions import agent
|
||||
|
||||
ALIAS = 'agent_sort_key'
|
||||
IS_SHIM_EXTENSION = False
|
||||
IS_STANDARD_ATTR_EXTENSION = False
|
||||
NAME = 'Agents Sort Key'
|
||||
API_PREFIX = ''
|
||||
DESCRIPTION = 'Enabling the keyword sort_key for sorting in agents.'
|
||||
UPDATED_TIMESTAMP = '2013-02-03T10:00:00-00:00'
|
||||
is_sort_key = {'is_sort_key': True}
|
||||
agents_collection = agent.RESOURCE_ATTRIBUTE_MAP[agent.COLLECTION_NAME]
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
agent.COLLECTION_NAME: {
|
||||
k: {**v, **is_sort_key} for k, v in agents_collection.items() if
|
||||
k != "configurations"}
|
||||
}
|
||||
SUB_RESOURCE_ATTRIBUTE_MAP = {}
|
||||
ACTION_MAP = {}
|
||||
REQUIRED_EXTENSIONS = []
|
||||
OPTIONAL_EXTENSIONS = []
|
||||
ACTION_STATUS = {}
|
@ -0,0 +1,25 @@
|
||||
# All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api.definitions import agent
|
||||
from neutron_lib.api.definitions import agent_sort_key
|
||||
from neutron_lib.tests.unit.api.definitions import base
|
||||
|
||||
|
||||
class AgentDefinitionTestCase(base.DefinitionBaseTestCase):
|
||||
extension_module = agent_sort_key
|
||||
extension_resources = (agent.COLLECTION_NAME,)
|
||||
extension_attributes = ('topic', 'agent_type', 'created_at',
|
||||
'configurations', 'heartbeat_timestamp',
|
||||
'binary', 'started_at', 'host', 'alive',)
|
5
releasenotes/notes/bug-1877254-2b997b3911e98079.yaml
Normal file
5
releasenotes/notes/bug-1877254-2b997b3911e98079.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add keyword ``is_sort_key`` to agents. Make the agent's
|
||||
attribute can be used as a sort key for sorting list result.
|
Loading…
Reference in New Issue
Block a user