Set system, chassis, and bmc as global variables

Changes:
  - Add SYSTEM_ID as a global variable and set to default value system
  - Replace redfish/v1/Systems/system to redfish/v1/Systems/SYSTEM_ID
  - Replace redfish/v1/Chassis/chassis to redfish/v1/Chassis/CHASSIS_ID
  - Replace redfish/v1/Managers/bmc to redfish/v1/Managers/MANAGER_ID

Tested:
  - Tested on sandbox with the changes with sample test run with
    sample test ID runs
    1. without SYSTEM_ID provided
    2. with -v SYSTEM_ID:system1
    3. with export SYSTEM_ID=""
    3. with export SYSTEM_ID="system2"

Change-Id: Ifc412b20038cef1eba632caaa6c300be328259bd
Signed-off-by: Wilson Suen <wilsons@supermicro.com>
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish_utils.robot b/lib/bmc_redfish_utils.robot
index a9ca187..c8e9ac4 100644
--- a/lib/bmc_redfish_utils.robot
+++ b/lib/bmc_redfish_utils.robot
@@ -32,7 +32,7 @@
     #  }
     # }
 
-    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/system/  ComputerSystem.Reset
+    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/${SYSTEM_ID}/  ComputerSystem.Reset
     ${payload}=  Create Dictionary  ResetType=${reset_type}
     ${resp}=  Redfish.Post  ${target}  body=&{payload}
     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
@@ -60,7 +60,7 @@
 Reset BIOS Via Redfish
     [Documentation]  Do BIOS reset through Redfish.
 
-    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/system/Bios/  Bios.ResetBios
+    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/${SYSTEM_ID}/Bios/  Bios.ResetBios
     Redfish.Post  ${target}  valid_status_codes=[${HTTP_OK}]
 
 
@@ -173,7 +173,7 @@
     # fru_type  The type of fru (e.g. "Processors", "Memory", etc.).
 
     ${fru_records}=  Redfish_Utils.Enumerate Request
-    ...  /redfish/v1/Systems/system/${fru_type}  return_json=0
+    ...  /redfish/v1/Systems/${SYSTEM_ID}/${fru_type}  return_json=0
     ${fru_records}=  Filter Struct  ${fru_records}  [('State', 'Enabled'), ('Health', 'OK')]
 
     [Return]  ${fru_records}
diff --git a/lib/common_utils.robot b/lib/common_utils.robot
index 5eeb62c..18f77a1 100755
--- a/lib/common_utils.robot
+++ b/lib/common_utils.robot
@@ -865,7 +865,7 @@
 Redfish Get Host Version
     [Documentation]  Get host version via Redfish.
 
-    ${output}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Systems/system  BiosVersion
+    ${output}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Systems/${SYSTEM_ID}  BiosVersion
     [Return]  ${output}
 
 
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
index d320059..02b203c 100644
--- a/lib/dump_utils.robot
+++ b/lib/dump_utils.robot
@@ -194,7 +194,7 @@
 Redfish Delete All System Dumps
     [Documentation]  Delete all system  dumps via Redfish.
 
-    Redfish.Post  /redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog
+    Redfish.Post  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/Dump/Actions/LogService.ClearLog
 
 
 Redfish BMC Dump Should Not Exist
diff --git a/lib/logging_utils.robot b/lib/logging_utils.robot
index 9d6ca1f..bc77fc4 100644
--- a/lib/logging_utils.robot
+++ b/lib/logging_utils.robot
@@ -319,7 +319,7 @@
     [Documentation]  Do Redfish EventLog purge.
 
     ${target_action}=  redfish_utils.Get Target Actions
-    ...  /redfish/v1/Systems/system/LogServices/EventLog/  LogService.ClearLog
+    ...  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/  LogService.ClearLog
     Redfish.Post  ${target_action}  body={'target': '${target_action}'}
     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
 
@@ -335,7 +335,7 @@
     [Documentation]  Do Redfish PostCodes purge from system.
 
     ${target_action}=  redfish_utils.Get Target Actions
-    ...  /redfish/v1/Systems/system/LogServices/PostCodes/  LogService.ClearLog
+    ...  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/PostCodes/  LogService.ClearLog
     Redfish.Post  ${target_action}  body={'target': '${target_action}'}
     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
 
@@ -361,7 +361,7 @@
     #    [Name]:                   POST Code Log Entry
     #    [Severity]:               OK
 
-    ${members}=  Redfish.Get Attribute  /redfish/v1/Systems/system/LogServices/PostCodes/Entries  Members
+    ${members}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/PostCodes/Entries  Members
     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
 
     [Return]  ${members}
diff --git a/lib/open_power_utils.robot b/lib/open_power_utils.robot
index 344590b..21a0901 100644
--- a/lib/open_power_utils.robot
+++ b/lib/open_power_utils.robot
@@ -83,7 +83,7 @@
 Get Functional Processor Count
     [Documentation]  Get functional processor count.
 
-    ${cpu_list}=  Redfish.Get Members List  /redfish/v1/Systems/system/Processors/  *cpu*
+    ${cpu_list}=  Redfish.Get Members List  /redfish/v1/Systems/${SYSTEM_ID}/Processors/  *cpu*
 
     FOR  ${endpoint_path}  IN  @{cpu_list}
        # {'Health': 'OK', 'State': 'Enabled'} get only matching status good.
@@ -98,7 +98,7 @@
 Get Active OCC State Count
     [Documentation]  Get active OCC state count.
 
-    ${cpu_list}=  Redfish.Get Members List  /redfish/v1/Systems/system/Processors/  *cpu*
+    ${cpu_list}=  Redfish.Get Members List  /redfish/v1/Systems/${SYSTEM_ID}/Processors/  *cpu*
 
     FOR  ${endpoint_path}  IN  @{cpu_list}
        ${num}=  Set Variable  ${endpoint_path[-1]}
@@ -150,7 +150,7 @@
     #  /redfish/v1/Systems/system/Processors/cpu0
     #  /redfish/v1/Systems/system/Processors/cpu1
 
-    ${cpu_list}=  Redfish.Get Members List  /redfish/v1/Systems/system/Processors/  cpu*
+    ${cpu_list}=  Redfish.Get Members List  /redfish/v1/Systems/${SYSTEM_ID}/Processors/  cpu*
 
     FOR  ${endpoint_path}  IN  @{cpu_list}
        # {'Health': 'OK', 'State': 'Enabled'} get only matching status good.
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index cd7dd3f..5820532 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -236,9 +236,23 @@
         del FFDC_GET_REQUEST[key]
 
 REDFISH_BASE = "/redfish/v1/"
-REDFISH_ELOG = REDFISH_BASE + "Systems/system/LogServices/EventLog/Entries"
 REDFISH_FIRMWARE = REDFISH_BASE + "UpdateService/FirmwareInventory"
 
+try:
+    REDFISH_SYSTEM_ID = REDFISH_SYSTEM_ID = os.environ.get(
+        "SYSTEM_ID", ""
+    ) or BuiltIn().get_variable_value("${SYSTEM_ID}", default="system")
+
+    REDFISH_ELOG = (
+        REDFISH_BASE
+        + "Systems/"
+        + REDFISH_SYSTEM_ID
+        + "/LogServices/EventLog/Entries"
+    )
+except RobotNotRunningError:
+    REDFISH_ELOG = REDFISH_BASE + "Systems/system/LogServices/EventLog/Entries"
+    pass
+
 # Add file name and corresponding Get Request
 FFDC_GET_REDFISH_REQUEST = {
     "GET REQUESTS": {
diff --git a/lib/redfish_code_update_utils.robot b/lib/redfish_code_update_utils.robot
index 4395ef2..96dd265 100644
--- a/lib/redfish_code_update_utils.robot
+++ b/lib/redfish_code_update_utils.robot
@@ -24,7 +24,7 @@
     ...   '${image_info["Description"]}' == 'BMC image' or '${image_info["Description"]}' == 'BMC update'
     ...    Redfish.Get Attribute  /redfish/v1/Managers/${MANAGER_ID}  FirmwareVersion
     ...  ELSE
-    ...    Redfish.Get Attribute  /redfish/v1/Systems/system  BiosVersion
+    ...    Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}  BiosVersion
 
     ${functional}=  Run Keyword And Return Status
     ...   Should Be Equal  ${sw_functional}  ${image_info["Version"]}
@@ -245,7 +245,7 @@
     # quiet    Indicates whether results should be printed.
 
     ${state}=  Redfish.Get Attribute
-    ...  ${REDFISH_BASE_URI}Systems/system  PowerState
+    ...  ${REDFISH_BASE_URI}Systems/${SYSTEM_ID}  PowerState
     Rqprint Vars  state
 
     [Return]  ${state}
diff --git a/lib/resource.robot b/lib/resource.robot
index 6e54e6e..49ddc4c 100755
--- a/lib/resource.robot
+++ b/lib/resource.robot
@@ -35,6 +35,7 @@
 
 ${MANAGER_ID}              bmc
 ${CHASSIS_ID}              chassis
+${SYSTEM_ID}               system
 
 # MTLS_ENABLED indicates whether mTLS is enabled.
 ${MTLS_ENABLED}            False
diff --git a/lib/utils.robot b/lib/utils.robot
index eeeb9a0..e0fd04f 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -375,7 +375,7 @@
 Redfish Get Power Restore Policy
     [Documentation]  Returns the BMC power restore policy.
 
-    ${power_restore_policy}=  Redfish.Get Attribute  /redfish/v1/Systems/system  PowerRestorePolicy
+    ${power_restore_policy}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}  PowerRestorePolicy
     [Return]  ${power_restore_policy}
 
 Get Auto Reboot
@@ -388,7 +388,7 @@
 Redfish Get Auto Reboot
     [Documentation]  Returns auto reboot setting.
 
-    ${resp}=  Redfish.Get Attribute  /redfish/v1/Systems/system  Boot
+    ${resp}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}  Boot
     [Return]  ${resp["AutomaticRetryConfig"]}
 
 
@@ -691,7 +691,7 @@
     # Description of argument(s):
     # power_restore_policy    Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState").
 
-    Redfish.Patch  /redfish/v1/Systems/system  body={"PowerRestorePolicy": "${power_restore_policy}"}
+    Redfish.Patch  /redfish/v1/Systems/${SYSTEM_ID}  body={"PowerRestorePolicy": "${power_restore_policy}"}
     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
 
 
@@ -749,7 +749,7 @@
     # Description of argument(s):
     # setting    The reboot setting, "RetryAttempts" and "Disabled".
 
-    Redfish.Patch  /redfish/v1/Systems/system  body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
+    Redfish.Patch  /redfish/v1/Systems/${SYSTEM_ID}  body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
 
     ${current_setting}=  Redfish Get Auto Reboot
@@ -881,10 +881,10 @@
 
     ${payload}=  Create Dictionary  Boot=${data}
 
-    Redfish.Patch  /redfish/v1/Systems/system  body=&{payload}
+    Redfish.Patch  /redfish/v1/Systems/${SYSTEM_ID}  body=&{payload}
     ...  valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
 
-    ${resp}=  Redfish.Get Attribute  /redfish/v1/Systems/system  Boot
+    ${resp}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}  Boot
     Should Be Equal As Strings  ${resp["BootSourceOverrideEnabled"]}  ${override_enabled}
     Should Be Equal As Strings  ${resp["BootSourceOverrideTarget"]}  ${override_target}
     Run Keyword If  '${PLATFORM_ARCH_TYPE}' == 'x86'
@@ -916,7 +916,7 @@
     # Description of argument(s):
     # match_state    Expected match state (e.g. Enabled, Starting, Error)
 
-    ${Status}=  Redfish.Get Attribute  /redfish/v1/Managers/bmc  Status
+    ${Status}=  Redfish.Get Attribute  /redfish/v1/Managers/${MANAGER_ID}  Status
 
     Should Be Equal As Strings  ${match_state}  ${Status['State']}
 
@@ -946,7 +946,7 @@
     #    "LastState": "OSRunning"
     # },
 
-    ${boot_progress}=  Redfish.Get Properties  /redfish/v1/Systems/system/
+    ${boot_progress}=  Redfish.Get Properties  /redfish/v1/Systems/${SYSTEM_ID}/
 
     Return From Keyword If  "${PLATFORM_ARCH_TYPE}" == "x86"
     ...  NA  ${boot_progress["Status"]["State"]}