示例#1
0
static int
stmfAddToHostGroup001()
{
	int ret = 0;
	int stmfRet;
	uchar_t wwn[8];
	char *groupName = "HG";
	stmfDevid devid;
	stmfGroupProperties *groupProps;

	bzero(&devid, sizeof (devid));
	stmfRet = stmfCreateHostGroup((stmfGroupName *)groupName);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 1;
		goto cleanup;
	}

	wwn[0] = 0x01;
	wwn[1] = 0x23;
	wwn[2] = 0x45;
	wwn[3] = 0x67;
	wwn[4] = 0x89;
	wwn[5] = 0xab;
	wwn[6] = 0xcd;
	wwn[7] = 0xef;

	stmfRet = stmfDevidFromWwn(wwn, &devid);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 1;
		goto cleanup;
	}

	stmfRet = stmfAddToHostGroup((stmfGroupName *)groupName, &devid);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 1;
		goto cleanup;
	}

	stmfRet = stmfGetHostGroupMembers((stmfGroupName *)groupName,
	    &groupProps);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 1;
		goto cleanup;
	}

	if (bcmp(&devid, &(groupProps->name[0]), sizeof (devid)) != 0) {
		ret = 1;
		goto cleanup;
	}

cleanup:
	(void) stmfDeleteHostGroup((stmfGroupName *)groupName);
	return (ret);
}
示例#2
0
static int
stmfGetHostGroupMembers001()
{
	int ret = 0;
	int i;
	int stmfRet;
	uchar_t wwn[8];
	char *groupName = "h01";
	int found = 0;
	stmfDevid devid1, devid2;
	stmfGroupProperties *groupProps;

	bzero(&devid1, sizeof (devid1));
	bzero(&devid2, sizeof (devid2));
	stmfRet = stmfCreateHostGroup((stmfGroupName *)groupName);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 1;
		goto cleanup;
	}

	wwn[0] = 0x01;
	wwn[1] = 0x23;
	wwn[2] = 0x45;
	wwn[3] = 0x67;
	wwn[4] = 0x89;
	wwn[5] = 0xab;
	wwn[6] = 0xcd;
	wwn[7] = 0xef;

	stmfRet = stmfDevidFromWwn(wwn, &devid1);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 2;
		goto cleanup;
	}

	stmfRet = stmfAddToHostGroup((stmfGroupName *)groupName, &devid1);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 3;
		goto cleanup;
	}

	wwn[0] = 0xab;
	wwn[1] = 0xcd;
	wwn[2] = 0xef;
	wwn[3] = 0x01;
	wwn[4] = 0x23;
	wwn[5] = 0x45;
	wwn[6] = 0x67;
	wwn[7] = 0x89;

	stmfRet = stmfDevidFromWwn(wwn, &devid2);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 4;
		goto cleanup;
	}

	stmfRet = stmfAddToHostGroup((stmfGroupName *)groupName, &devid2);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 5;
		goto cleanup;
	}
	stmfRet = stmfGetHostGroupMembers((stmfGroupName *)groupName,
	    &groupProps);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 6;
		goto cleanup;
	}

	for (i = 0; i < groupProps->cnt; i++) {
		if ((bcmp(&devid1, &(groupProps->name[i]),
		    sizeof (devid1)) == 0) ||
		    (bcmp(&devid2, &(groupProps->name[i]),
		    sizeof (devid2)) == 0)) {
			found++;
		}
	}

	if (found != 2) {
		ret = 7;
		goto cleanup;
	}

cleanup:
	(void) stmfDeleteHostGroup((stmfGroupName *)groupName);
	return (ret);
}