Example #1
0
static void get_entity_event(ipmi_entity_t	*entity,
			     SaHpiRptEntryT	*entry, void *cb_data)
{
	SaHpiEntityPathT entity_ep;

	struct ohoi_handler *ipmi_handler = cb_data;

	entry->ResourceInfo.ResourceRev = 0;
	entry->ResourceInfo.SpecificVer = 0;
	entry->ResourceInfo.DeviceSupport = 0;
	entry->ResourceInfo.ManufacturerId = 0;
	entry->ResourceInfo.ProductId = 0;
	entry->ResourceInfo.FirmwareMajorRev = 0;
	entry->ResourceInfo.FirmwareMinorRev = 0;
	
	entry->ResourceInfo.AuxFirmwareRev = 0;
	entry->ResourceEntity.Entry[0].EntityType 
                = ipmi_entity_get_entity_id(entity);
	entry->ResourceEntity.Entry[0].EntityLocation 
                = ipmi_entity_get_entity_instance(entity);
	entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT;
	entry->ResourceEntity.Entry[1].EntityLocation = 0;
	
	/* let's append entity_root from config */

	string2entitypath(ipmi_handler->entity_root, &entity_ep);

	ep_concat(&entry->ResourceEntity, &entity_ep);

	entry->EntryId = 0;
	entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);

	entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE;
	
	if (ipmi_entity_hot_swappable(entity)) {
			entry->ResourceCapabilities |= SAHPI_CAPABILITY_MANAGED_HOTSWAP
					| SAHPI_CAPABILITY_FRU;
	}

	if(ipmi_entity_get_is_fru(entity)) {
			entry->ResourceCapabilities |= SAHPI_CAPABILITY_FRU | SAHPI_CAPABILITY_INVENTORY_DATA;
	}
				
	entry->ResourceSeverity = SAHPI_OK;
#if 0
	entry->DomainId = 0;
#endif
	entry->ResourceTag.DataType = SAHPI_TL_TYPE_ASCII6;
	
	entry->ResourceTag.Language = SAHPI_LANG_ENGLISH;
	entry->ResourceTag.DataLength = (SaHpiUint32T) ipmi_entity_get_id_length(entity); 

	ipmi_entity_get_id(entity, entry->ResourceTag.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH);
	if ((strlen(entry->ResourceTag.Data) == 0) || (!strcmp(entry->ResourceTag.Data, "invalid"))) {
			char *str;
			str = ipmi_entity_get_entity_id_string(entity);
			memcpy(entry->ResourceTag.Data, str, strlen(str) + 1);
	}
}
Example #2
0
static void get_mc_entity_event(ipmi_mc_t	*mc,
			        SaHpiRptEntryT	*entry)
{
	uint8_t	vals[4];
	SaHpiEntityPathT mc_ep;
	char mc_name[128];
	int sel_support;
        
	memset(&mc_ep, 0, sizeof(SaHpiEntityPathT));
	dbg("entity_root: %s", entity_root);
	string2entitypath(entity_root, &mc_ep);
	append_root(&mc_ep);

        snprintf(mc_name, sizeof(mc_name),
                 "Management Controller(%x, %x)",
                 ipmi_mc_get_channel(mc), 
                 ipmi_mc_get_address(mc));
        
	entry->EntryId = 0;
	entry->ResourceInfo.ResourceRev = 0;
	entry->ResourceInfo.SpecificVer = 0;
	entry->ResourceInfo.DeviceSupport = 0;
	entry->ResourceInfo.ManufacturerId =
		(SaHpiManufacturerIdT)ipmi_mc_manufacturer_id(mc);
	entry->ResourceInfo.ProductId = (SaHpiUint16T)ipmi_mc_product_id(mc);
	entry->ResourceInfo.FirmwareMajorRev =
		(SaHpiUint8T)ipmi_mc_major_fw_revision(mc);
	entry->ResourceInfo.FirmwareMinorRev =
		(SaHpiUint8T)ipmi_mc_minor_fw_revision(mc);
	
	ipmi_mc_aux_fw_revision(mc, vals);
	/* There are 4, and we only use first. */
	entry->ResourceInfo.AuxFirmwareRev = (SaHpiUint8T)vals[0];
	entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SYS_MGMNT_MODULE ;
	/*we get MC number on IPMB for unique identifier */
	entry->ResourceEntity.Entry[0].EntityInstance = ipmi_mc_get_address(mc);
	dbg ("MC Instance: %d", entry->ResourceEntity.Entry[0].EntityInstance);
	sel_support = ipmi_mc_sel_device_support(mc);
	if (sel_support == 1) {
		dbg("MC supports SEL");
		entry->ResourceCapabilities = SAHPI_CAPABILITY_SEL;
	}
	else {
		entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE;
		dbg("MC does not support SEL");
	}
	entry->ResourceSeverity = SAHPI_OK;
	entry->DomainId = 0;
	entry->ResourceTag.DataType = SAHPI_TL_TYPE_ASCII6;
	entry->ResourceTag.Language = SAHPI_LANG_ENGLISH;
	entry->ResourceTag.DataLength = strlen(mc_name); 
	memcpy(entry->ResourceTag.Data, mc_name, strlen(mc_name)+1);

	ep_concat(&entry->ResourceEntity, &mc_ep);
        
	entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);
	dbg("MC ResourceId: %d", (int)entry->ResourceId);
}
Example #3
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{BIOS,71}{DRIVE_BACKPLANE,49}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_DRIVE_BACKPLANE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 49)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_BIOS)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 71)
                return 1;
        
        return 0;
}
Example #4
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{POWER_DISTRIBUTION_UNIT,73}{BACK_PANEL_BOARD,70}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_BACK_PANEL_BOARD) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 70)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_POWER_DISTRIBUTION_UNIT)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 73)
                return 1;
        
        return 0;
}
Example #5
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{OEM_SYSINT_SPECIFIC,6}{BOARD_SET_SPECIFIC,30}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_BOARD_SET_SPECIFIC)
                return 1;
        
        if(tmp_ep.Entry[0].EntityLocation != 30)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_OEM_SYSINT_SPECIFIC)
                return 1;
        
        if(tmp_ep.Entry[1].EntityLocation != 6)
                return 1;
        
        return 0;
}
Example #6
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{IO_SUBBOARD,90}{SYSTEM_SLOT,2}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_SYSTEM_SLOT) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 2)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_IO_SUBBOARD)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 90)
                return 1;
        
        return 0;
}
Example #7
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{PERIPHERAL_BAY_2,20}{MEMORY_MODULE,36}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_MEMORY_MODULE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 36)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_PERIPHERAL_BAY_2)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 20)
                return 1;
        
        return 0;
}
Example #8
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{IO_BLADE,29}{PROCESSOR,23}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_PROCESSOR) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 23)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_IO_BLADE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 29)
                return 1;
        
        return 0;
}
Example #9
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SYS_MGMNT_SOFTWARE,26}{OTHER_SYSTEM_BOARD,66}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_OTHER_SYSTEM_BOARD) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 66)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SYS_MGMNT_SOFTWARE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 26)
                return 1;
        
        return 0;
}
Example #10
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SBC_SUBBOARD,2}{POWER_MGMNT,66}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_POWER_MGMNT) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 66)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SBC_SUBBOARD)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 2)
                return 1;
        
        return 0;
}
Example #11
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SUB_CHASSIS,65}{SUBBOARD_CARRIER_BLADE,78}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_SUBBOARD_CARRIER_BLADE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 78)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SUB_CHASSIS)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 65)
                return 1;
        
        return 0;
}
Example #12
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{MEMORY_DEVICE,70}{INTERCONNECT,18}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_INTERCONNECT) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 18)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_MEMORY_DEVICE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 70)
                return 1;
        
        return 0;
}
Example #13
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{EXTERNAL_ENVIRONMENT,81}{DISK_DRIVE_BAY,45}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_DISK_DRIVE_BAY) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 45)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_EXTERNAL_ENVIRONMENT)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 81)
                return 1;
        
        return 0;
}
Example #14
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{IO_SUBBOARD,54}{PERIPHERAL_BAY,49}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_PERIPHERAL_BAY) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 49)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_IO_SUBBOARD)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 54)
                return 1;
        
        return 0;
}
Example #15
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SUBRACK,94}{PERIPHERAL_BAY,34}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_PERIPHERAL_BAY) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 34)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SUBRACK)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 94)
                return 1;
        
        return 0;
}
Example #16
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SUB_CHASSIS,19}{ALARM_MANAGER,82}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_ALARM_MANAGER) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 82)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SUB_CHASSIS)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 19)
                return 1;
        
        return 0;
}
Example #17
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{CHASSIS_SPECIFIC,97}{BOARD_SET_SPECIFIC,-5}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_BOARD_SET_SPECIFIC)
                return 1;
        
        if(tmp_ep.Entry[0].EntityLocation != -5)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_CHASSIS_SPECIFIC)
                return 1;
        
        if(tmp_ep.Entry[1].EntityLocation != 97)
                return 1;
        
        return 0;
}
Example #18
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{POWER_DISTRIBUTION_UNIT,59}{SYS_MGMNT_SOFTWARE,97}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_SYS_MGMNT_SOFTWARE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 97)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_POWER_DISTRIBUTION_UNIT)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 59)
                return 1;
        
        return 0;
}
Example #19
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{POWER_UNIT,63}{PROCESSOR_BOARD,28}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_PROCESSOR_BOARD) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 28)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_POWER_UNIT)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 63)
                return 1;
        
        return 0;
}
Example #20
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{IO_BLADE,26}{POWER_MODULE,56}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_POWER_MODULE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 56)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_IO_BLADE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 26)
                return 1;
        
        return 0;
}
Example #21
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SYSTEM_BUS,86}{SPEC_PROC_BLADE,45}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_SPEC_PROC_BLADE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 45)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SYSTEM_BUS)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 86)
                return 1;
        
        return 0;
}
Example #22
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SYS_MGMNT_SOFTWARE,39}{RACK,66}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_RACK) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 66)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SYS_MGMNT_SOFTWARE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 39)
                return 1;
        
        return 0;
}
Example #23
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{SYS_MGMNT_MODULE,95}{MEMORY_DEVICE,85}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_MEMORY_DEVICE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 85)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_SYS_MGMNT_MODULE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 95)
                return 1;
        
        return 0;
}
Example #24
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{ALARM_MANAGER_BLADE,88}{SUB_CHASSIS,25}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_SUB_CHASSIS) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 25)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_ALARM_MANAGER_BLADE)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 88)
                return 1;
        
        return 0;
}
Example #25
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{DISK_BAY,57}{DISK_DRIVE,48}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_DISK_DRIVE) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 48)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_DISK_BAY)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 57)
                return 1;
        
        return 0;
}
Example #26
0
/**
 * main: epathstr -> epath test
 * 
 * This test tests whether an entity path string is converted into
 * an entity path properly.  
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 * 
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv) 
{
        SaHpiEntityPathT tmp_ep;
        char *entity_root = "{OTHER_CHASSIS_BOARD,60}{COMPACTPCI_CHASSIS,95}";
        
        string2entitypath(entity_root, &tmp_ep);
        
        if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_COMPACTPCI_CHASSIS) 
                return 1;
        
        if(tmp_ep.Entry[0].EntityInstance != 95)
                return 1;
        
        if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_OTHER_CHASSIS_BOARD)
                return 1;
        
        if(tmp_ep.Entry[1].EntityInstance != 60)
                return 1;
        
        return 0;
}
Example #27
0
/**
 * main: epathstr -> epath test
 *
 * This test tests whether an entity path string is converted into
 * an entity path properly.
 *
 * TODO: a more extensive set of tests would be nice, might need to create a
 * perl program to generate that code
 *
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv)
{
    SaHpiEntityPathT tmp_ep;
    char *entity_root = "{OTHER_SYSTEM_BOARD,92}{SYS_EXPANSION_BOARD,57}";

    string2entitypath(entity_root, &tmp_ep);

    if(tmp_ep.Entry[0].EntityType != SAHPI_ENT_SYS_EXPANSION_BOARD)
        return 1;

    if(tmp_ep.Entry[0].EntityInstance != 57)
        return 1;

    if(tmp_ep.Entry[1].EntityType != SAHPI_ENT_OTHER_SYSTEM_BOARD)
        return 1;

    if(tmp_ep.Entry[1].EntityInstance != 92)
        return 1;

    return 0;
}
Example #28
0
int main (int argc, char **argv) {
	SaHpiEntityPathT  ep;
	gchar *test_string, *expected_string;
	const int MAX_STRING_SIZE = 512;
	gchar returned_string[MAX_STRING_SIZE];
	int   err;

        test_string = "{217,11}";
        expected_string = "{217,11}";

	err = string2entitypath(test_string, &ep);
	if (err)
		return 1;

        err = entitypath2string(&ep, returned_string, MAX_STRING_SIZE);
        if (err < 0)
                return 1;

        if (strcmp(returned_string, expected_string))
                return 1;

        return 0;
}
Example #29
0
int main (int argc, char **argv) {
	SaHpiEntityPathT  ep;
	gchar *test_string, *expected_string;
	const int MAX_STRING_SIZE = 512;
	gchar returned_string[MAX_STRING_SIZE];
	int   err;

        // check if we can convert the last entry of the list
        test_string = "{SUBBOARD_CARRIER_BLADE,12}";
        expected_string = "{SUBBOARD_CARRIER_BLADE,12}";

	err = string2entitypath(test_string, &ep);
	if (err)
		return 1;
        
        err = entitypath2string(&ep, returned_string, MAX_STRING_SIZE);
        if (err < 0)
                return 1;

        if (strcmp(returned_string, expected_string))
                return 1;

        return 0;
}
Example #30
0
static int snmp_rsa_discover_resources(void *hnd)
{
        SaHpiEntityPathT entity_root;        
        guint i;
        struct oh_event *e;
	struct snmp_value get_value;
//	struct snmp_value get_active;
        struct oh_handler_state *handle = (struct oh_handler_state *)hnd;
        struct snmp_rsa_hnd *custom_handle = (struct snmp_rsa_hnd *)handle->data;
        RPTable *tmpcache = (RPTable *)g_malloc0(sizeof(RPTable));
        GSList *tmpqueue = NULL;
        char *root_tuple = (char *)g_hash_table_lookup(handle->config,"entity_root");        
                
        string2entitypath(root_tuple, &entity_root);

        /* see if the chassis exists by querying system health */
        if(snmp_get(custom_handle->ss,".1.3.6.1.4.1.2.3.51.1.2.7.1.0",&get_value) != 0) {
                /* If we get here, something is hosed. No need to do more discovery */
                dbg("Couldn't fetch SNMP RSA system health.\n");
                dbg("There is no chassis.");
                g_free(tmpcache);
                return -1;
        }

        /* discover the chassis */
        e = snmp_rsa_discover_chassis(handle, &entity_root);
        if(e != NULL) {
                struct ResourceMibInfo *res_mib =
                        g_memdup(&(snmp_rsa_rpt_array[RSA_RPT_ENTRY_CHASSIS].rsa_res_info.mib),
                                 sizeof(struct snmp_rpt));
                oh_add_resource(tmpcache,&(e->u.res_event.entry),res_mib,0);
                tmpqueue = g_slist_append(tmpqueue, e);
                SaHpiResourceIdT rid = e->u.res_event.entry.ResourceId;
                SaHpiEntityPathT parent_ep = e->u.res_event.entry.ResourceEntity;
		find_sensors(snmp_rsa_chassis_sensors);                        
		find_controls(snmp_rsa_chassis_controls);
		find_inventories(snmp_rsa_chassis_inventories);
        }

        /* discover all cpus */
        for (i = 0; i < RSA_MAX_CPU; i++) {
                /* see if the cpu exists by querying the thermal sensor */
                if((snmp_get(custom_handle->ss,
                             snmp_rsa_cpu_thermal_sensors[i].rsa_sensor_info.mib.oid,
                             &get_value) != 0) ||
                   (get_value.type != ASN_OCTET_STR) ||
                   (strcmp(get_value.string, "Not Readable!") == 0)) {
                        /* If we get here the CPU is not installed */
                        dbg("CPU %d not found.\n", i+RSA_HPI_INSTANCE_BASE);
                        continue;
                }

                e = snmp_rsa_discover_cpu(handle, &entity_root, i);
                if(e != NULL) {
                        struct ResourceMibInfo *res_mib =
                                g_memdup(&(snmp_rsa_rpt_array[RSA_RPT_ENTRY_CPU].rsa_res_info.mib),
                                         sizeof(struct snmp_rpt));
                        oh_add_resource(tmpcache,&(e->u.res_event.entry),res_mib,0);
                        tmpqueue = g_slist_append(tmpqueue, e);
                        SaHpiResourceIdT rid = e->u.res_event.entry.ResourceId;
                        SaHpiEntityPathT parent_ep = e->u.res_event.entry.ResourceEntity;
                        /* add the CPU thermal sensor */
                        e = snmp_rsa_discover_sensors(handle,
                                                      parent_ep,
                                                      &snmp_rsa_cpu_thermal_sensors[i]);
                        if(e != NULL) {
                                struct RSA_SensorInfo *rsa_data = g_memdup(&(snmp_rsa_cpu_thermal_sensors[i].rsa_sensor_info),
                                                                           sizeof(struct RSA_SensorInfo));
                                oh_add_rdr(tmpcache,rid,&(e->u.rdr_event.rdr), rsa_data, 0);
                                tmpqueue = g_slist_append(tmpqueue, e);
                        }
                }
        }

        /* discover all dasd */
        for (i = 0; i < RSA_MAX_DASD; i++) {
                /* see if the dasd exists by querying the thermal sensor */
                if((snmp_get(custom_handle->ss,
                             snmp_rsa_dasd_thermal_sensors[i].rsa_sensor_info.mib.oid,
                             &get_value) != 0) ||
                   (get_value.type != ASN_OCTET_STR) ||
                   (strcmp(get_value.string, "Not Readable!") == 0)) {
                        /* If we get here the DASD is not installed */
                        dbg("DASD %d not found.\n", i+RSA_HPI_INSTANCE_BASE);
                        continue;
                }

                e = snmp_rsa_discover_dasd(handle, &entity_root, i);
                if(e != NULL) {
                        struct ResourceMibInfo *res_mib =
                                g_memdup(&(snmp_rsa_rpt_array[RSA_RPT_ENTRY_DASD].rsa_res_info.mib),
                                         sizeof(struct snmp_rpt));
                        oh_add_resource(tmpcache,&(e->u.res_event.entry),res_mib,0);
                        tmpqueue = g_slist_append(tmpqueue, e);
                        SaHpiResourceIdT rid = e->u.res_event.entry.ResourceId;
                        SaHpiEntityPathT parent_ep = e->u.res_event.entry.ResourceEntity;
                        /* add the DASD thermal sensor */
                        e = snmp_rsa_discover_sensors(handle,
                                                      parent_ep,
                                                      &snmp_rsa_dasd_thermal_sensors[i]);
                        if(e != NULL) {
                                struct RSA_SensorInfo *rsa_data = g_memdup(&(snmp_rsa_dasd_thermal_sensors[i].rsa_sensor_info),
                                                                           sizeof(struct RSA_SensorInfo));
                                oh_add_rdr(tmpcache,rid,&(e->u.rdr_event.rdr), rsa_data, 0);
                                tmpqueue = g_slist_append(tmpqueue, e);
                        }
                }
        }

        /* discover all fans */
        for (i = 0; i < RSA_MAX_FAN; i++) {
                /* see if the fan exists by querying the  sensor */
                if((snmp_get(custom_handle->ss,
                             snmp_rsa_fan_sensors[i].rsa_sensor_info.mib.oid,
                             &get_value) != 0) ||
                   (get_value.type != ASN_OCTET_STR) ||
                   (strcmp(get_value.string, "Not Readable!") == 0)) {
                        /* If we get here the fan is not installed */
                        dbg("Fan %d not found.\n", i+RSA_HPI_INSTANCE_BASE);
                        continue;
                }

                e = snmp_rsa_discover_fan(handle, &entity_root, i);
                if(e != NULL) {
                        struct ResourceMibInfo *res_mib =
                                g_memdup(&(snmp_rsa_rpt_array[RSA_RPT_ENTRY_FAN].rsa_res_info.mib),
                                         sizeof(struct snmp_rpt));
                        oh_add_resource(tmpcache,&(e->u.res_event.entry),res_mib,0);
                        tmpqueue = g_slist_append(tmpqueue, e);
                        SaHpiResourceIdT rid = e->u.res_event.entry.ResourceId;
                        SaHpiEntityPathT parent_ep = e->u.res_event.entry.ResourceEntity;
                        /* add the fan sensor */
                        e = snmp_rsa_discover_sensors(handle,
                                                      parent_ep,
                                                      &snmp_rsa_fan_sensors[i]);
                        if(e != NULL) {
                                struct RSA_SensorInfo *rsa_data = g_memdup(&(snmp_rsa_fan_sensors[i].rsa_sensor_info),
                                                                           sizeof(struct RSA_SensorInfo));
                                oh_add_rdr(tmpcache,rid,&(e->u.rdr_event.rdr), rsa_data, 0);
                                tmpqueue = g_slist_append(tmpqueue, e);
                        }
                }
        }

        /*
        Rediscovery: Get difference between current rptcache and tmpcache. Delete
        obsolete items from rptcache and add new items in.        
        */
        GSList *res_new = NULL, *rdr_new = NULL, *res_gone = NULL, *rdr_gone = NULL;
        GSList *node = NULL;
        
       	rpt_diff(handle->rptcache, tmpcache, &res_new, &rdr_new, &res_gone, &rdr_gone);
	dbg("%d resources have gone away.", g_slist_length(res_gone));
	dbg("%d resources are new or have changed", g_slist_length(res_new));

        for (node = rdr_gone; node != NULL; node = node->next) {
                SaHpiRdrT *rdr = (SaHpiRdrT *)node->data;
                SaHpiRptEntryT *res = oh_get_resource_by_ep(handle->rptcache, &(rdr->Entity));
                /* Create remove rdr event and add to event queue */
                struct oh_event *e = (struct oh_event *)g_malloc0(sizeof(struct oh_event));
                if (e) {
                        e->type = OH_ET_RDR_DEL;
                        e->u.rdr_del_event.record_id = rdr->RecordId;
                        e->u.rdr_del_event.parent_entity = rdr->Entity;
                        handle->eventq = g_slist_append(handle->eventq, e);
                } else dbg("Could not allocate more memory to create event.");
                /* Remove rdr from plugin's rpt cache */
                if (rdr && res)
                        oh_remove_rdr(handle->rptcache, res->ResourceId, rdr->RecordId);
                else dbg("No valid resource or rdr at hand. Could not remove rdr.");
                
        }
        g_slist_free(rdr_gone);

        for (node = res_gone; node != NULL; node = node->next) {
                SaHpiRptEntryT *res = (SaHpiRptEntryT *)node->data;
		/* Create remove resource event and add to event queue */
		struct oh_event *e = (struct oh_event *)g_malloc0(sizeof(struct oh_event));
                if (e) {
                        e->type = OH_ET_RESOURCE_DEL;
                        e->u.res_del_event.resource_id = res->ResourceId;
                        handle->eventq = g_slist_append(handle->eventq, e);
                } else dbg("Could not allocate more memory to create event.");
		/* Remove resource from plugin's rpt cache */
                if (res)
                        oh_remove_resource(handle->rptcache, res->ResourceId);
                else dbg("No valid resource at hand. Could not remove resource.");
        }
        g_slist_free(res_gone);

        for (node = res_new; node != NULL; node = node->next) {
                GSList *tmpnode = NULL;
                SaHpiRptEntryT *res = (SaHpiRptEntryT *)node->data;
                if (!res) {
                        dbg("No valid resource at hand. Could not process new resource.");
                        continue;
                }
                gpointer data = oh_get_resource_data(tmpcache, res->ResourceId);
                oh_add_resource(handle->rptcache, res, g_memdup(data, sizeof(struct snmp_rpt)),0);
                /* Add new/changed resources to the event queue */
                for (tmpnode = tmpqueue; tmpnode != NULL; tmpnode = tmpnode->next) {
                        struct oh_event *e = (struct oh_event *)tmpnode->data;
                        if (e->type == OH_ET_RESOURCE &&
                            e->u.res_event.entry.ResourceId == res->ResourceId) {
                                handle->eventq = g_slist_append(handle->eventq, e);
                                tmpqueue = g_slist_remove_link(tmpqueue, tmpnode);
				g_slist_free_1(tmpnode);
                                break;
                        }
                }
        }
        g_slist_free(res_new);
        
        for (node = rdr_new; node != NULL; node = node->next) {
                guint rdr_data_size = 0;
                GSList *tmpnode = NULL;
                SaHpiRdrT *rdr = (SaHpiRdrT *)node->data;
                SaHpiRptEntryT *res = oh_get_resource_by_ep(handle->rptcache, &(rdr->Entity));
                if (!res || !rdr) {
                        dbg("No valid resource or rdr at hand. Could not process new rdr.");
                        continue;
                }
                gpointer data = oh_get_rdr_data(tmpcache, res->ResourceId, rdr->RecordId);
                /* Need to figure out the size of the data associated with the rdr */
                if (rdr->RdrType == SAHPI_SENSOR_RDR) rdr_data_size = sizeof(struct RSA_SensorMibInfo);
                else if (rdr->RdrType == SAHPI_CTRL_RDR)
                        rdr_data_size = sizeof(struct RSA_ControlMibInfo);
                else if (rdr->RdrType == SAHPI_INVENTORY_RDR)
                        rdr_data_size = sizeof(struct RSA_InventoryMibInfo);
                oh_add_rdr(handle->rptcache, res->ResourceId, rdr, g_memdup(data, rdr_data_size),0);
                /* Add new/changed rdrs to the event queue */
                for (tmpnode = tmpqueue; tmpnode != NULL; tmpnode = tmpnode->next) {
                        struct oh_event *e = (struct oh_event *)tmpnode->data;
                        if (e->type == OH_ET_RDR &&                            
                            ep_cmp(&(e->u.rdr_event.rdr.Entity),&(rdr->Entity)) == 0 &&
                            e->u.rdr_event.rdr.RecordId == rdr->RecordId) {
                                handle->eventq = g_slist_append(handle->eventq, e);
                                tmpqueue =  g_slist_remove_link(tmpqueue, tmpnode);
				g_slist_free_1(tmpnode);
                                break;
                        }
                }
        }        
        g_slist_free(rdr_new);
        
        /* Clean up tmpqueue and tmpcache */
        g_slist_free(tmpqueue);
        oh_flush_rpt(tmpcache);
        g_free(tmpcache);
        
        return SA_OK;        
}