Moved "Verify IPMI Username And Password" keyword in library

Also simplified the logic to verify username and password.

Change-Id: I83551087b08331acb7c2b200db88b494d9384172
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/ipmi/test_ipmi_user.robot b/ipmi/test_ipmi_user.robot
index d51fda1..a669b26 100644
--- a/ipmi/test_ipmi_user.robot
+++ b/ipmi/test_ipmi_user.robot
@@ -18,10 +18,6 @@
 ${valid_password}       0penBmc1
 ${max_password_length}  20
 ${ipmi_setaccess_cmd}   channel setaccess
-${IPMI_EXT_CMD}         ipmitool -I lanplus -C 3
-${PASSWORD_OPTION}      -P
-${USER_OPTION}          -U
-${SEL_INFO_CMD}         sel info
 
 
 *** Test Cases ***
@@ -248,7 +244,7 @@
     # Verify that disabled IPMI  user is unable to run IPMI command.
     ${msg}=  Run Keyword And Expect Error  *  Verify IPMI Username And Password
     ...  ${random_username}  ${valid_password}
-    Should Contain  ${msg}  IPMI command fails
+    Should Contain  ${msg}  Unable to establish IPMI
 
 
 Verify IPMI Root User Password Change
@@ -311,20 +307,6 @@
     Verify IPMI Username And Password  root  ${OPENBMC_PASSWORD}
 
 
-Verify IPMI Username And Password
-    [Documentation]  Verify that user is able to run IPMI command
-    ...  with given username and password.
-    [Arguments]  ${username}  ${password}
-
-    ${ipmi_cmd}=  Catenate  SEPARATOR=
-    ...  ${IPMI_EXT_CMD}${SPACE}${USER_OPTION}${SPACE}${username}
-    ...  ${SPACE}${PASSWORD_OPTION}${SPACE}${password}
-    ...  ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${SEL_INFO_CMD}
-    ${rc}  ${output}=  Run and Return RC and Output  ${ipmi_cmd}
-    Should Be Equal  ${rc}  ${0}  msg=IPMI command fails
-    Should Contain  ${output}  SEL Information
-
-
 Delete All Non Root IPMI User
     [Documentation]  Delete all non-root IPMI user.
 
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index cfdb6fe..24ef24c 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -359,3 +359,17 @@
 
     Run Inband IPMI Standard Command
     ...  lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']}
+
+
+Verify IPMI Username And Password
+    [Documentation]  Verify that user is able to run IPMI command
+    ...  with given username and password.
+    [Arguments]  ${username}  ${password}
+
+    # Description of argument(s):
+    # username    The user name (e.g. "root", "robert", etc.).
+    # password    The user password (e.g. "0penBmc", "0penBmc1", etc.).
+
+    ${output}=  Run External IPMI Standard Command
+    ...  sel info  U=${username}  P=${password}
+    Should Contain  ${output}  SEL Information  msg=SEL information not present