Beispiel #1
0
int deleteField(SaHpiSessionIdT sessionId,
		SaHpiResourceIdT resourceId,
		SaHpiIdrIdT IdrId, SaHpiEntryIdT AreaId)
{
	SaErrorT status;
	int retval;
	int response;
	SaHpiIdrFieldT Field;

	response = getField(sessionId, resourceId, IdrId, AreaId, &Field);
	if (response == SAF_TEST_FAIL) {
		e_trace();
		retval = SAF_TEST_UNRESOLVED;
	} else if (response == SAF_TEST_NOTSUPPORT) {
		retval = SAF_TEST_NOTSUPPORT;
	} else {

		status = saHpiIdrFieldDelete(sessionId,
					     resourceId,
					     IdrId, AreaId, Field.FieldId);

		if (status == SA_ERR_HPI_READ_ONLY) {
			retval = SAF_TEST_PASS;
		} else {
			retval = SAF_TEST_FAIL;
			e_print(saHpiIdrFieldDelete,
				SA_ERR_HPI_READ_ONLY, status);
		}
	}

	return retval;
}
Beispiel #2
0
static ret_code_t del_inventory_field(SaHpiSessionIdT sessionId,
	SaHpiResourceIdT rptid, SaHpiIdrIdT rdrnum)
{
	SaErrorT	rv;
	SaHpiEntryIdT	areaId, fieldId;
	int		res, i;

	i = get_int_param("Area Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Area Id\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	areaId = res;

	i = get_int_param("Field Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Field Id\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	fieldId = res;

	rv = saHpiIdrFieldDelete(sessionId, rptid, rdrnum, areaId, fieldId);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrFieldDelete: %s\n", oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	return(HPI_SHELL_OK);
}
Beispiel #3
0
int deleteField(SaHpiSessionIdT sessionId,
		SaHpiResourceIdT resourceId,
		SaHpiIdrIdT IdrId, SaHpiEntryIdT AreaId)
{
	SaErrorT status;
	int retval = SAF_TEST_UNKNOWN;
	SaHpiIdrFieldT Field;
	SaHpiEntryIdT NextFieldId;

	status = saHpiIdrFieldGet(sessionId, resourceId, IdrId, AreaId,
				  SAHPI_IDR_FIELDTYPE_UNSPECIFIED,
				  SAHPI_FIRST_ENTRY, &NextFieldId, &Field);

	if (status == SA_ERR_HPI_NOT_PRESENT) {
		retval = SAF_TEST_NOTSUPPORT;
	} else if (status != SA_OK) {
		retval = SAF_TEST_UNRESOLVED;
		e_print(saHpiIdrFieldGet, SA_OK, status);
	} else {

		//   Call the routine while passing in an invalid 
		//   ResourceId.

		status = saHpiIdrFieldDelete(sessionId,
					     INVALID_RESOURCE_ID,
					     IdrId, AreaId, Field.FieldId);

		if (status == SA_ERR_HPI_INVALID_RESOURCE) {
			retval = SAF_TEST_PASS;
		} else {
			retval = SAF_TEST_FAIL;
			e_print(saHpiIdrFieldDelete,
				SA_ERR_HPI_INVALID_RESOURCE, status);
		}
	}

	return retval;
}
Beispiel #4
0
int runTest(SaHpiSessionIdT sessionId,
	    SaHpiResourceIdT resourceId,
	    SaHpiIdrIdT IdrId, SaHpiEntryIdT AreaId)
{
	SaErrorT status;
	int retval;
	int response;
	SaHpiEntryIdT FieldId, NextFieldId;
	SaHpiIdrFieldT Field, MyField;

	response = addField(sessionId, resourceId, IdrId, AreaId, &MyField);
	if (response != SAF_TEST_PASS) {
		retval = response;
	} else {

		status = saHpiIdrFieldGet(sessionId,
					  resourceId,
					  IdrId,
					  AreaId,
					  SAHPI_IDR_FIELDTYPE_UNSPECIFIED,
					  MyField.FieldId,
					  &NextFieldId, &Field);

		if (status != SA_OK) {
			retval = SAF_TEST_FAIL;
			e_print(saHpiIdrFieldGet, SA_OK, status);
		} else {

			retval = SAF_TEST_UNKNOWN;

			// Retrieve the field by Field type.

			NextFieldId = SAHPI_FIRST_ENTRY;
			while ((NextFieldId != SAHPI_LAST_ENTRY) &&
			       (retval == SAF_TEST_UNKNOWN)) {

				FieldId = NextFieldId;
				status = saHpiIdrFieldGet(sessionId,
							  resourceId,
							  IdrId,
							  AreaId,
							  SAHPI_IDR_FIELDTYPE_CUSTOM,
							  FieldId,
							  &NextFieldId, &Field);

				if (status == SA_ERR_HPI_NOT_PRESENT) {
					// do nothing
				} else if (status != SA_OK) {
					retval = SAF_TEST_UNRESOLVED;
					e_print(saHpiIdrFieldGet,
						SA_ERR_HPI_NOT_PRESENT, status);
				} else if (Field.FieldId == MyField.FieldId) {
					retval = SAF_TEST_PASS;
				}
			}

			if (retval == SAF_TEST_UNKNOWN) {
				retval = SAF_TEST_FAIL;
				m_print
				    ("\"saHpiIdrFieldGet()\" did not return newly added field!");
			}

			status = saHpiIdrFieldDelete(sessionId, resourceId,
						     IdrId, AreaId,
						     Field.FieldId);
			if (status != SA_OK) {
				e_print(saHpiIdrFieldDelete, SA_OK, status);
			}
		}
	}

	return retval;
}
Beispiel #5
0
int TestField(SaHpiSessionIdT sessionId,
	      SaHpiResourceIdT resourceId,
	      SaHpiIdrIdT IdrId, SaHpiEntryIdT AreaId)
{
	SaErrorT status;
	int retval;
	SaHpiIdrFieldT Field;
	SaHpiEntryIdT NextFieldId;

	status = addCustomField(sessionId, resourceId, IdrId, AreaId, &Field);
	if (status == SA_ERR_HPI_INVALID_DATA) {
		retval = SAF_TEST_NOTSUPPORT;
	} else if (status == SA_ERR_HPI_OUT_OF_SPACE) {
		retval = SAF_TEST_NOTSUPPORT;
	} else if (status != SA_OK) {
		retval = SAF_TEST_UNRESOLVED;
		e_print(saHpiIdrFieldAdd, SA_OK, status);
	} else {

		// Set a new value in the field. 

		Field.Field.Data[0] = 's';
		status = saHpiIdrFieldSet(sessionId, resourceId, IdrId, &Field);

		if (status == SA_ERR_HPI_INVALID_DATA) {

			retval = SAF_TEST_NOTSUPPORT;

		} else if (status != SA_OK) {

			retval = SAF_TEST_FAIL;
			e_print(saHpiIdrFieldSet, SA_OK, status);

		} else {

			status = saHpiIdrFieldGet(sessionId,
						  resourceId,
						  IdrId, AreaId,
						  SAHPI_IDR_FIELDTYPE_CUSTOM,
						  Field.FieldId,
						  &NextFieldId, &Field);

			if (status != SA_OK) {
				retval = SAF_TEST_UNRESOLVED;
				e_print(saHpiIdrFieldGet, SA_OK, status);
			} else if (Field.Field.Data[0] == 's') {
				retval = SAF_TEST_PASS;
			} else {
				retval = SAF_TEST_FAIL;
			}
		}

		// Clean up
		status = saHpiIdrFieldDelete(sessionId, resourceId,
					     IdrId, AreaId, Field.FieldId);

		if (status != SA_OK) {
			e_print(saHpiIdrFieldDelete, SA_OK, status);
		}
	}

	return retval;
}
Beispiel #6
0
int main(int argc, char **argv)
{
	SaHpiSessionIdT sid = 0;
        SaHpiEntryIdT newid;
        SaHpiIdrFieldT field;
	SaErrorT rc = SA_OK;

        rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL);
	if (rc != SA_OK) {
		dbg("Failed to open session");
                return -1;
	}
	rc = saHpiDiscover(sid);
	if (rc != SA_OK) {
		dbg("Failed to run discover");
                return -1;
	}

        /* get the resource id of the chassis */
        SaHpiResourceIdT resid = get_resid(sid, SAHPI_ENT_SYSTEM_CHASSIS);
        if (resid == 0) {
		dbg("Couldn't find the resource id of the chassis");
                return -1;
	}

        rc = saHpiIdrAreaAdd(sid, resid, 1, SAHPI_IDR_AREATYPE_PRODUCT_INFO,
                             &newid);
        if (rc != SA_OK) {
		dbg("Couldn't add new area");
		dbg("Error %s",oh_lookup_error(rc));
                return -1;
	}

        field.AreaId = newid;
        field.Type = SAHPI_IDR_FIELDTYPE_PART_NUMBER;
        field.Field.DataType = SAHPI_TL_TYPE_TEXT;
        field.Field.Language = SAHPI_LANG_ENGLISH;
        field.Field.DataLength = 6;
        field.Field.Data[0] = '1';
        field.Field.Data[1] = '2';
        field.Field.Data[2] = '3';
        field.Field.Data[3] = '4';
        field.Field.Data[4] = '5';
        field.Field.Data[5] = '6';
        field.Field.Data[6] = '\0';
        rc = saHpiIdrFieldAdd(sid, resid, 1, &field);
        if (rc != SA_OK) {
		dbg("Couldn't add field");
		dbg("Error %s",oh_lookup_error(rc));
                return -1;
	}

        rc = saHpiIdrFieldDelete(sid, resid, 1, newid, field.FieldId);
        if (rc != SA_OK) {
		dbg("Couldn't delete field");
		dbg("Error %s",oh_lookup_error(rc));
                return -1;
	}

        field.AreaId = 1;
        field.FieldId = 1;
        rc = saHpiIdrFieldDelete(sid, resid, 1, 1, 1);
        if (rc == SA_OK) {
		dbg("Able to delete read only field");
                return -1;
	}

	return 0;
}