From 9111e83dcdc4e1cffcbec73554667a9c4d167ff7 Mon Sep 17 00:00:00 2001 From: ZHAOWANGSHU Date: Tue, 12 Aug 2025 10:15:33 +0000 Subject: [PATCH] feature: Add fixed ip filter in list_recycle_servers Change-Id: I036e6ebec4b28a29d05126a09bb362409469c882 Signed-off-by: ZHAOWANGSHU --- skyline_apiserver/api/v1/extension.py | 9 +++++++++ .../tests/unit/api/v1/test_extension.py | 2 ++ swagger.json | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/skyline_apiserver/api/v1/extension.py b/skyline_apiserver/api/v1/extension.py index a9f2f6f..49ef648 100644 --- a/skyline_apiserver/api/v1/extension.py +++ b/skyline_apiserver/api/v1/extension.py @@ -324,6 +324,13 @@ def list_recycle_servers( uuid: Optional[str] = Query( None, description="Filter the list of recycle servers by the given recycle server UUID." ), + ip: Optional[str] = Query( + None, + description=( + "Filter the list of recycle servers by the given IP address " + "(only fixed, not floating). Also passed to Nova API if supported." + ), + ), ) -> schemas.RecycleServersResponse: all_projects = all_projects or False if all_projects: @@ -365,6 +372,8 @@ def list_recycle_servers( "project_id": project_id, "uuid": uuid, } + if ip is not None: + search_opts["ip"] = ip if not all_projects: search_opts["project_id"] = profile.project.id servers = nova.list_servers( diff --git a/skyline_apiserver/tests/unit/api/v1/test_extension.py b/skyline_apiserver/tests/unit/api/v1/test_extension.py index 8ef5da0..95e7f06 100644 --- a/skyline_apiserver/tests/unit/api/v1/test_extension.py +++ b/skyline_apiserver/tests/unit/api/v1/test_extension.py @@ -126,6 +126,7 @@ class TestListRecycleServersReal: project_name=None, name=None, uuid=None, + ip="10.0.0.5", ) # Assertions @@ -140,6 +141,7 @@ class TestListRecycleServersReal: assert call_args[1]["search_opts"]["deleted"] is True assert call_args[1]["search_opts"]["all_tenants"] is True assert call_args[1]["search_opts"]["project_id"] == "test-project-id" + assert call_args[1]["search_opts"]["ip"] == "10.0.0.5" # Verify other services were called mock_glance.list_images.assert_called() diff --git a/swagger.json b/swagger.json index d6cfe32..2145ba3 100644 --- a/swagger.json +++ b/swagger.json @@ -791,6 +791,24 @@ }, "description": "Filter the list of recycle servers by the given recycle server UUID." }, + { + "name": "ip", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "description": "Filter the list of recycle servers by the given IP address (only fixed, not floating). Also passed to Nova API if supported.", + "title": "Ip" + }, + "description": "Filter the list of recycle servers by the given IP address (only fixed, not floating). Also passed to Nova API if supported." + }, { "name": "X-Openstack-Request-Id", "in": "header",