NNM (Network Node Manager) code to set object status
ovsetstatus.arf
Application "ovOVStatus_Down" {
Version "ovOVStatus_Down";
Copyright {
"(c) Copyright 1994 Centre for Information Technology",
"All rights reserved."
}
Description {
"Application Registration File for ovOVStatus_Down.",
"Changes the ovstatus for the selected objects."
}
Command -Initial -Shared -Restart "ovsetstatus";
MenuBar "Administer" {
"Set OV status" f.menu "OVstatus";
}
Menu "OVstatus" {
"Unknown" f.action "OVStatus_Down";
"Normal" f.action "OVStatus_Down";
"Warning" f.action "OVStatus_Down";
"Minor" f.action "OVStatus_Down";
"Major" f.action "OVStatus_Down";
"Critical" f.action "OVStatus_Down";
"Restricted" f.action "OVStatus_Down";
"Testing" f.action "OVStatus_Down";
"Disabled" f.action "OVStatus_Down";
}
Action "OVStatus_Down" {
}
} /*---End Application---*/
ovsetstatus.c
/**************************************************************************
*
* COPYRIGHT (C) Centre for Information Technology Research, 1994
*
* Author: David Horton
*************************************************************************/
static char rcs[] = "@(#)$RCSfile: OVStatus.c,v $ $Revision: 2.0 $";
#include
#include
#include
#include
void OVStatus_DownCB( UserData, ActionId, MenuItemId, SelectionList,
CBArgc, CBArgv, TheMap, TheSubmap)
void *UserData;
char *ActionId;
char *MenuItemId;
OVwObjectIdList *SelectionList;
int CBArgc;
char **CBArgv;
OVwMapInfo *TheMap;
OVwSubmapId TheSubmap;
{
int ret = 0;
static char *S_names[] = {
"Unknown",
"Normal",
"Warning",
"Minor",
"Major",
"Critical",
"Restricted",
"Testing",
"Disabled",
NULL };
static int S_codes[] = {
ovwUnknownStatus ,
ovwNormalStatus,
ovwWarningStatus,
ovwMinorStatus,
ovwMajorStatus,
ovwCriticalStatus,
ovwRestrictedStatus,
ovwTestingStatus,
ovwDisabledStatus};
OVwStatusType S_code = ovwUnknownStatus;
int s;
OVwObjectId oid;
fprintf(stderr,"Enter OVStatus_DownCB(,%s,%s,0x%x,,,,,)\n",
ActionId, MenuItemId, SelectionList);
/* determine desired status */
for (s = 0; S_names[s] != NULL; s++) {
if (strstr(MenuItemId, S_names[s]) != NULL) {
printf("Setting status to %s\n",S_names[s]);
S_code = S_codes[s];
break;
}
}
for (s = 0; s < SelectionList->count; s++) {
oid = SelectionList->object_ids[s];
printf("[%d] OID = %d\n", s, oid);
ret = OVwSetStatusOnObject(TheMap, oid, S_code);
if (ret != 0) {
fprintf(stderr, "OVwSetStatusOnObject( ...): %s\n",
OVwErrorMsg(OVwError()));
}
}
return;
}
CloseShop( UserData, EventId, Normal )
void *UserData;
unsigned long EventId;
int Normal;
{
exit(0);
} /*---End CloseShop()---*/
main(int argc, char *argv[]) {
int ret = 0;
if ( (ret = OVwInit()) != 0) {
ret = OVwError();
fprintf(stderr, "OVwInit: %s\n", OVwErrorMsg(ret));
exit (ret);
}
/*---Register A Callback for the end session event---*/
if( OVwAddCallback( ovwEndSession, NULL,
(OVwCallbackProc) CloseShop, NULL ) !=0 ) {
fprintf(stderr, "OVwAddCallback( ovwEndSession...: %s\n",
OVwErrorMsg(OVwError()));
exit(1);
}
if( OVwAddActionCallback( "OVStatus_Down",
(OVwActionCallbackProc) OVStatus_DownCB, NULL ) !=0 ){
fprintf(stderr, "OVwAddActionCallback(OVStatus_Down: %s\n",
OVwErrorMsg(OVwError()));
exit(1);
}
OVwMainLoop();
/*---Never get here...---*/
}