DMTF redfish system path logic update in test suites

Changes:
     - Dynamincally find the logical id and use

Resolves   openbmc/openbmc-test-automation#2172

Change-Id: I9af1cc6a3ad4b7ad29270b9b8013fe18e6259bd1
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/gui/gui_test/overview_menu/test_overview_menu.robot b/gui/gui_test/overview_menu/test_overview_menu.robot
index abaee7a..89e90f7 100644
--- a/gui/gui_test/overview_menu/test_overview_menu.robot
+++ b/gui/gui_test/overview_menu/test_overview_menu.robot
@@ -123,15 +123,15 @@
     [Tags]  Verify_Server_LED_Turn_On
 
     # Turn Off the server LED via Redfish and refresh GUI.
-    Redfish.Patch  /redfish/v1/Systems/system  body={"IndicatorLED":"Off"}   valid_status_codes=[200, 204]
+    Set IndicatorLED State  Off
+
     Refresh GUI
 
     # Turn ON the LED via GUI.
     Click Element At Coordinates  ${xpath_led_button}  0  0
 
     # Cross check that server LED ON state via Redfish.
-    ${led_status}=  Redfish.Get Attribute  /redfish/v1/Systems/system  IndicatorLED
-    Should Be True  '${led_status}' == 'Lit'
+    Verify Identify LED State Via Redfish  Lit
 
 
 Verify Server LED Turn Off
@@ -139,15 +139,14 @@
     [Tags]  Verify_Server_LED_Turn_Off
 
     # Turn On the server LED via Redfish and refresh GUI.
-    Redfish.Patch  /redfish/v1/Systems/system  body={"IndicatorLED":"Lit"}   valid_status_codes=[200, 204]
+    Set IndicatorLED State  Lit
     Refresh GUI
 
     # Turn OFF the LED via GUI.
     Click Element At Coordinates  ${xpath_led_button}  0  0
 
     # Cross check that server LED off state via Redfish.
-    ${led_status}=  Redfish.Get Attribute  /redfish/v1/Systems/system  IndicatorLED
-    Should Be True  '${led_status}' == 'Off'
+    Verify Identify LED State Via Redfish  Off
 
 
 Verify BMC Time In Overview Page
@@ -184,3 +183,31 @@
 
     Click Element  ${xpath_overview_menu}
     Wait Until Page Contains Element  ${xpath_overview_page_header}
+
+
+Verify Identify LED State Via Redfish
+    [Documentation]  Verify that Redfish identify LED system with given state.
+    [Arguments]  ${expected_state}
+    # Description of argument(s):
+    # expected_state    Expected value of Identify LED.
+
+    # Python module:  get_member_list(resource_path)
+    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
+    FOR  ${system}  IN  @{systems}
+        ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
+        Should Be True  '${led_value}' == '${expected_state}'
+    END
+
+
+Set IndicatorLED State
+    [Documentation]  Performe redfish PATCH operation.
+    [Arguments]  ${led_state}  ${expect_resp_code}=[200, 204]
+    # Description of argument(s):
+    # led_state            IndicatorLED state to "off", "Lit" etc.
+    # expect_resp_code     Expected HTTPS response code. Default [200, 204]
+
+    # Python module:  get_member_list(resource_path)
+    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
+    FOR  ${system}  IN  @{systems}
+        Redfish.Patch  ${system}  body={"IndicatorLED":${led_state}}   valid_status_codes=${expect_resp_code}
+    END
diff --git a/ipmi/test_ipmi_general.robot b/ipmi/test_ipmi_general.robot
index faab290..4a8c5a7 100644
--- a/ipmi/test_ipmi_general.robot
+++ b/ipmi/test_ipmi_general.robot
@@ -277,5 +277,9 @@
     # Description of argument(s):
     # expected_led_status  Expected value of Identify LED.
 
-    ${led_value}=  Redfish.Get Attribute  /redfish/v1/Systems/system  IndicatorLED
-    Should Be True  '${led_value}' == '${expected_state}'
+    # Python module:  get_member_list(resource_path)
+    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
+    FOR  ${system}  IN  @{systems}
+        ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
+        Should Be True  '${led_value}' == '${expected_state}'
+    END
diff --git a/ipmi/test_ipmi_sensor.robot b/ipmi/test_ipmi_sensor.robot
index 5527465..0bd3347 100644
--- a/ipmi/test_ipmi_sensor.robot
+++ b/ipmi/test_ipmi_sensor.robot
@@ -395,7 +395,10 @@
     #    "State": "Enabled"
     #}
 
-    ${redfish_value}=  Redfish.Get Properties  /redfish/v1/Systems/system/Processors/${component}
+    # Python module:  get_endpoint_path_list(resource_path, end_point_prefix)
+    ${processor_list}=  redfish_utils.Get Endpoint Path List   /redfish/v1/Systems/  Processors
+
+    ${redfish_value}=  Redfish.Get Properties  ${processor_list[0]}/${component}
     Should Be True  '${redfish_value['Status']['State']}' == 'Enabled'
 
 
@@ -420,7 +423,10 @@
     #    "State": "Absent"
     #}
 
-    ${redfish_value}=  Redfish.Get Properties  /redfish/v1/Systems/system/Processors/${component}
+    # Python module:  get_endpoint_path_list(resource_path, end_point_prefix)
+    ${processor_list}=  redfish_utils.Get Endpoint Path List   /redfish/v1/Systems/  Processors
+
+    ${redfish_value}=  Redfish.Get Properties  ${processor_list[0]}/${component}
     Should Be True  '${redfish_value['Status']['State']}' == 'Absent'