fix: Fix the limit for ports list

We need set retrieve_all as False when we
use neutron client SDK. Default value is True,
it will retrieve all data.

Change-Id: I4e0222c28038fb1b769667951607376adbae284a
This commit is contained in:
Boxiang Zhu 2022-08-17 14:57:10 +08:00
parent eb59b2614d
commit 3dd6cb89fc
2 changed files with 5 additions and 3 deletions

View File

@ -1009,7 +1009,7 @@ async def list_ports(
server_ids = [] server_ids = []
network_ids = [] network_ids = []
result = [] result = []
for port in ports.get("ports", []): for port in ports.next().get("ports", []):
origin_data = OSPort(port).to_dict() origin_data = OSPort(port).to_dict()
port = Port(port).to_dict() port = Port(port).to_dict()
port["origin_data"] = origin_data port["origin_data"] = origin_data

View File

@ -19,6 +19,7 @@ from typing import Any
from fastapi import HTTPException, status from fastapi import HTTPException, status
from keystoneauth1.exceptions.http import Unauthorized from keystoneauth1.exceptions.http import Unauthorized
from keystoneauth1.session import Session from keystoneauth1.session import Session
from neutronclient.v2_0.client import _GeneratorWithMeta
from starlette.concurrency import run_in_threadpool from starlette.concurrency import run_in_threadpool
from skyline_apiserver import schemas from skyline_apiserver import schemas
@ -54,15 +55,16 @@ async def list_ports(
session: Session, session: Session,
region_name: str, region_name: str,
global_request_id: str, global_request_id: str,
retrieve_all: bool = False,
**kwargs: Any, **kwargs: Any,
) -> Any: ) -> _GeneratorWithMeta:
try: try:
nc = await utils.neutron_client( nc = await utils.neutron_client(
session=session, session=session,
region=region_name, region=region_name,
global_request_id=global_request_id, global_request_id=global_request_id,
) )
return await run_in_threadpool(nc.list_ports, **kwargs) return await run_in_threadpool(nc.list_ports, retrieve_all=retrieve_all, **kwargs)
except Unauthorized as e: except Unauthorized as e:
raise HTTPException( raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED, status_code=status.HTTP_401_UNAUTHORIZED,