Library robot code with the latest directives
Changes: Run Keyword If is deprecated since Robot
Framework version 5.*, use 'IF' instead
Tested: Tested with dry-run option changes
Change-Id: I6a7be9749d00aec3dfdb6b8ae3cf0c4b9ac2ce45
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/snmp/redfish_snmp_utils.robot b/lib/snmp/redfish_snmp_utils.robot
index 9045143..a7bc30a 100644
--- a/lib/snmp/redfish_snmp_utils.robot
+++ b/lib/snmp/redfish_snmp_utils.robot
@@ -175,10 +175,11 @@
# Delete the SNMP manager if the requested IP & ports are found
# and mark is_snmp_found to true.
- Run Keyword If 'snmp://${snmp_ip_port}' == '${snmp_mgr}'
- ... Run Keywords Set Local Variable ${is_snmp_found} ${True}
- ... AND Redfish.Delete ${snmp_mgr_uri}
- ... AND Exit For Loop
+ IF 'snmp://${snmp_ip_port}' == '${snmp_mgr}'
+ Set Local Variable ${is_snmp_found} ${True}
+ Redfish.Delete ${snmp_mgr_uri}
+ Exit For Loop
+ END
END
Pass Execution If ${is_snmp_found} == ${False}
diff --git a/lib/snmp/snmp_utils.robot b/lib/snmp/snmp_utils.robot
index d94cb8f..122789b 100644
--- a/lib/snmp/snmp_utils.robot
+++ b/lib/snmp/snmp_utils.robot
@@ -34,13 +34,13 @@
${resp}= OpenBMC Post Request
... ${SNMP_MANAGER_URI}action/Client data=${data}
- Run Keyword If '${expected_result}' == 'error'
- ... Should Be Equal As Strings
- ... ${resp.status_code} ${HTTP_BAD_REQUEST}
- ... msg=Allowing the configuration of an invalid SNMP.
- ... ELSE
- ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ... msg=Not allowing the configuration of a valid SNMP.
+ IF '${expected_result}' == 'error'
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_BAD_REQUEST}
+ ... msg=Allowing the configuration of an invalid SNMP.
+ ELSE
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
+ ... msg=Not allowing the configuration of a valid SNMP.
+ END
Get List Of SNMP Manager And Port Configured On BMC
@@ -95,9 +95,9 @@
${snmp_objs}= Read Properties ${SNMP_MANAGER_URI}enumerate
FOR ${snmp_obj} IN @{snmp_objs}
${obj}= Set Variable ${snmp_objs['${snmp_obj}']}
- Run Keyword If
- ... '${obj['Address']}' == '${ip}' and '${obj['Port']}' == '${port}'
- ... Return From Keyword ${snmp_obj}
+ IF '${obj['Address']}' == '${ip}' and '${obj['Port']}' == '${port}'
+ Return From Keyword ${snmp_obj}
+ END
END
Return From Keyword ${EMPTY}
diff --git a/lib/state_manager.robot b/lib/state_manager.robot
index bd6cbe2..af9044d 100755
--- a/lib/state_manager.robot
+++ b/lib/state_manager.robot
@@ -25,7 +25,7 @@
... ${HOST_STATE_URI} RequestedHostTransition data=${args}
# Does caller want to wait for status?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ IF '${wait}' == '${0}' Return From Keyword
Wait Until Keyword Succeeds
... 10 min 10 sec Is Host Running
@@ -45,11 +45,11 @@
... ${HOST_STATE_URI} RequestedHostTransition data=${args}
# Does caller want to wait for status?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ IF '${wait}' == '${0}' Return From Keyword
${status}= Run Keyword And Return Status Wait For PowerOff
- Run Keyword if '${status}' == '${False}' Hard Power Off
+ IF '${status}' == '${False}' Hard Power Off
Wait For PowerOff
@@ -71,7 +71,7 @@
... ${CHASSIS_STATE_URI} RequestedPowerTransition data=${args}
# Does caller want to wait for status?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ IF '${wait}' == '${0}' Return From Keyword
Wait Until Keyword Succeeds
... 1 min 10 sec Run Keywords Is Chassis Off AND Is Host Off
@@ -89,7 +89,7 @@
... ${HOST_STATE_URI} RequestedHostTransition data=${args}
# Does caller want to wait for host booted status?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ IF '${wait}' == '${0}' Return From Keyword
Is Host Rebooted
@@ -179,9 +179,10 @@
[Documentation] Recover host from quisced state.
${resp}= Run Keyword And Return Status Is Host Quiesced
- Run Keyword If '${resp}' == 'True'
- ... Run Keywords Initiate Host PowerOff AND
- ... Log HOST is recovered from quiesced state
+ IF '${resp}' == 'True'
+ Initiate Host PowerOff
+ Log HOST is recovered from quiesced state
+ END
Get Host State
@@ -231,10 +232,11 @@
# expected_state - expected BMC state
${bmc_state}= Get BMC State
- Run Keyword If '${bmc_state}' == '${expected_state}'
- ... Log BMC is already in ${expected_state} state
- ... ELSE
- ... OBMC Reboot (off)
+ IF '${bmc_state}' == '${expected_state}'
+ Log BMC is already in ${expected_state} state
+ ELSE
+ OBMC Reboot (off)
+ END
Initiate BMC Reboot
[Documentation] Initiate BMC reboot.
@@ -249,10 +251,10 @@
... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
# Does caller want to wait for status?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ IF '${wait}' == '${0}' Return From Keyword
${session_active}= Check If BMC Reboot Is Initiated
- Run Keyword If '${session_active}' == '${True}'
+ IF '${session_active}' == '${True}'
... Fail msg=BMC Reboot didn't occur.
Check If BMC is Up
@@ -282,13 +284,13 @@
[Documentation] Wait until given BMC state is reached.
[Arguments] ${state}
# state - BMC state to wait for
- Run Keyword If '${state}' == '${BMC_READY_STATE}'
- ... Wait Until Keyword Succeeds
- ... 10 min 10 sec Is BMC Ready
- ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
- ... Wait Until Keyword Succeeds
- ... 10 min 10 sec Is BMC Not Ready
- ... ELSE Fail msg=Invalid BMC state
+ IF '${state}' == '${BMC_READY_STATE}'
+ Wait Until Keyword Succeeds 10 min 10 sec Is BMC Ready
+ ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
+ Wait Until Keyword Succeeds 10 min 10 sec Is BMC Not Ready
+ ELSE
+ Fail msg=Invalid BMC state
+ END
Set State Interface Version
@@ -296,18 +298,20 @@
${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
${status}= Run Keyword And Return Status
... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- Run Keyword If '${status}' == '${True}'
- ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
- ... ELSE
- ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
+ IF '${status}' == '${True}'
+ Set Global Variable ${OBMC_STATES_VERSION} ${1}
+ ELSE
+ Set Global Variable ${OBMC_STATES_VERSION} ${0}
+ END
Power Off Request
[Documentation] Select appropriate poweroff keyword.
- Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
- ... Initiate Power Off
- ... ELSE
- ... Initiate Host PowerOff
+ IF '${OBMC_STATES_VERSION}' == '${0}'
+ Initiate Power Off
+ ELSE
+ Initiate Host PowerOff
+ END
Wait For BMC Ready
diff --git a/lib/utils.robot b/lib/utils.robot
index 8c00bd1..e25b0a5 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -48,13 +48,11 @@
[Documentation] Verify ping and rest authentication.
${l_ping}= Run Keyword And Return Status
... Ping Host ${OPENBMC_HOST}
- Run Keyword If '${l_ping}' == '${False}'
- ... Fail msg=Ping Failed
+ IF '${l_ping}' == '${False}' Fail msg=Ping Failed
${l_rest}= Run Keyword And Return Status
... Initialize OpenBMC
- Run Keyword If '${l_rest}' == '${False}'
- ... Fail msg=REST Authentication Failed
+ IF '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
# Just to make sure the SSH is working for SCP
Open Connection And Log In
@@ -66,10 +64,10 @@
[Documentation] Verify ping, SSH and redfish authentication.
${l_ping}= Run Keyword And Return Status Ping Host ${OPENBMC_HOST}
- Run Keyword If '${l_ping}' == '${False}' Fail msg=Ping Failed
+ IF '${l_ping}' == '${False}' Fail msg=Ping Failed
${l_rest}= Run Keyword And Return Status Redfish.Login
- Run Keyword If '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
+ IF '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
# Just to make sure the SSH is working.
Open Connection And Log In
@@ -115,8 +113,9 @@
... data=xyz.openbmc_project.State.Watchdog.Action.PowerCycle
${status} ${result}= Run Keyword And Ignore Error
... Read Attribute ${HOST_WATCHDOG_URI} ExpireAction
- Run Keyword If '${status}' == 'PASS'
- ... Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data}
+ IF '${status}' == 'PASS'
+ Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data}
+ END
${int_milliseconds}= Convert To Integer ${milliseconds}
${data}= Create Dictionary data=${int_milliseconds}
@@ -245,16 +244,16 @@
# the only recourse users will have is that they may specify
# -v boot_prog_method:Old to force old behavior on such builds.
- Run Keyword If '${boot_prog_method}' != '${EMPTY}' Return From Keyword
+ IF '${boot_prog_method}' != '${EMPTY}' Return From Keyword
${new_status} ${new_value}= Run Keyword And Ignore Error
... New Get Boot Progress
# If the new style read fails, the method must necessarily be "Old".
- Run Keyword If '${new_status}' == 'PASS'
- ... Run Keywords
- ... Set Global Variable ${boot_prog_method} New AND
- ... Rqpvars boot_prog_method AND
- ... Return From Keyword
+ IF '${new_status}' == 'PASS'
+ Set Global Variable ${boot_prog_method} New
+ Rqpvars boot_prog_method
+ Return From Keyword
+ END
# Default method is "Old".
Set Global Variable ${boot_prog_method} Old
@@ -277,7 +276,7 @@
should be equal as strings ${resp.status_code} ${HTTP_OK}
# Does caller want to wait for power on status?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ IF '${wait}' == '${0}' Return From Keyword
Wait Until Keyword Succeeds 3 min 10 sec Is Power On
@@ -368,8 +367,7 @@
... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
${session_active}= Check If warmReset is Initiated
- Run Keyword If '${session_active}' == '${True}'
- ... Fail msg=warm reset didn't occur
+ IF '${session_active}' == '${True}' Fail msg=warm reset didn't occur
Sleep ${SYSTEM_SHUTDOWN_TIME}min
Check If BMC Is Up
@@ -690,10 +688,11 @@
... 1=RetryAttempts
... 0=Disabled
- Run Keyword If ${REDFISH_SUPPORT_TRANS_STATE} == ${1}
- ... Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]}
- ... ELSE
- ... Set Auto Reboot ${value}
+ IF ${REDFISH_SUPPORT_TRANS_STATE} == ${1}
+ Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]}
+ ELSE
+ Set Auto Reboot ${value}
+ END
Set Auto Reboot
[Documentation] Set the given auto reboot setting.
@@ -843,8 +842,9 @@
${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled}
... BootSourceOverrideTarget=${override_target}
- Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
- ... Set To Dictionary ${data} BootSourceOverrideMode ${override_mode}
+ IF '${PLATFORM_ARCH_TYPE}' == 'x86'
+ Set To Dictionary ${data} BootSourceOverrideMode ${override_mode}
+ END
${payload}= Create Dictionary Boot=${data}
@@ -854,8 +854,9 @@
${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'
- ... Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode}
+ IF '${PLATFORM_ARCH_TYPE}' == 'x86'
+ Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode}
+ END
# Redfish state keywords.
@@ -969,8 +970,9 @@
... host=Disabled
... boot_progress=None
- Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
- ... Set To Dictionary ${standby_states} boot_progress=NA
+ IF '${PLATFORM_ARCH_TYPE}' == 'x86'
+ Set To Dictionary ${standby_states} boot_progress=NA
+ END
Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States