Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Commit 86a3e95

Browse files
Reverts part of the SLA-endpoint change, keeping pagesize changes and increasing version number.
1 parent 88ae8ee commit 86a3e95

File tree

5 files changed

+79
-36
lines changed

5 files changed

+79
-36
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ straightforward as possible.
1616

1717
### Fixed
1818

19+
## [1.0.1] - 2021-08-27
20+
21+
### Fixed
22+
23+
* Reverts SLA-Endpoint changes to stop counting removed VM's.
24+
* Pagesize code inside of the rest-request remains unchanged.
25+
26+
### Changed
27+
28+
* Changes SLA-Request count-field name and group name to a better matching candidate.
29+
* Removes the need to cut of prefix via regex
30+
* Removes associated regex code
31+
* Changes REST-Client query time measurement from using a timer to using the result-internal timer.
32+
1933
## [1.0.0] - 2021-08-26
2034

2135
### Major changes summary

python/influx/definitions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ def add_table_definitions(cls, database: Database):
486486
'vmCountBySLA': Datatype.INT
487487
},
488488
tags=[
489+
'slaId',
489490
'slaName'
490491
],
491492
retention_policy=cls._RP_DAYS_90(),

python/sppConnection/api_queries.py

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
ApiQueries
55
"""
66
import logging
7-
from typing import List, Dict, Any
7+
from typing import List, Dict, Any, Optional
88
import json
9+
import urllib.parse
910

11+
from utils.execption_utils import ExceptionUtils
12+
from utils.spp_utils import SppUtils
1013
from sppConnection.rest_client import RequestType, RestClient
1114

1215

@@ -108,38 +111,67 @@ def get_all_vms(self) -> List[Dict[str, Any]]:
108111

109112
def get_vms_per_sla(self) -> List[Dict[str, Any]]:
110113
"""retrieves and calculates all vmware per SLA."""
111-
endpoint = "/api/endeavour/catalog/recovery/hypervisorvm"
112-
allow_list = [
113-
"_id.protectionInfo.storageProfileName",
114-
"count"
115-
]
116-
params = {
117-
"action": "aggregate",
118-
"pageSize": None
119-
}
120-
# other options: volume, vm, tag, tagcategory
121-
post_data = {
122-
"op":[
123-
{
124-
"operation": "count",
125-
"fieldname": "protectionInfo.storageProfileName",
126-
"outputname": "vmCountBySLA" # buggy request, does actually not change anything
127-
}
128-
],
129-
"group": [
130-
"protectionInfo.storageProfileName"
131-
]
132-
}
133114

134-
return self.__rest_client.get_objects(
115+
endpoint = "/ngp/slapolicy"
116+
allow_list = ["name", "id"]
117+
array_name = "slapolicies"
118+
119+
sla_policty_list = self.__rest_client.get_objects(
135120
endpoint=endpoint,
136-
params=params,
137-
request_type=RequestType.POST,
138121
allow_list=allow_list,
139-
post_data=post_data,
140-
add_time_stamp=True,
141-
array_name="results")
122+
array_name=array_name,
123+
add_time_stamp=False
124+
)
125+
126+
result_list: List[Dict[str, Any]] = []
127+
for sla_policty in sla_policty_list:
128+
try:
129+
sla_name: str = sla_policty["name"]
130+
except KeyError as error:
131+
ExceptionUtils.exception_info(error, extra_message="skipping one sla entry due missing name.")
132+
continue
133+
sla_id: Optional[str] = sla_policty.get("id", None)
134+
135+
result_dict: Dict[str, Any] = {}
136+
137+
## hotadd:
138+
sla_name = urllib.parse.quote_plus(sla_name)
139+
140+
endpoint = "/api/hypervisor/search"
141+
params = {
142+
"resourceType": "vm",
143+
"from": "hlo",
144+
"pageSize": 1,
145+
"filter": json.dumps([
146+
{
147+
"property": "storageProfileName",
148+
"value": sla_name,
149+
"op": "="
150+
}
151+
])
152+
}
153+
# other options: volume, vm, tag, tagcategory
154+
post_data = {
155+
"name": "*",
156+
"hypervisorType": "vmware",
157+
}
158+
159+
(response_json, _) = self.__rest_client.query_url(
160+
self.__rest_client.get_url(endpoint),
161+
params,
162+
RequestType.POST,
163+
post_data)
164+
165+
result_dict["slaName"] = sla_name
166+
result_dict["slaId"] = sla_id
167+
result_dict["vmCountBySLA"] = response_json.get("total", None)
168+
169+
time_key, time = SppUtils.get_capture_timestamp_sec()
170+
result_dict[time_key] = time
171+
172+
result_list.append(result_dict)
142173

174+
return result_list
143175

144176
def get_sla_dump(self) -> List[Dict[str, Any]]:
145177
"""retrieves all storage profiles."""

python/sppmon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
08/22/2021 version 0.15 Added --fullLogs argument and reduced regular/loaded joblog query to SUMMARY-Only
6666
08/25/2021 version 0.15.1 Replaced SLA-Endpoint by so-far unknown endpoint, bringing it in line with other api-requests.
6767
08/27/2021 version 1.0.0 Release of SPPMon
68+
08/27/2021 version 1.0.1 Reverted parts of the SLA-Endpoint change
6869
"""
6970
from __future__ import annotations
7071

@@ -93,7 +94,7 @@
9394
from utils.spp_utils import SppUtils
9495

9596
# Version:
96-
VERSION = "1.0.0 (2021/08/27)"
97+
VERSION = "1.0.1 (2021/08/27)"
9798

9899

99100
# ----------------------------------------------------------------------------

python/sppmonMethods/protection.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77
import logging
88

9-
from re import compile, sub
109
from typing import List, Dict, Any, Union, Optional
1110

1211
from influx.influx_client import InfluxClient
@@ -55,11 +54,7 @@ def vms_per_sla(self) -> None:
5554
LOGGER.info("> calculating number of VMs per SLA")
5655
result = MethodUtils.query_something(
5756
name="VMs per SLA",
58-
source_func=self.__api_queries.get_vms_per_sla,
59-
rename_tuples=[
60-
("storageProfileName", "slaName"),
61-
("count", "vmCountBySLA") # buggy request
62-
]
57+
source_func=self.__api_queries.get_vms_per_sla
6358
)
6459
LOGGER.info(">> inserting number of VMs per SLA into DB")
6560
self.__influx_client.insert_dicts_to_buffer(

0 commit comments

Comments
 (0)