Replace deprecated keywords for lib
Changes:
- Run KeyWord If is deprecated since Robot
Framework version 5.*, use 'IF' instead
Tested:
- Checked using robot dry-run to make sure the
syntax is not broken
Change-Id: I4e1418fad55b736d35e47c1fca1175baaab2f0b4
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/lib/bmc_cleanup.robot b/lib/bmc_cleanup.robot
index 8040ead..e8ef2bd 100644
--- a/lib/bmc_cleanup.robot
+++ b/lib/bmc_cleanup.robot
@@ -37,5 +37,6 @@
... find ${cleanup_dir_path} | wc -l
Should Be True ${file_count2} < ${file_count1}
# Delete the directory if it is empty.
- Run Keyword If ${file_count2} <= 1
- ... BMC Execute Command rm -r ${cleanup_dir_path}
+ IF ${file_count2} <= 1
+ BMC Execute Command rm -r ${cleanup_dir_path}
+ END
diff --git a/lib/bmc_date_and_time_utils.robot b/lib/bmc_date_and_time_utils.robot
index 0d9da48..0140b11 100644
--- a/lib/bmc_date_and_time_utils.robot
+++ b/lib/bmc_date_and_time_utils.robot
@@ -37,10 +37,10 @@
# expected.
# Assign default value of UTC current date time if date_time is empty.
- ${date_time}= Run Keyword If
- ... '${date_time}' == '${EMPTY}' Get Current Date time_zone=UTC
- ... ELSE
- ... Set Variable ${date_time}
+ ${current_date_time}= Get Current Date time_zone=UTC
+ ${date_time}= Set Variable If '${date_time}' == '${EMPTY}'
+ ... ${current_date_time} ${date_time}
+
# Patch date_time based on type of ${request_type}.
IF '${request_type}' == 'valid'
${date_time}= Convert Date ${date_time} result_format=%Y-%m-%dT%H:%M:%S+00:00
@@ -70,10 +70,12 @@
# host_state Host state at which date time will be updated for verification
# (eg. on, off).
- Run Keyword If '${host_state}' == 'on'
- ... Redfish Power On stack_mode=skip
- ... ELSE
- ... Redfish Power off stack_mode=skip
+ IF '${host_state}' == 'on'
+ Redfish Power On stack_mode=skip
+ ELSE
+ Redfish Power off stack_mode=skip
+ END
+
${current_date}= Get Current Date time_zone=UTC
${new_value}= Subtract Time From Date ${current_date} 1 day
Redfish Set DateTime ${new_value}
@@ -100,9 +102,11 @@
Restore NTP Status
[Documentation] Restore NTP Status.
- Run Keyword If '${original_ntp["ProtocolEnabled"]}' == 'True'
- ... Set NTP state ${TRUE}
- ... ELSE Set NTP state ${FALSE}
+ IF '${original_ntp["ProtocolEnabled"]}' == 'True'
+ Set NTP state ${TRUE}
+ ELSE
+ Set NTP state ${FALSE}
+ END
Verify NTP Servers Are Populated
@@ -128,10 +132,12 @@
... systemctl status systemd-timesyncd
... ignore_err=${1}
${sync_status}= Get Lines Matching Regexp ${resp[0]} .*Active.*
- Run Keyword If ${expected_sync_status}==${True}
- ... Should Contain ${sync_status} active (running)
- Run Keyword If ${expected_sync_status}==${False}
- ... Should Contain ${sync_status} inactive (dead)
+ IF ${expected_sync_status}==${True}
+ Should Contain ${sync_status} active (running)
+ END
+ IF ${expected_sync_status}==${False}
+ Should Contain ${sync_status} inactive (dead)
+ END
Enable NTP And Add NTP Address
diff --git a/lib/bmc_redfish_utils.robot b/lib/bmc_redfish_utils.robot
index 26aec0a..25d4dc8 100644
--- a/lib/bmc_redfish_utils.robot
+++ b/lib/bmc_redfish_utils.robot
@@ -202,10 +202,12 @@
${context_var}= Get Variable Value ${resp.dict["Context"]} ${EMPTY}
# Handle backward compatibility for OEM.
${oem_var}= Get Variable Value ${resp.dict["Oem"]["OpenBMC"]["ClientID"]} ${EMPTY}
- Run Keyword If '${context_var}' != '${EMPTY}'
- ... Append To List ${client_id_sessions} ${session}
- Run Keyword If '${oem_var}' != '${EMPTY}'
- ... Append To List ${client_id_sessions} ${session}
+ IF '${context_var}' != '${EMPTY}'
+ Append To List ${client_id_sessions} ${session}
+ END
+ IF '${oem_var}' != '${EMPTY}'
+ Append To List ${client_id_sessions} ${session}
+ END
END
RETURN ${client_id_sessions}
@@ -298,17 +300,19 @@
${user_exists}= Run Keyword And Return Status Should Be Equal As Strings ${curr_role}[0] PASS
# Delete user account when force is True.
- Run Keyword If ${force} == ${True} Redfish.Delete ${REDFISH_ACCOUNTS_URI}${user_name}
- ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
+ IF ${force} == ${True}
+ Redfish.Delete ${REDFISH_ACCOUNTS_URI}${user_name}
+ ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
+ END
# Create specified user when force is True or User does not exist.
${payload}= Create Dictionary
... UserName=${user_name} Password=${password} RoleId=${role_id} Enabled=${enabled}
- Run Keyword If ${force} == ${True} or ${user_exists} == ${False}
- ... Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
- ... valid_status_codes=[${HTTP_CREATED}]
-
+ IF ${force} == ${True} or ${user_exists} == ${False}
+ Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
+ ... valid_status_codes=[${HTTP_CREATED}]
+ END
Get User Role
[Documentation] Get User Role.
diff --git a/lib/dmtf_redfishtool_utils.robot b/lib/dmtf_redfishtool_utils.robot
index caf7f31..484aefb 100644
--- a/lib/dmtf_redfishtool_utils.robot
+++ b/lib/dmtf_redfishtool_utils.robot
@@ -25,7 +25,7 @@
${cmd}= Catenate ${cmd_args} GET ${uri}
Log ${cmd}
${rc} ${cmd_output}= Run and Return RC and Output ${cmd}
- Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
+ IF ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
RETURN ${cmd_output}
@@ -44,7 +44,7 @@
${cmd}= Catenate ${cmd_args} PATCH ${uri} --data=${payload}
Log ${cmd}
${rc} ${cmd_output}= Run and Return RC and Output ${cmd}
- Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
+ IF ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
RETURN ${cmd_output}
@@ -64,7 +64,7 @@
${cmd}= Catenate ${cmd_args} POST ${uri} --data=${payload}
Log ${cmd}
${rc} ${cmd_output}= Run and Return RC and Output ${cmd}
- Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
+ IF ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
RETURN ${cmd_output}
@@ -82,7 +82,7 @@
${cmd}= Catenate ${cmd_args} DELETE ${uri}
Log ${cmd}
${rc} ${cmd_output}= Run and Return RC and Output ${cmd}
- Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
+ IF ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
RETURN ${cmd_output}
@@ -100,7 +100,7 @@
Return From Keyword IF ${cmd_rsp_status} == True
${matches}= Get Regexp Matches ${error_expected} 200|204
${rsp_status}= Run Keyword And Return Status Should Be Empty ${matches}
- Run Keyword If ${rsp_status} == False
+ IF ${rsp_status} == False
... Fail msg=${cmd_output}
@{words} = Split String ${error_expected} ,
@{errorString}= Split String ${cmd_output} ${SPACE}
@@ -108,10 +108,12 @@
${status}= Run Keyword And Return Status Should Contain Any ${errorString} ${error}
Return From Keyword If ${status} == True
END
- ${rsp_code}= Run Keyword If ${status} == False Get Regexp Matches ${cmd_output} [0-9][0-9][0-9]
+ ${rsp_code}= Set Variable If ${status} == False Get Regexp Matches ${cmd_output} [0-9][0-9][0-9]
${rsp_code_status}= Run Keyword And Return Status Should Not Be Empty ${rsp_code}
- Run Keyword If ${rsp_code_status} == True
- ... Fail msg=Getting status code as ${rsp_code[0]} instead of ${error_expected}, status code mismatch.
- ... ELSE
- ... Fail msg=${cmd_output}
+
+ IF ${rsp_code_status} == True
+ Fail msg=Getting status code as ${rsp_code[0]} instead of ${error_expected}, status code mismatch.
+ ELSE
+ Fail msg=${cmd_output}
+ END