Reading json for post code update action
Change-Id: I6636e81b44ca25c87ed92a65121cccbfebcf86a2
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/applytime_table.json b/data/applytime_table.json
similarity index 100%
rename from lib/applytime_table.json
rename to data/applytime_table.json
diff --git a/lib/utils.py b/lib/utils.py
index 0049cca..05bae08 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -4,6 +4,7 @@
Companion file to utils.robot.
"""
+import os
import gen_print as gp
import gen_robot_keyword as grk
import bmc_ssh_utils as bsu
@@ -18,6 +19,18 @@
import collections
+# The code base directory will be one level up from the directory containing this module.
+code_base_dir_path = os.path.dirname(os.path.dirname(__file__)) + os.sep
+
+
+def get_code_base_dir_path():
+ r"""
+ Return the dir path of our code base.
+ """
+
+ return code_base_dir_path
+
+
def set_power_policy_method():
r"""
Set the global bmc_power_policy_method to either 'Old' or 'New'.
diff --git a/lib/utils.robot b/lib/utils.robot
index ab5faec..b8d3db7 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -713,3 +713,28 @@
${resp}= Post Request openbmc ${BMC_USER_URI}root/action/SetPassword
... data=${data} headers=${headers}
Valid Value resp.status_code [${HTTP_OK}]
+
+
+Get Post Boot Action
+ [Documentation] Get post boot action.
+
+ # Post code update action dictionay.
+ #
+ # {
+ # BMC image: {
+ # OnReset: Redfish OBMC Reboot (off),
+ # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
+ # },
+ # Host image: {
+ # OnReset: Redfish Host Reboot,
+ # Immediate: Wait State os_running_match_state 10 mins
+ # }
+ # }
+
+ ${code_base_dir_path}= Get Code Base Dir Path
+ ${post_code_update_actions}= Evaluate
+ ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json
+ Rprint Vars post_code_update_actions
+
+ [Return] ${post_code_update_actions}
+
diff --git a/redfish/extended/redfish_bmc_code_update.robot b/redfish/extended/redfish_bmc_code_update.robot
index 3999882..c9cc03a 100644
--- a/redfish/extended/redfish_bmc_code_update.robot
+++ b/redfish/extended/redfish_bmc_code_update.robot
@@ -15,6 +15,7 @@
Resource ../../lib/common_utils.robot
Resource ../../lib/code_update_utils.robot
Resource ../../lib/redfish_code_update_utils.robot
+Resource ../../lib/utils.robot
Library ../../lib/gen_robot_valid.py
Library ../../lib/var_funcs.py
Library ../../lib/gen_robot_keyword.py
@@ -51,7 +52,6 @@
# Checking for file existence.
Valid File Path IMAGE_FILE_PATH
-
Activate Existing Firmware
[Documentation] Set fimware image to lower priority.
[Arguments] ${image_version}
@@ -124,15 +124,13 @@
Redfish Update Firmware
[Documentation] Update the BMC firmware via redfish interface.
+ ${post_code_update_actions}= Get Post Boot Action
${state}= Get Pre Reboot State
Rprint Vars state
-
Run Keyword And Ignore Error Set ApplyTime policy=OnReset
Redfish Upload Image And Check Progress State
${tar_version}= Get Version Tar ${IMAGE_FILE_PATH}
${image_info}= Get Software Inventory State By Version ${tar_version}
- ${get_json_file}= OperatingSystem.Get File ${EXECDIR}/lib/applytime_table.json
- ${post_code_update_actions}= Evaluate json.loads('''${get_json_file}''') json
Run Key ${post_code_update_actions['${image_info["image_type"]}']['OnReset']}
Redfish.Login
Redfish Verify BMC Version ${IMAGE_FILE_PATH}