BMC driver version check

Checks the user specified BMC version string and if found installed
on the BMC, skip the update process.

Resolves  openbmc/openbmc-test-automation#780

Change-Id: Ia48c90a0db74b02d82cad5f7ac1c2a4586214c99
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 5ec74c8..8be8876 100755
--- a/extended/code_update/code_update_utils.robot
+++ b/extended/code_update/code_update_utils.robot
@@ -114,19 +114,16 @@
 
 
 Validate BMC Version
-    [Arguments]   ${args}=post
-    # Check BMC installed version
+    [Documentation]  Get BMC version from /etc/os-release and compare.
+    [Arguments]  ${version}
+
+    # Description of argument(s):
+    # version  Software version (e.g. "v1.99.8-41-g86a4abc").
+
     Open Connection And Log In
-    ${version}   ${stderr}=    Execute Command   cat /etc/version
-    ...    return_stderr=True
-    Should Be Empty     ${stderr}
-    # The File name contains the version installed
-    Run Keyword If   '${args}' == 'before'
-    ...    Should not Contain  ${FILE_PATH}   ${version}
-    ...    msg=Same version already installed
-    ...    ELSE
-    ...    Should Contain      ${FILE_PATH}   ${version}
-    ...    msg=Code update Failed
+    ${cmd}=  Set Variable  grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '='
+    ${output}=  Execute Command On BMC  ${cmd}
+    Should Be Equal As Strings  ${version}  ${output[1:-1]}
 
 
 Trigger Warm Reset via Reboot
diff --git a/extended/code_update/update_bmc.robot b/extended/code_update/update_bmc.robot
index 8771e86..b82ae13 100644
--- a/extended/code_update/update_bmc.robot
+++ b/extended/code_update/update_bmc.robot
@@ -79,12 +79,12 @@
     [Documentation]  Initiate a code update on the BMC.
     [Tags]  Initiate_Code_Update_BMC
 
-    # TODO: Disabling version check until new logic are in place.
-    # ${status}=   Run Keyword and Return Status
-    # ...   Validate BMC Version   before
+    ${status}=  Run Keyword If  '${LAST_KNOWN_GOOD_VERSION}' != '${EMPTY}'
+    ...  Run Keyword And Return Status
+    ...  Validate BMC Version  ${LAST_KNOWN_GOOD_VERSION}
 
-    # Run Keyword if  '${status}' == '${False}'
-    # ...     Pass Execution   Same Driver version installed
+    Run Keyword if  '${status}' == '${True}'
+    ...  Pass Execution  The BMC already has the requested build loaded so no further action will be taken.
 
     # Enable user to bypass prerequisite operations.
     # Use cases for if BMC is not in working state.