cl_getgroupmap routine
The cl_getgroupmap routine returns information about the resource groups in a cluster. You should call the cl_alloc_groupmap before calling this routine to reserve the storage in memory. You should call cl_free_groupmap after calling this routine.
Syntax
int cl_getgroupmap (int clusterid, struct cl_group *groupmap)Parameters
| Item | Description |
|---|---|
| clusterid | The cluster ID of the desired cluster. |
| groupmap | Storage for the returned resource group information. |
Status codes
The request completed successfully if it returns a non-negative number (number of groups in the cluster).
| Item | Description |
|---|---|
| CLE_SYSERR | System error. Check the AIX® global variable errno for additional information. |
| CLE_BADARGS | Missing or invalid parameters. |
| CLE_IVCLUSTERID | The request specified an invalid cluster ID. |
Example
int i,j;
int clusterid = 1113325332;
int groups;
char cbuf[CL_ERRMSG_LEN];
struct cl_group *groupmap;
cl_alloc_groupmap(&groupmap);
if (groupmap==NULL){
printf("unable to allocate storage: cl_alloc_groupmap = NULL\n");
exit(-1);
}
groups = cl_getgroupmap(clusterid, groupmap);
if(groups < 0) {
cl_perror(groups, "can't get resource group map");
} else {
printf("cluster %d has %d resource groups\n", clusterid, groups);
for(i=0; i < groups; i++){
printf("resource group %d [%s] has %d nodes\n",
groupmap[i].clg_group_id,
groupmap[i].clg_name,
groupmap[i].clg_num_nodes);
printf("policies:\n");
printf("\tstartup %d \n",groupmap[i].clg_startup_policy);
printf("\tfallover %d \n",groupmap[i].clg_fallover_policy);
printf("\tfallback %d \n",groupmap[i].clg_fallback_policy);
printf("\tsite %d \n",groupmap[i].clg_site_policy);
printf("\tuser %d \n",groupmap[i].clg_user_policy_name);
printf("node states:\n");
for(j=0; j < groupmap[i].clg_num_nodes; j++){
printf("\tnode %d is in state %d \n",
groupmap[i].clg_node_ids[j],
groupmap[i].clg_node_states[j]);
}
printf("resources
for(j=0; j < groupmap[i].clg_num_resources; j++){
printf("\tresource %d is in state %d\n",
groupmap[i].clg_resource_id[j],
groupmap[i].clg_res_state[j]);
}
}
}