int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int val   = 0;
    int ret   = ONLP_STATUS_OK;
    int index = ONLP_OID_ID_GET(id);
    const char psu_model[]=PSU_MODEL;

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_psu_info_t));
    *info = pinfo[index]; /* Set the onlp_oid_hdr_t */

    /* Fixed system, PSU is always present */
	info->status |= ONLP_PSU_STATUS_PRESENT;

	strncpy(info->model, psu_model, sizeof(info->model));

    /* Get the cable preset state */
    if (psu_module_info_get(index, "pwr_status", &val) != 0) {
        AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index);
    }

    if (val != PSU_CABLE_PRESENT) {
        info->status |= ONLP_PSU_STATUS_UNPLUGGED;
        return ONLP_STATUS_OK;
    }

    info->status |= ONLP_PSU_STATUS_PRESENT;

    ret = _psu_info_get(info);

    return ret;
}
int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int val   = 0;
    int ret   = ONLP_STATUS_OK;
    int index = ONLP_OID_ID_GET(id);

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_psu_info_t));
    *info = pinfo[index]; /* Set the onlp_oid_hdr_t */

    /* Get the present state */
    if (psu_module_info_get(index, "status", &val) != 0) {
    	AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index);
    }

    if (val != PSU_STATUS_PRESENT) {
        info->status &= ~ONLP_PSU_STATUS_PRESENT;
        info->status |= ONLP_PSU_STATUS_UNPLUGGED;
        return ONLP_STATUS_OK;
    }

    /* Get the cable preset state */
    if (psu_module_info_get(index, "pwr_status", &val) != 0) {
    	AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index);
    }

    if (val != PSU_CABLE_PRESENT) {
        info->status |= ONLP_PSU_STATUS_UNPLUGGED;
        return ONLP_STATUS_OK;
    }

    info->status |= ONLP_PSU_STATUS_PRESENT;

    ret = _psu_info_get(info);

    return ret;
}
示例#3
0
int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int val   = 0;
    int ret   = ONLP_STATUS_OK;
    int index = ONLP_OID_ID_GET(id);

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_psu_info_t));
    *info = pinfo[index]; /* Set the onlp_oid_hdr_t */

    /* Get the present state */
    if ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) {
	printf("Unable to read PSU(%d) node(psu)\r\n", index);
	return ret;
    }

    if (val == 0) {
	info->status = ONLP_PSU_STATUS_PRESENT;
    }
    else
    if (val == 1) {
	info->status = ONLP_PSU_STATUS_UNPLUGGED;
	return ret;
    }
    else {
	info->status = ONLP_PSU_STATUS_FAILED;
	return ret;
    }

    if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) {
	printf("Unable to read PSU(%d) module information\r\n", index);
    }

    return ret;
}