Add case to test get user access command via IPMI

Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: I0caf17c65268995c3d1fe47ce88a2102b9aa30b3
diff --git a/ipmi/test_ipmi_user.robot b/ipmi/test_ipmi_user.robot
index 6420166..b20abea 100644
--- a/ipmi/test_ipmi_user.robot
+++ b/ipmi/test_ipmi_user.robot
@@ -51,6 +51,36 @@
     Should Contain  ${maximum_ids}  15
 
 
+Verify IPMI User List
+    [Documentation]  Verify user list via IPMI.
+    [Tags]  Verify_IPMI_User_List
+    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
+    ...  Delete Created User  ${random_userid}
+
+    ${random_userid}  ${random_username}=  Create Random IPMI User
+    Set Test Variable  ${random_userid}
+
+    Run IPMI Standard Command
+    ...  user set password ${random_userid} ${valid_password}
+    Run IPMI Standard Command  user enable ${random_userid}
+    # Delay added for IPMI user to get enabled.
+    Sleep  5s
+    # Set admin privilege and enable IPMI messaging for newly created user.
+    Set Channel Access  ${random_userid}  ipmi=on privilege=${admin_level_priv}
+
+    ${users_access}=  Get User Access Ipmi  ${CHANNEL_NUMBER}
+    Rprint Vars  users_access
+
+    ${index}=  Evaluate  ${random_userid} - 1
+    # Verify the user access of created user.
+    Valid Value  users_access[${index}]['id']  ['${random_userid}']
+    Valid Value  users_access[${index}]['name']  ['${random_username}']
+    Valid Value  users_access[${index}]['callin']  ['true']
+    Valid Value  users_access[${index}]['link']  ['false']
+    Valid Value  users_access[${index}]['auth']  ['true']
+    Valid Value  users_access[${index}]['ipmi']  ['ADMINISTRATOR']
+
+
 Verify IPMI User Creation With Valid Name And ID
     [Documentation]  Create user via IPMI and verify.
     [Tags]  Test_IPMI_User_Creation_With_Valid_Name_And_ID
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index 2a72fde..156b32a 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -657,3 +657,35 @@
     key_var_list[11] = 'Non-Volatile Settings:'
     result = vf.key_value_list_to_dict(key_var_list, process_indent=1)
     return result
+
+
+def get_user_access_ipmi(channel_number=1):
+
+    r"""
+    Run 'user list [<channel number>]' command and return the result as a list of dictionaries.
+
+    Example robot code:
+    ${users_access}=  user list 1
+    Rprint Vars  users_access
+
+    Example output:
+    users:
+      [0]:
+        [id]:                                         1
+        [name]:                                       root
+        [callin]:                                     false
+        [link]:                                       true
+        [auth]:                                       true
+        [ipmi]:                                       ADMINISTRATOR
+      [1]:
+        [id]:                                         2
+        [name]:                                       axzIDwnz
+        [callin]:                                     true
+        [link]:                                       false
+        [auth]:                                       true
+        [ipmi]:                                       ADMINISTRATOR
+    """
+
+    cmd_buf = "user list " + str(channel_number)
+    stdout, stderr, rc = execute_ipmi_cmd(cmd_buf, "external", print_output=0)
+    return vf.outbuf_to_report(stdout)