int open_session() { SaErrorT rv; SaHpiVersionT hpiVer; rv = saHpiInitialize(&hpiVer); if (rv != SA_OK) { printf("saHpiInitialize error %d\n", rv); return -1; } rv = saHpiSessionOpen(SAHPI_DEFAULT_DOMAIN_ID, &sessionid, NULL); if (rv != SA_OK) { printf("saHpiSessionOpen error %d\n", rv); return -1; } rv = saHpiResourcesDiscover(sessionid); if (rv != SA_OK) printf("saHpiResourcesDiscover rv = %d\n", rv); printf("Initial discovery done\n"); printf("\tEnter a command or \"help\" for list of commands\n"); pthread_create(&ge_thread, NULL, get_event, NULL); return 0; }
int main (int argc, char *argv []) { SaErrorT err; SaHpiSessionIdT session_id; err = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &session_id, NULL); if (err != SA_OK) { printf("%s: saHpiSessionOpen failed\n", argv[0]); printf("%s: the daemon may not be running\n", argv[0]); return (-1); } err = saHpiDiscover(session_id); if (err != SA_OK) { printf("%s: saHpiDiscover failed\n", argv[0]); return (-1); } err = saHpiSessionClose(session_id); if (err != SA_OK) { printf("%s: saHpiSessionClose failed\n", argv[0]); return (-1); } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiWatchdogT wd; 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; } rc = saHpiWatchdogTimerGet(sid, 1, 1, &wd); if (rc != SA_OK) { dbg("Couldn't get watchdog timer"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiPowerStateT pwrstate; SaErrorT rc = SA_OK; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if (rc != SA_OK) { err("Failed to open session"); return -1; } rc = saHpiDiscover(sid); if (rc != SA_OK) { err("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) { err("Couldn't find the resource id of the chassis"); return -1; } rc = saHpiResourcePowerStateGet(sid, resid, &pwrstate); if (rc != SA_OK) { err("Couldn't get power state"); err("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; 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; } rc = saHpiResourcePowerStateSet(sid, 1, SAHPI_POWER_ON); if (rc != SA_OK) { dbg("Couldn't set power state"); dbg("Error %s",oh_lookup_error(rc)); return -1; } rc = saHpiResourcePowerStateSet(sid, 1, SAHPI_POWER_OFF); if (rc == SA_OK) { dbg("Able to set invalid power state"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiTimeT cur_time = 0; 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; } /* set event log time */ rc = saHpiEventLogTimeSet(sid, 1, cur_time); if (rc != SA_OK) { dbg("Couldn't set event log time"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiHsStateT state; 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 hs drive */ SaHpiResourceIdT resid = get_resid(sid, SAHPI_ENT_DISK_DRIVE_BAY); if (resid == 0) { dbg("Couldn't find the resource id of the hs drive"); return -1; } rc = saHpiHotSwapStateGet(sid, resid, &state); if (rc != SA_OK) { dbg("Couldn't get state"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiIdrFieldT field; SaHpiEntryIdT next; SaErrorT rc = SA_OK; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if (rc != SA_OK) { err("Failed to open session"); return -1; } rc = saHpiDiscover(sid); if (rc != SA_OK) { err("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) { err("Couldn't find the resource id of the chassis"); return -1; } rc = saHpiIdrFieldGet(sid, resid, 1, 1, SAHPI_IDR_FIELDTYPE_MANUFACTURER, SAHPI_FIRST_ENTRY, &next, &field); if (rc != SA_OK) { err("Couldn't get field"); err("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiIdrFieldT field; SaHpiEntryIdT next; 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; } rc = saHpiIdrFieldGet(sid, 1, 1, 1, SAHPI_IDR_FIELDTYPE_MANUFACTURER, SAHPI_FIRST_ENTRY, &next, &field); if (rc != SA_OK) { dbg("Couldn't get field"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
SaErrorT tsetup (SaHpiSessionIdT *sessionid_ptr) { SaErrorT err = SA_OK; /* ************************ * Hook in simulation environment * ***********************/ err = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, sessionid_ptr, NULL); if (err != SA_OK) { printf("Error! Can not open session.\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); printf(" Received error=%s\n", oh_lookup_error(err)); } if (!err) err = saHpiDiscover(*sessionid_ptr); if (err != SA_OK) { printf("Error! Can not discover resources.\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); printf(" Received error=%s\n", oh_lookup_error(err)); err = saHpiSessionClose(*sessionid_ptr); } return err; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; 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 = saHpiAnnunciatorAcknowledge(sid, resid, 1, SAHPI_ENTRY_UNSPECIFIED, SAHPI_MINOR); if (rc != SA_OK) { dbg("Couldn't ack annunciator"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; setenv("OPENHPI_CONF","./noconfig", 1); if (saHpiSessionOpen(1, &sid, NULL)) return -1; /* Load plugins */ if (oHpiPluginLoad("libdummy")) return -1; if (oHpiPluginLoad("libwatchdog")) return -1; if (!oHpiPluginGetNext(NULL, NULL, 0)) return -1; if (oHpiPluginUnload("libwatchdog")) return -1; return oHpiPluginUnload("libdummy"); }
int main(int argc, char **argv) { SaErrorT err; SaHpiSessionIdT sessionid; err = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL); if (err) { printf(" Error! Testcase failed. Line=%d\n", __LINE__); printf(" Received error=%s\n", oh_lookup_error(err)); return -1; } // regular sim_init is part of saHpiSessionOpen, here we close it sim_close(); // env variable OPENHPI_SIMTEST_FILE is now defined in Makefile.am // setenv("OPENHPI_SIMTEST_FILE","./sim_test_file", 1); // create hash table based on input file err = sim_file(); if (err != SA_OK) { printf(" Error! sim_file failed\n"); return -1; } /****************** * End of testcases ******************/ err = saHpiSessionClose(sessionid); if (err) { printf("Error! saHpiSessionClose: err=%d\n", err); return -1; } return 0; }
int open_session() { SaErrorT rv; if (!g_thread_supported()) { g_thread_init(NULL); }; thread_wait = g_cond_new(); thread_mutex = g_mutex_new(); do_progress("Discover"); rv = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL); if (rv != SA_OK) { printf("saHpiSessionOpen error %d\n", rv); return -1; } rv = saHpiDiscover(sessionid); if (rv != SA_OK) printf("saHpiDiscover rv = %d\n", rv); delete_progress(); printf("Initial discovery done\n"); Domain = init_resources(sessionid); if (Domain == (Domain_t *)NULL) { printf("init_resources error\n"); return -1; } printf("\tEnter a command or \"help\" for list of commands\n"); pthread_create(&ge_thread, NULL, get_event, NULL); return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; char *config_file = NULL; GHashTable *config = g_hash_table_new(g_str_hash, g_str_equal); oHpiHandlerIdT hid = 0; /* Save config file env variable and unset it */ config_file = getenv("OPENHPI_CONF"); setenv("OPENHPI_CONF","./noconfig", 1); if (saHpiSessionOpen(1, &sid, NULL)) return -1; if (oHpiPluginLoad("libdummy")) return -1; /* Set configuration. */ g_hash_table_insert(config, "plugin", "libdummy"); g_hash_table_insert(config, "entity_root", "{SYSTEM_CHASSIS,1}"); g_hash_table_insert(config, "name", "test"); g_hash_table_insert(config, "addr", "0"); if (oHpiHandlerCreate(config, &hid)) return -1; if (!oHpiHandlerInfo(0, NULL)) return -1; /* Restore config file env variable */ setenv("OPENHPI_CONF",config_file,1); return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaErrorT rc = SA_OK; int retc; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if(rc != SA_OK) return -1; rc = saHpiDiscover(sid); if (rc != SA_OK) return -1; /* inject an event */ retc = inject_event("simulator"); if (retc != 0) { return -1; } /* sleep so the msg thread gets a chance to process the msg */ g_usleep(100000); saHpiSessionClose(sid); return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; char *config_file = NULL; oHpiPluginInfoT pinfo; /* Save config file env variable and unset it */ config_file = getenv("OPENHPI_CONF"); setenv("OPENHPI_CONF","./noconfig", 1); if (saHpiSessionOpen(1, &sid, NULL)) return -1; if (oHpiPluginLoad("libdummy")) return -1; if (oHpiPluginInfo("libdummy",&pinfo)) return -1; if (pinfo.refcount != 1) return -1; /* Restore config file env variable */ setenv("OPENHPI_CONF",config_file,1); return oHpiPluginUnload("libdummy"); }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiWatchdogT wd; 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 = saHpiWatchdogTimerGet(sid, resid, 1, &wd); if (rc != SA_OK) { dbg("Couldn't get watchdog timer"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiAnnouncementT announ; SaErrorT rc = SA_OK; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if (rc != SA_OK) { err("Failed to open session"); return -1; } rc = saHpiDiscover(sid); if (rc != SA_OK) { err("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) { err("Couldn't find the resource id of the chassis"); return -1; } announ.EntryId = SAHPI_FIRST_ENTRY; rc = saHpiAnnunciatorGetNext(sid, resid, 1, SAHPI_ALL_SEVERITIES, FALSE, &announ); if (rc != SA_OK) { err("Couldn't get next annunciator"); err("Error %s",oh_lookup_error(rc)); return -1; } rc = saHpiAnnunciatorGetNext(sid, resid, 1, SAHPI_ALL_SEVERITIES, FALSE, &announ); if (rc != SA_OK) { err("Couldn't get next annunciator"); err("Error %s",oh_lookup_error(rc)); return -1; } rc = saHpiAnnunciatorGetNext(sid, resid, 1, SAHPI_ALL_SEVERITIES, FALSE, &announ); if (rc != SA_OK) { err("Couldn't get next annunciator"); err("Error %s",oh_lookup_error(rc)); return -1; } rc = saHpiAnnunciatorGetNext(sid, resid, 1, SAHPI_ALL_SEVERITIES, FALSE, &announ); if (rc == SA_OK) { err("Invalid number of announcements"); err("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; char next_plugin[PLUGIN_NAME_SIZE]; setenv("OPENHPI_CONF","./noconfig", 1); if (saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL)) return -1; /* Load plugins */ if (oHpiPluginLoad("libsimulator")) return -1; if (oHpiPluginLoad("libwatchdog")) return -1; if (oHpiPluginUnload("libsimulator")) return -1; next_plugin[0] = '\0'; if (!oHpiPluginGetNext("libsimulator", next_plugin, PLUGIN_NAME_SIZE)) return -1; return oHpiPluginUnload("libwatchdog"); }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; GHashTable *config = g_hash_table_new(g_str_hash, g_str_equal); oHpiHandlerIdT hid = 0; setenv("OPENHPI_CONF","./noconfig", 1); if (saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL)) return -1; if (oHpiPluginLoad("libsimulator")) return -1; /* Set configuration. */ g_hash_table_insert(config, "plugin", "libsimulator"); g_hash_table_insert(config, "entity_root", "{SYSTEM_CHASSIS,1}"); g_hash_table_insert(config, "name", "test"); g_hash_table_insert(config, "addr", "0"); if (oHpiHandlerCreate(config, &hid)) return -1; if (!oHpiHandlerDestroy(0)) return -1; return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; 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; } rc = saHpiHotSwapActionRequest(sid, 4, SAHPI_HS_ACTION_EXTRACTION); if (rc != SA_OK) { dbg("Couldn't request action"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int getSaHpiSession (SaHpiSessionIdT * out) { SaHpiVersionT version; DEBUGMSGTL ((AGENT, "--- getSaHpiSession: Entry. ")); if (session_avail == AGENT_FALSE) { err = saHpiInitialize (&version); if (SA_OK != err) { snmp_log (LOG_ERR, "saHpiInitialize error: %s\n", get_error_string (err)); return AGENT_ERR_INIT; } err = saHpiSessionOpen (SAHPI_DEFAULT_DOMAIN_ID, &session_id, NULL); if (SA_OK != err) { snmp_log (LOG_ERR, "saHpiSessionOpen error: %s\n", get_error_string (err)); return AGENT_ERR_SESSION_OPEN; } err = saHpiSubscribe (session_id, SAHPI_FALSE); if (SA_OK != err) { snmp_log (LOG_ERR, "saHpiSubscribe failed. error: %s\n", get_error_string (err)); return AGENT_ERR_SUBSCRIBE; } session_avail = AGENT_TRUE; //Subscribe to the Events } rediscover_count--; if (rediscover_count <= 0) { // Re-set the rediscover_count; DEBUGMSGTL ((AGENT, "Calling 'saHpiResourceDiscover()'.\n")); rediscover_count = REDISCOVER_COUNT_MAX; err = saHpiResourcesDiscover (session_id); if (SA_OK != err) { snmp_log (LOG_ERR, "saHpiResourcesDiscover error: %s\n", get_error_string (err)); return AGENT_ERR_DISCOVER; } } if (out) *out = session_id; DEBUGMSGTL ((AGENT, "--- getSaHpiSession: Exit\n")); return AGENT_ERR_NOERROR; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiAnnouncementT announ; 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; } /* add an announcement */ announ.EntryId = 0; // modified by oh_announcement_append announ.Timestamp = 0; // modified by oh_announcement_append announ.AddedByUser = FALSE; // modified by oh_announcement_append announ.Severity = SAHPI_CRITICAL; announ.Acknowledged = FALSE; announ.StatusCond.Type= SAHPI_STATUS_COND_TYPE_SENSOR; announ.StatusCond.Entity.Entry[0].EntityType = SAHPI_ENT_SYSTEM_BOARD; announ.StatusCond.Entity.Entry[0].EntityLocation = 1; announ.StatusCond.Entity.Entry[1].EntityType = SAHPI_ENT_ROOT; announ.StatusCond.Entity.Entry[1].EntityLocation = 0; announ.StatusCond.DomainId = 1; announ.StatusCond.ResourceId = 1; announ.StatusCond.SensorNum = 1; announ.StatusCond.EventState = SAHPI_ES_UNSPECIFIED; announ.StatusCond.Name.Length = 6; memcpy(&announ.StatusCond.Name.Value,"announ", 6); announ.StatusCond.Mid = 123; announ.StatusCond.Data.DataType = SAHPI_TL_TYPE_TEXT; announ.StatusCond.Data.Language = SAHPI_LANG_ENGLISH; announ.StatusCond.Data.DataLength = 6; memcpy(&announ.StatusCond.Data.Data,"announ", 6); rc = saHpiAnnunciatorAdd(sid, resid, 1, &announ); if (rc != SA_OK) { dbg("Couldn't add announcement"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
SaErrorT openSession(SaHpiSessionIdT * sessionId) { SaErrorT status; status = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, sessionId, NULL); if (status != SA_OK) { e_print(saHpiSessionOpen, SA_OK, status); } return status; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiEventT entry; SaHpiEventLogEntryT logentry; SaHpiEventLogEntryIdT prev, next; 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; } /* initialize the new event log entry */ entry.Source = SAHPI_UNSPECIFIED_RESOURCE_ID; entry.EventType = SAHPI_ET_USER; entry.Timestamp = 0; entry.Severity = SAHPI_INFORMATIONAL; oh_init_textbuffer(&entry.EventDataUnion.UserEvent.UserEventData); oh_append_textbuffer(&entry.EventDataUnion.UserEvent.UserEventData, "My user data"); /* add event log entry */ rc = saHpiEventLogEntryAdd(sid, resid, &entry); if (rc != SA_OK) { dbg("Couldn't add event log entry"); dbg("Error %s",oh_lookup_error(rc)); return -1; } /* get event log entry */ rc = saHpiEventLogEntryGet(sid, resid, SAHPI_NEWEST_ENTRY, &prev, &next, &logentry, NULL, NULL); if (rc != SA_OK) { dbg("Couldn't get event log entry"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiAnnouncementT announ; 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; } /* add an announcement */ announ.EntryId = 0; // modified by oh_announcement_append announ.Timestamp = 0; // modified by oh_announcement_append announ.AddedByUser = FALSE; // modified by oh_announcement_append announ.Severity = SAHPI_CRITICAL; announ.Acknowledged = FALSE; announ.StatusCond.Type= SAHPI_STATUS_COND_TYPE_SENSOR; announ.StatusCond.Entity.Entry[0].EntityType = SAHPI_ENT_SYSTEM_BOARD; announ.StatusCond.Entity.Entry[0].EntityLocation = 1; announ.StatusCond.Entity.Entry[1].EntityType = SAHPI_ENT_ROOT; announ.StatusCond.Entity.Entry[1].EntityLocation = 0; announ.StatusCond.DomainId = 1; announ.StatusCond.ResourceId = 1; announ.StatusCond.SensorNum = 1; announ.StatusCond.EventState = SAHPI_ES_UNSPECIFIED; announ.StatusCond.Name.Length = 5; memcpy(&announ.StatusCond.Name.Value,"announ", 5); announ.StatusCond.Mid = 123; /* we will not worry about the Data field for this test */ rc = saHpiAnnunciatorAdd(sid, 1, 1, &announ); if (rc != SA_OK) { dbg("Couldn't add announcement"); dbg("Error %s",oh_lookup_error(rc)); return -1; } rc = saHpiAnnunciatorDelete(sid, 1, 1, SAHPI_ENTRY_UNSPECIFIED, SAHPI_CRITICAL); if (rc != SA_OK) { dbg("Couldn't delete announcement"); dbg("Error %s",oh_lookup_error(rc)); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaErrorT rc = SA_OK; int event_ctr = 0; SaHpiEventLogEntryT ele; SaHpiRdrT rdr; SaHpiRptEntryT rpte; SaHpiEventLogEntryIdT eleid, neleid, peleid; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if(rc != SA_OK) return -1; rc = saHpiSubscribe(sid); if(rc != SA_OK) return -1; rc = saHpiDiscover(sid); if (rc != SA_OK) return -1; /* count discovery events */ eleid = neleid = SAHPI_OLDEST_ENTRY; while (rc == SA_OK && neleid != SAHPI_NO_MORE_ENTRIES) { rc = saHpiEventLogEntryGet(sid, SAHPI_UNSPECIFIED_RESOURCE_ID, eleid, &peleid, &neleid, &ele, &rdr, &rpte); if (ele.Event.EventType == SAHPI_ET_RESOURCE) event_ctr++; eleid = neleid; } if (rc != SA_OK) { printf("SaHpiEventLogEntryGet returned %d.\n", rc); return -1; } /* A FRU device does NOT generate an ADD event. So our Hot Swap Disk * Drive Bay resource will not generate an ADD event since it is marked * as a FRU. If you change this, this test will see an additional event. */ if (event_ctr != 4) { printf("Incorrect number of events returned. Found %d events.\n", event_ctr); return -1; } return 0; }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; SaHpiRptEntryT res; SaHpiRdrT rdr; SaHpiEntryIdT id = SAHPI_FIRST_ENTRY; SaHpiResourceIdT resid; int failcount = 0; int testnum = 0; SaErrorT rc = SA_OK; rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if(rc != SA_OK) { failed("Failed to open session"); } rc = saHpiDiscover(sid); if(rc != SA_OK) { failed("Failed to run discover"); } rc = saHpiRptEntryGet(sid, id, &id, &res); runtest(); if(rc != SA_OK) { dbg("Error %s",oh_lookup_error(rc)); failed("Couldn't get the first rpt entry"); /* we're toast, bail */ goto end; } else{ id = SAHPI_FIRST_ENTRY; resid = res.ResourceId; rc = saHpiRdrGet(sid, resid, id, &id, &rdr); if (oh_cmp_ep(&rdr.Entity,&res.ResourceEntity) != SAHPI_TRUE){ dbg("Error %s", oh_lookup_error(rc)); failed("Entity path of rdr did not match entity path of resource"); } runtest(); if(rc != SA_OK){ dbg("Error %s", oh_lookup_error(rc)); failed("Couldn't get the first rdr entry"); goto end; } } dbg("Ran %d tests", testnum); /* if there is any failures, the test fails */ end: if(failcount) { return -1; } return(0); }
int main(int argc, char **argv) { SaHpiSessionIdT sid = 0; char *config_file = NULL; GHashTable *h0 = g_hash_table_new(g_str_hash, g_str_equal), *h1 = g_hash_table_new(g_str_hash, g_str_equal), *h2 = g_hash_table_new(g_str_hash, g_str_equal); oHpiHandlerIdT hid0 = 0, hid1 = 0, hid2 = 0, next_id = 0; /* Save config file env variable and unset it */ config_file = getenv("OPENHPI_CONF"); setenv("OPENHPI_CONF","./noconfig", 1); if (saHpiSessionOpen(1, &sid, NULL)) return -1; if (oHpiPluginLoad("libdummy")) return -1; if (oHpiPluginLoad("libwatchdog")) return -1; /* Set configuration. */ g_hash_table_insert(h0, "plugin", "libdummy"); g_hash_table_insert(h0, "entity_root", "{SYSTEM_CHASSIS,1}"); g_hash_table_insert(h0, "name", "test"); g_hash_table_insert(h0, "addr", "0"); g_hash_table_insert(h1, "plugin", "libwatchdog"); g_hash_table_insert(h1, "entity_root", "{SYSTEM_CHASSIS,2}"); g_hash_table_insert(h1, "addr", "0"); g_hash_table_insert(h2, "plugin", "libdummy"); g_hash_table_insert(h2, "entity_root", "{SYSTEM_CHASSIS,3}"); g_hash_table_insert(h2, "name", "test"); g_hash_table_insert(h2, "addr", "0"); if (oHpiHandlerCreate(h0, &hid0) || oHpiHandlerCreate(h1, &hid1) || oHpiHandlerCreate(h2, &hid2)) return -1; if (oHpiHandlerDestroy(hid1)) return -1; if (oHpiHandlerGetNext(hid0, &next_id) && next_id == 3) return -1; if (!oHpiHandlerGetNext(hid1, &next_id)) return -1; return 0; }