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

Commit 88ae8ee

Browse files
switches key of storageprofile to avoid regex issues
1 parent 5436d67 commit 88ae8ee

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

python/sppConnection/api_queries.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def get_all_vms(self) -> List[Dict[str, Any]]:
109109
def get_vms_per_sla(self) -> List[Dict[str, Any]]:
110110
"""retrieves and calculates all vmware per SLA."""
111111
endpoint = "/api/endeavour/catalog/recovery/hypervisorvm"
112+
allow_list = [
113+
"_id.protectionInfo.storageProfileName",
114+
"count"
115+
]
112116
params = {
113117
"action": "aggregate",
114118
"pageSize": None
@@ -118,19 +122,20 @@ def get_vms_per_sla(self) -> List[Dict[str, Any]]:
118122
"op":[
119123
{
120124
"operation": "count",
121-
"fieldname": "protectionInfo.policyName",
125+
"fieldname": "protectionInfo.storageProfileName",
122126
"outputname": "vmCountBySLA" # buggy request, does actually not change anything
123127
}
124128
],
125129
"group": [
126-
"protectionInfo.policyName"
130+
"protectionInfo.storageProfileName"
127131
]
128132
}
129133

130134
return self.__rest_client.get_objects(
131135
endpoint=endpoint,
132136
params=params,
133137
request_type=RequestType.POST,
138+
allow_list=allow_list,
134139
post_data=post_data,
135140
add_time_stamp=True,
136141
array_name="results")

python/sppConnection/rest_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ def query_url(
357357

358358
# send the query
359359
try:
360-
start_time = time.perf_counter()
361360
if(request_type == RequestType.GET):
362361
response_query = get(
363362
url=url, headers=self.__headers, verify=False,
@@ -368,8 +367,7 @@ def query_url(
368367
url=url, headers=self.__headers, verify=False,
369368
params=params, json=post_data, auth=auth,
370369
timeout=(self.__initial_connection_timeout, self.__timeout))
371-
end_time = time.perf_counter()
372-
send_time = (end_time - start_time)
370+
send_time = response_query.elapsed.total_seconds()
373371

374372
except ReadTimeout as timeout_error:
375373

python/sppmonMethods/protection.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,10 @@ def vms_per_sla(self) -> None:
5757
name="VMs per SLA",
5858
source_func=self.__api_queries.get_vms_per_sla,
5959
rename_tuples=[
60-
("_id.protectionInfo.policyName", "slaName"),
60+
("storageProfileName", "slaName"),
6161
("count", "vmCountBySLA") # buggy request
62-
],
63-
deactivate_verbose=True
62+
]
6463
)
65-
66-
# the endpoint offers a prefix `vmware_`
67-
# due to compability reasons the prefix is removed
68-
# may be reintroduced if other types occur.
69-
pattern = compile(r"^vmware_")
70-
for sla in result:
71-
# replaces the first occurence
72-
sla['slaName'] = sub(pattern, "", sla['slaName'], 1)
73-
74-
if(self.__verbose):
75-
MethodUtils.my_print(result)
76-
7764
LOGGER.info(">> inserting number of VMs per SLA into DB")
7865
self.__influx_client.insert_dicts_to_buffer(
7966
table_name="slaStats", list_with_dicts=result)

0 commit comments

Comments
 (0)