Retry BMC image file over network via SCP
Post SCP check if the file size is 32M, if not delete the incomplete
/tmp/flashimg file from BMC and SCP again. If this fails the update
manager would anyway flag "Unpack Error". This is just a way to reduce
the SCP timedout failure due to flaky network.
Resolves openbmc/openbmc-test-automation#98
Resolves openbmc/openbmc#1946
Change-Id: I761938b7adffd914c40dfd065d20d164b0a86fde
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/extended/code_update/code_update_utils.robot b/extended/code_update/code_update_utils.robot
old mode 100644
new mode 100755
index dac252b..e86d50b
--- a/extended/code_update/code_update_utils.robot
+++ b/extended/code_update/code_update_utils.robot
@@ -54,9 +54,47 @@
SCP Tar Image File to BMC
- [Arguments] ${filepath}
+ [Documentation] Copy BMC tar image to BMC.
+ [Arguments] ${image_file_path}
+ # Description of argument(s):
+ # image_file_path Downloaded BMC tar file image path.
+
+
Open Connection for SCP
- scp.Put File ${filepath} /tmp/flashimg
+ Open Connection And Log In
+ Loop SCP Retry ${image_file_path}
+
+
+Loop SCP Retry
+ [Documentation] Try transferring the file 4 times.
+ [Arguments] ${image_file_path}
+ # Description of argument(s):
+ # image_file_path Downloaded BMC tar file image path.
+
+ : FOR ${index} IN RANGE 0 4
+ \ ${status}= Retry SCP ${image_file_path}
+ \ Exit For Loop If '${status}' == '${True}'
+
+
+Retry SCP
+ [Documentation] Delete the incomplete file and scp file.
+ [Arguments] ${image_file_path}
+ # Description of argument(s):
+ # image_file_path Downloaded BMC tar file image path.
+
+ ${targ_file_path}= Set Variable /tmp/flashimg
+
+ # TODO: Need to remove this when new code update in place.
+ # Example output:
+ # root@witherspoon:~# ls -lh /tmp/flashimg
+ # -rwxr-xr-x 1 root root 32.0M Jun 29 01:12 /tmp/flashimg
+ Execute Command On BMC rm -f /tmp/flashimg
+ scp.Put File ${image_file_path} ${targ_file_path}
+
+ ${file_size}= Execute Command On BMC ls -lh ${targ_file_path}
+ ${status}= Run Keyword And Return Status
+ ... Should Contain ${file_size} 32.0M msg=Incomplete file transfer.
+ [return] ${status}
Check If File Exist