BMC code update changes

This changes addresses the following:
    - Using power setting utils for poweroff
    - Add PrepareForUpdate Method

Resolves openbmc/openbmc-test-automation#132

Change-Id: I5c09057e9e8c3895ef49097dc5ee81ae2155b0c6
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
index a54b7f2..adb7691 100644
--- a/extended/code_update/code_update_utils.robot
+++ b/extended/code_update/code_update_utils.robot
@@ -8,8 +8,9 @@
 
 *** Variables ***
 
-${BMC_UPD_METHOD}   /org/openbmc/control/flash/bmc/action/update
-${BMC_UPD_ATTR}     /org/openbmc/control/flash/bmc
+${BMC_UPD_METHOD}    /org/openbmc/control/flash/bmc/action/update
+${BMC_PREP_METHOD}   /org/openbmc/control/flash/bmc/action/PrepareForUpdate
+${BMC_UPD_ATTR}      /org/openbmc/control/flash/bmc
 
 *** Keywords ***
 
@@ -38,6 +39,18 @@
     should contain    ${data['status']}   to apply
 
 
+Prepare For Update
+    [Documentation]   Switch to update mode in progress. This method calls
+    ...               the Abort method to remove the pending update if there
+    ...               is any before code activation.
+    ${data} =   create dictionary   data=@{EMPTY}
+    ${resp}=    openbmc post request    ${BMC_PREP_METHOD}   data=${data}
+    should be equal as strings   ${resp.status_code}   ${HTTP_OK}
+
+    ${data}=      Read Properties     ${BMC_UPD_ATTR}
+    should contain    ${data['status']}   Switch to update mode in progress
+
+
 SCP Tar Image File to BMC
     [arguments]         ${filepath}
     Open Connection for SCP
diff --git a/extended/code_update/update_bmc.robot b/extended/code_update/update_bmc.robot
index b2d7692..29566fe 100644
--- a/extended/code_update/update_bmc.robot
+++ b/extended/code_update/update_bmc.robot
@@ -8,6 +8,10 @@
 ...               Update work flow sequence:
 ...                 - User input BMC File existence check
 ...                 - Ping Test and REST authentication
+...                 - Issue poweroff
+...                 - Prepare for Update
+...                 - Force reboot
+...                 - Wait for BMC to come online clean
 ...                 - Apply preserve BMC Network setting
 ...                 - SCP image to BMC
 ...                 - Activate the flash image
@@ -16,7 +20,6 @@
 ...                 - Version check post update
 
 Resource          code_update_utils.robot
-Resource          ../../lib/boot/boot_resource_master.robot
 
 *** Variables ***
 
@@ -35,7 +38,11 @@
     Run Keyword if  '${status}' == '${False}'
     ...     Pass Execution   Same Driver version installed
 
-    BMC Power Off
+    Initiate Power Off
+    Prepare For Update
+    # TODO: openbmc/openbmc#519
+    Trigger Warm Reset via Reboot
+    Check If BMC is Up    5 min   10 sec
 
     Preserve BMC Network Setting
     SCP Tar Image File to BMC   ${FILE_PATH}