Add support to find a list of redfish URL ending with endpoints
Chamges:
- Function to return list of entries ending with /endpoint
For end point "Power":
['/redfish/v1/Chassis/chassis/Power',
'/redfish/v1/Chassis/motherboard/Power']
Change-Id: I6a5ad3fa5fc9c65fb6618b0ede3e9829bc95dcc1
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish_utils.py b/lib/bmc_redfish_utils.py
index f8d2a94..484c7af 100644
--- a/lib/bmc_redfish_utils.py
+++ b/lib/bmc_redfish_utils.py
@@ -5,6 +5,7 @@
"""
import json
+import re
from robot.libraries.BuiltIn import BuiltIn
import gen_print as gp
@@ -82,6 +83,25 @@
resp = self._redfish_.get(resource_path)
return resp.dict
+ def get_endpoint_path_list(self, resource_path, end_point_prefix):
+ r"""
+ Returns list with entries ending in "/endpoint".
+
+ Description of argument(s):
+ resource_path URI resource base path (e.g. "/redfish/v1/Chassis/").
+ end_point_prefix Name of the enpoint (e.g. 'Power').
+
+ Find all list entries ending in "/endpoint" combination such as
+ /redfish/v1/Chassis/<foo>/Power
+ /redfish/v1/Chassis/<bar>/Power
+ """
+
+ end_point_list = self.list_request(resource_path)
+
+ # Regex to match entries ending in "/prefix" with optional underscore.
+ regex = ".*/" + end_point_prefix + "[_]?[0-9]*?"
+ return [x for x in end_point_list if re.match(regex, x, re.IGNORECASE)]
+
def get_target_actions(self, resource_path, target_attribute):
r"""
Returns resource target entry of the searched target attribute.