refactor: added async await to ONTAP call
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# contains the business logic for aggregates
|
||||
|
||||
from typing import List
|
||||
|
||||
from fastapi import Request
|
||||
from .aggregate_schema import AggregateSchema, MetricEnum
|
||||
from logging import getLogger
|
||||
from ..utils import round_bytes, get_data_from_ontap
|
||||
@@ -9,13 +11,13 @@ logger = getLogger("uvicorn")
|
||||
logger.setLevel("DEBUG")
|
||||
|
||||
|
||||
async def get_aggregates(metric: str = "relative") -> List[AggregateSchema]:
|
||||
async def get_aggregates(request: Request, metric: str = "relative") -> List[AggregateSchema]:
|
||||
# Dummy data for demonstration
|
||||
# You can use the metric parameter to filter or modify results as needed
|
||||
# For now, just return the same data and show metric usage
|
||||
logger.debug(f"Metric used: {metric}")
|
||||
|
||||
__aggregates = get_data_from_ontap(logger, "172.16.57.2", "admin", "Netapp12", "storage/aggregates", "fields=name,uuid,space,node,home_node")
|
||||
client = request.app.requests_client
|
||||
__aggregates = await get_data_from_ontap(client, logger, "172.16.57.2", "admin", "Netapp12", "storage/aggregates", "fields=name,uuid,space,node,home_node")
|
||||
logger.debug(__aggregates)
|
||||
__aggregates = __aggregates.get("records")
|
||||
if metric == MetricEnum.relative:
|
||||
|
||||
Reference in New Issue
Block a user