Moved common variables and keyword out of test suite

Change-Id: I88cba15809a24cb50a5883975d6259ef5d3fa878
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/data/pel_variables.py b/data/pel_variables.py
index 1a14803..a3986f8 100644
--- a/data/pel_variables.py
+++ b/data/pel_variables.py
@@ -11,3 +11,31 @@
     'Message': 'An application had an internal failure',
     'SRC': 'BD8D1002',
     'Sev': 'Unrecoverable Error'}
+
+ERROR_LOG_CREATE_BASE_CMD = 'busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging \
+    xyz.openbmc_project.Logging.Create Create ssa{ss} '
+
+CMD_INTERNAL_FAILURE = ERROR_LOG_CREATE_BASE_CMD + 'xyz.openbmc_project.Common.Error.InternalFailure \
+    xyz.openbmc_project.Logging.Entry.Level.Error 0'
+
+CMD_FRU_CALLOUT = ERROR_LOG_CREATE_BASE_CMD + 'xyz.openbmc_project.Common.Error.Timeout \
+    xyz.openbmc_project.Logging.Entry.Level.Error 2 "TIMEOUT_IN_MSEC" "5" "CALLOUT_INVENTORY_PATH" \
+    "/xyz/openbmc_project/inventory/system/chassis/motherboard"'
+
+CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT = 'org.open_power.Logging.Error.TestError1 \
+    xyz.openbmc_project.Logging.Entry.Level.Error 0'
+
+CMD_INFORMATIONAL_ERROR = ERROR_LOG_CREATE_BASE_CMD + 'xyz.openbmc_project.Common.Error.TestError2 \
+    xyz.openbmc_project.Logging.Entry.Level.Informational 0'
+
+CMD_INVENTORY_PREFIX = 'busctl get-property xyz.openbmc_project.Inventory.Manager \
+    /xyz/openbmc_project/inventory/system/chassis/motherboard'
+
+CMD_UNRECOVERABLE_ERROR = ERROR_LOG_CREATE_BASE_CMD + 'xyz.openbmc_project.Common.Error.InternalFailure \
+    xyz.openbmc_project.Logging.Entry.Level.Error 0'
+
+CMD_PREDICTIVE_ERROR = ERROR_LOG_CREATE_BASE_CMD + 'xyz.openbmc_project.Common.Error.InternalFailure \
+    xyz.openbmc_project.Logging.Entry.Level.Warning 0'
+
+CMD_UNRECOVERABLE_HOST_ERROR = ERROR_LOG_CREATE_BASE_CMD + 'xyz.openbmc_project.Host.Error.Event \
+    xyz.openbmc_project.Logging.Entry.Level.Error 1 RAWPEL /tmp/FILE_NBMC_UNRECOVERABLE'
diff --git a/lib/logging_utils.robot b/lib/logging_utils.robot
index 7c1fbea..9e28a80 100644
--- a/lib/logging_utils.robot
+++ b/lib/logging_utils.robot
@@ -3,7 +3,7 @@
 
 Resource        rest_client.robot
 Variables       ../data/variables.py
-
+Variables       ../data/pel_variables.py
 
 *** Variables ***
 
@@ -149,6 +149,36 @@
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
     ...  msg=Could not clear BMC error logs.
 
+
+Create Test PEL Log
+    [Documentation]  Generate test PEL log.
+    [Arguments]  ${pel_type}=Internal Failure
+
+    # Description of argument(s):
+    # pel_type      The PEL type (e.g. Internal Failure, FRU Callout, Procedural Callout).
+
+    # Test PEL log entry example:
+    # {
+    #    "0x5000002D": {
+    #            "SRC": "BD8D1002",
+    #            "Message": "An application had an internal failure",
+    #            "PLID": "0x5000002D",
+    #            "CreatorID": "BMC",
+    #            "Subsystem": "BMC Firmware",
+    #            "Commit Time": "02/25/2020  04:47:09",
+    #            "Sev": "Unrecoverable Error",
+    #            "CompID": "0x1000"
+    #    }
+    # }
+
+    Run Keyword If  '${pel_type}' == 'Internal Failure'
+    ...   BMC Execute Command  ${CMD_INTERNAL_FAILURE}
+    ...  ELSE IF  '${pel_type}' == 'FRU Callout'
+    ...   BMC Execute Command  ${CMD_FRU_CALLOUT}
+    ...  ELSE IF  '${pel_type}' == 'Procedure And Symbolic FRU Callout'
+    ...   BMC Execute Command  ${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}
+
+
 Create Test Error Log
     [Documentation]  Generate test error log.
     # Test error log entry example:
diff --git a/openpower/pel/test_bmc_pel.robot b/openpower/pel/test_bmc_pel.robot
index dd1b2e7..8e46817 100644
--- a/openpower/pel/test_bmc_pel.robot
+++ b/openpower/pel/test_bmc_pel.robot
@@ -14,41 +14,9 @@
 
 *** Variables ***
 
-${CMD_INTERNAL_FAILURE}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
-...  xyz.openbmc_project.Logging.Entry.Level.Error 0
-
-${CMD_FRU_CALLOUT}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.Timeout
-...  xyz.openbmc_project.Logging.Entry.Level.Error 2 "TIMEOUT_IN_MSEC" "5"
-...  "CALLOUT_INVENTORY_PATH" "/xyz/openbmc_project/inventory/system/chassis/motherboard"
-
-${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss} org.open_power.Logging.Error.TestError1
-...  xyz.openbmc_project.Logging.Entry.Level.Error 0
-
-${CMD_INFORMATIONAL_ERROR}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.TestError2
-...  xyz.openbmc_project.Logging.Entry.Level.Informational 0
-
-${CMD_INVENTORY_PREFIX}  busctl get-property xyz.openbmc_project.Inventory.Manager
-...  /xyz/openbmc_project/inventory/system/chassis/motherboard
-
-${CMD_UNRECOVERABLE_ERROR}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
-...  xyz.openbmc_project.Logging.Entry.Level.Error 0
-
-${CMD_PREDICTIVE_ERROR}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
-...   xyz.openbmc_project.Logging.Entry.Level.Warning 0
-
-${CMD_UNRECOVERABLE_HOST_ERROR}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
-...  xyz.openbmc_project.Logging.Create Create ssa{ss}
-...  xyz.openbmc_project.Host.Error.Event xyz.openbmc_project.Logging.Entry.Level.Error 1
-...  RAWPEL /tmp/FILE_NBMC_UNRECOVERABLE
-
 @{mandatory_pel_fileds}   Private Header  User Header  Primary SRC  Extended User Header  Failing MTMS
 
+
 *** Test Cases ***
 
 Create Test PEL Log And Verify
@@ -761,35 +729,6 @@
     [return]  ${usage_percent}
 
 
-Create Test PEL Log
-    [Documentation]  Generate test PEL log.
-    [Arguments]  ${pel_type}=Internal Failure
-
-    # Description of argument(s):
-    # pel_type      The PEL type (e.g. Internal Failure, FRU Callout, Procedural Callout).
-
-    # Test PEL log entry example:
-    # {
-    #    "0x5000002D": {
-    #            "SRC": "BD8D1002",
-    #            "Message": "An application had an internal failure",
-    #            "PLID": "0x5000002D",
-    #            "CreatorID": "BMC",
-    #            "Subsystem": "BMC Firmware",
-    #            "Commit Time": "02/25/2020  04:47:09",
-    #            "Sev": "Unrecoverable Error",
-    #            "CompID": "0x1000"
-    #    }
-    # }
-
-    Run Keyword If  '${pel_type}' == 'Internal Failure'
-    ...   BMC Execute Command  ${CMD_INTERNAL_FAILURE}
-    ...  ELSE IF  '${pel_type}' == 'FRU Callout'
-    ...   BMC Execute Command  ${CMD_FRU_CALLOUT}
-    ...  ELSE IF  '${pel_type}' == 'Procedure And Symbolic FRU Callout'
-    ...   BMC Execute Command  ${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}
-
-
 Get PEL Log IDs
     [Documentation]  Returns the list of PEL log IDs which contains given field's value.
     [Arguments]  ${pel_section}  ${pel_field}  @{pel_field_value}