XCAT- Add nodes to group and get list of nodes added in a group.
This change includes:
Adding BMC nodes to a group
Verify added BMC nodes
Get list of nodes added in a group.
This resolves openbmc/openbmc-test-automation#657
Change-Id: I9bd9668cfe8605728113d9f4f92cf5f7b64f4a68
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
diff --git a/lib/xcat/resource.txt b/lib/xcat/resource.txt
index 7636cf2..53f8860 100644
--- a/lib/xcat/resource.txt
+++ b/lib/xcat/resource.txt
@@ -7,6 +7,7 @@
${XCAT_PASSWORD} ${EMPTY}
${XCAT_PORT} 31578
${XCAT_DIR_PATH} /opt/xcat/bin/
+${GROUP} openbmc
# Default BMC nodes config file.
diff --git a/lib/xcat/xcat_utils.robot b/lib/xcat/xcat_utils.robot
index 9af70e4..19802a1 100644
--- a/lib/xcat/xcat_utils.robot
+++ b/lib/xcat/xcat_utils.robot
@@ -93,3 +93,47 @@
Should Be Empty ${stderr}
[Return] ${stdout}
+
+Add Nodes To Group
+ [Documentation] Add BMC nodes to group.
+ [Arguments] ${node} ${group}=${GROUP}
+
+ # Description of argument(s):
+ # node Name of the node (e.g. "node1").
+ # group Name of the group (e.g. "openbmc").
+
+ ${stdout} ${stderr}= Execute Command
+ ... ${XCAT_DIR_PATH}/chdef ${node} groups=${group} return_stderr=True
+ Should Be Empty ${stderr}
+
+Get List Of Nodes In Group
+ [Documentation] Get list of nodes in BMC.
+ [Arguments] ${group}=${GROUP}
+
+ # Description of argument(s):
+ # group Name of the group (e.g. "openbmc").
+
+ # Sample output of this keyword:
+ # XXX.XXX.XXX.XXX
+ # YYY.YYY.YYY.YYY
+ # ZZZ.ZZZ.ZZZ.ZZZ
+
+ ${stdout} ${stderr}= Execute Command
+ ... ${XCAT_DIR_PATH}/nodels ${group} return_stderr=True
+ Should Be Empty ${stderr}
+
+ [Return] ${stdout}
+
+Validate Node Added In Group
+ [Documentation] Validate whether node is added in group.
+ [Arguments] ${node} ${group}
+
+ # Description of argument(s):
+ # node Name of the node (e.g. "node1").
+ # group Name of the group (e.g. "openbmc").
+
+ ${nodes_in_group}= Get List Of Nodes In Group ${group}
+ Should Contain ${nodes_in_group} ${node}
+ ... msg=BMC node is not added in a group.
+
+# TBD openbmc/openbmc-test-automation/issues/647
diff --git a/xcat/xcat_testing.robot b/xcat/xcat_testing.robot
index 7a6fb1f..22c1898 100644
--- a/xcat/xcat_testing.robot
+++ b/xcat/xcat_testing.robot
@@ -43,6 +43,15 @@
\ Power Off Via XCAT ${bmc}
\ Validate Power Status Via XCAT ${bmc} ${poweroff_flag}
+Add Nodes To Group List
+ [Documentation] Add BMC nodes into group.
+ [Tags] Move_Added_Nodes_To_Group
+
+ # Add BMC nodes to group and validate.
+ : FOR ${bmc} IN @{BMC_LIST}
+ / Add Nodes To Group ${bmc} ${GROUP}
+ / Validate Node Added In Group ${bmc} ${GROUP}
+
*** Keywords ***
Validate XCAT Setup