Skip to content

Commit

Permalink
chore: make it able to passthrough variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Jun 21, 2021
1 parent 28ab79c commit 4e8b83b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions API/v1/VM/metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
import time
from typing import Optional
import xml.etree.ElementTree as ET
from http.client import RemoteDisconnected

Expand All @@ -15,6 +16,8 @@
async def instance_get_metrics(
cluster_id: str = Path(default=None, title="cluster_id", description="Cluster ID"),
vm_uuid: str = Path(default=None, title="vm_uuid", description="VM UUID"),
start: Optional[int] = None,
interval: Optional[int] = 60,
):
"""Get Xen Host Metrics"""

Expand All @@ -28,16 +31,14 @@ async def instance_get_metrics(

url = cluster_data["host"] + "/rrd_updates"

epoch = math.floor(time.time())

data_collection = 60
start_epoch = epoch - data_collection
if start is None:
start = math.floor(time.time() - interval)

response = session.get(
url,
params=dict(
start=start_epoch,
interval=data_collection,
start=start,
interval=interval,
cf="AVERAGE",
),
)
Expand Down

0 comments on commit 4e8b83b

Please sign in to comment.