Solstice Enterprise Manager 4.1 C++ API Reference | ![]() ![]() ![]() ![]() ![]() |
Nerve Center Interface
The Nerve Center Interface (NCI) library is built on top of the Portable Management Interface (PMI). The NCI library allows applications to create template requests, launch the request against Management Information Server (MIS) objects, and retrieve information about objects.
This chapter comprises the following topics:
- Section 7.1 Requests
- Section 7.2 Class and Function Summary
- Section 7.3 NC Requests
- Section7.4 NCI Library Classes
- Section 7.8 NCI Library Functions
- Section 7.10.31.2 Event Request Example
7.1 Requests
A Nerve Center (NC) template is a type of management request; it is used to manage a set of selected objects in the MIS. A NC template is comprised of state, condition, transition, and action requests. NC template definitions reside in the MIS.
When a request is launched, the Nerve Center polls remote objects and retrieves the requested information. If the application transitions to a new state, the managed object's severity and state attributes are changed in the MIS and appropriate applications are informed of that object's state change.
Note When compiling NCI clients, do not disable C++ exceptions (-noex option with Sun C++ compilers) and do link NCI clients with the RogueWave library.
7.2 Class and Function Summary
TABLE 7-1 summarizes the classes and functions included this chapter.
TABLE 7-1 Nerve Center Classes and Functions TABLE 7-2 lists the library classes included in the NCI. Allows iteration through the responses received for an asynchronous launch NCParsedReqHandle Class Parses request handles returned by NCI functions NCTopoInfoList Class Builds a list of toponode information nci_action_add Result Adds the action to the transition nci_action_delete Result Deletes the action from the list of actions for transition nci_async_request_start Waiter Launches NC requests asynchronously nci_condition_add Result Creates a condition object that can be used for building NC templates nci_condition_delete Result Deletes an existing condition nci_condition_get char* Returns an ASCII string containing RCL statement(s) nci_init Result Initializes the NCI library nci_parse_handle Result Parses a given request handle and returns data nci_pollrate_add Result Creates a new pollrate object in the MIS nci_pollrate_delete Result Deletes an existing pollrate object in the MIS nci_request_delete Result Deletes a running request nci_request_dump Array(DU) Returns current state, severity, and variable data nci_request_info Result Returns state name, severity string, and severity value nci_request_list Array(DU) Returns an array of request handles nci_request_start (DU) Starts a management request against an object nci_severity_add Result Creates a new security level in the MIS nci_severity_delete Result Deletes an existing severity in the MIS nci_state_add Result Adds the state to a NC template nci_state_delete Result Deletes the state from a NC template nci_state_get NC_State Gets the handle to identify the state in a NC template nci_template_add Result Edits a NC template nci_template_copy Result Copies a NC template nci_template_create Result Creates a handle for a NC template nci_templete_delete Result Deletes an existing NC template from the MIS nci_template_find NC_Defn Gets the handle for an existing request for editing nci_template_revert NC_Defn Undoes changes done to the NC template nci_template_store Result Stores the NC template nci_transition_add Result Adds a transition to an existing NC template nci_transition_delete Result Deletes a transition between two states nci_transition_find NC_Transition Gets the transition in a NC template nci_transition_get NC_Transition Gets the handle on transition from the state
7.3 NC Requests
7.3.1 Synchronous Launches
Synchronous launches imply that associated functions do not return until after all the parameter validation and communication with the MIS, regarding the start of the request, is complete. These functions do not actually confirm whether the request has started successfully or not. In that sense, it is asynchronous.
In comparison, functions in an asynchronous launch return even before any communication with the MIS, regarding the start of the request, takes place.
The functions that are specifically synchronous are:
Many of the request functions use the variable, handle. handle is an optional user-defined string. When it is used, the NCI uses it to build the request handle that the NCI returns.
The purpose of using handle is to allow an application, like the auto daemon, to get a list of running requests from the NCI and know which ones it has started. Such a list is useful when an application restarts. An application does not have to use handle; it can keep a list of the requests it has started instead. If handle is not passed, the request handle is formed by the NCI without it
7.3.2 Asynchronous Launches
In asynchronous launches, associated functions return before communication with the MIS, regarding the start of the request, takes place. In comparison, synchronous launches imply that associated functions do not return until after all the parameter validation and communication with the MIS, regarding the start of the request, is complete.
The classes/functions associated with asynchronous launches are:
- TABLE 7-2 lists the library classes included in the NCI.
- nci_async_request_start
- NCTopoInfoList Class
7.4 NCI Library Classes
TABLE 7-2 lists the library classes included in the NCI.
TABLE 7-2 NCI Library Classes TABLE 7-2 lists the library classes included in the NCI. NCParsedReqHandle Class NCTopoInfoList Class
7.5 NCAsyncResIterator Class
The NCAsyncResIterator class allows you to iterate through the responses received for an asynchronous launch of possible multiple requests. Each iteration allows you to extract response information about one request.
7.5.1 Constructor
NCAsyncResIterator(Ptr call_data );This constructor takes call_data as an argument. call_data is the data supplied by nci_async_request_start(), when nci_async_request_start() calls the user-installed callback.
7.5.2 Destructor
~NCAsyncResIterator();7.5.3 Operator Overloading for Prefix Operator++
RWBoolean operator++();The prefix increment operator advances the iterator one position in the response list. Returns FALSE, if it advances past the end of the response list. Otherwise, it returns TRUE.
Note The postfix operator++(int) is not supported.
7.5.4 Member Functions
get_req_handle
const DataUnit& get_req_handle() const;Returns the request handle for the request determined by the current position of the iterator in the response list. The results are undefined if the iterator is no longer valid or if operator++() has previously returned FALSE.
get_req_status
NCAsyncReqStatus get_req_status() const;Returns the status of the request determined by the current position of the iterator in the response list. The results are undefined if the iterator is no longer valid or if operator++() has previously returned FALSE.
NCAsyncReqStatus represents the status of the request that is launched asynchronously.
enum NCAsyncReqStatus{NOT_INITIALIZED,AWAITING_RESPONSE,LAUNCH_SUCCESS,LAUNCH_FAILURE};NOT_INITIALIZED: Indicates the NC request was never launched.
AWAITING_RESPONSE: Indicates that a request (internal CMIP request) has been made to the MIS to launch the NC request, and is waiting for a response from the MIS.
LAUNCH_SUCCESS: The NC request was successfully launched.
LAUNCH_FAILURE: The NC request launch failed.
get_error_reason
const RWCString& get_error_reason() const;Returns the reason for failure to launch a given request, determined by the current position of the iterator in the response list. You should use this member function only when get_req_status() returns LAUNCH_FAILURE.
The results are undefined if the iterator is no longer valid or if operator++() has previously returned FALSE.
7.6 NCParsedReqHandle Class
NCParsedReqHandle class is responsible for parsing request handles returned by NCI functions. For backward compatibility, nci_parse_handle() is retained. However, it is recommended that NCParsedReqHandle be used wherever possible. This provides better insulation against any changes to the request handle implementation and more information can be extracted from the request handle.
7.6.1 Constructors
NCParsedReqHandle(const DataUnit& req_handle_du);This constructor parses the req_handle_du which is received by NCI functions that launch requests, either synchronously or asynchronously.
If the request handle passed is invalid, the NCParsedReqHandle constructor throws an NCException to the user. To determine the cause of the exception, use NCException::why() which returns char*.
7.6.2 Default Destructor
~NCParsedReqHandle();7.6.3 Member Functions
get_topo_id
u_long get_topo_id() const;This function returns the topo_id from the request_handle.
get_mis_name
const RWCString& get_mis_name() const;This function returns the name of the MIS against which the request was launched.
get_template_name
const RWCString& get_template_name() const;This function returns the name of the NC template that was used to launch the request.
get_invoke_id
u_long get_invoke_id() const;This function returns the invoked id of the asynchronous launch. Invoke ID is per process and per invocation of nci_async_request_launch(). For synchronous launches, invoke_id is always zero.
get_user_stub
const RWCString& get_user_stub() const;This function returns the user_stub that was used in the construction of the request handle. This user_stub is passed to the invocation of synchronous versions of request launches.
7.7 NCTopoInfoList Class
NCTopoInfoList class is used to build a list of toponode information. Information about individual toponodes is shared using the copy constructor and assignment operator.
7.7.1 Default Constructor
NCTopoInfoList();This function is the default constructor that constructs an empty topology information list.
7.7.2 Copy Constructor
NCTopoInfoList (const NCTopoInfoList& that);This is the copy constructor that increments the reference count on the internal implementation object contained within that object.
7.7.3 Destructor
~NCTopoInfoList();This destructor decrements the reference count on the internal implementation object and deletes the internal implementation object when the reference count goes to zero.
7.7.4 Operator
Overloading for Operator=
NCTopoInfoList& operator=(const NCTopoInfoList& that);The assignment operator increments the reference count on the internal implementation object contained within that object.
7.7.5 Member Functions
add_topo_info
Result add_topo_info(u_long topo_id,Array(DU)& fdn_set,CDU mis_name = null_du);Alternately,
Result add_topo_info(u_long topo_id,CDU mis_name = null_du);This member function adds information about one toponode to the NCTopoInfoList object. This overloaded member function is provided for the sake of efficiency and performance. Some applications might already cache the fdns of the toponodes (the value of the topoNodeMOSet GDMO attribute).
Such applications can pass in the fdn_set (optional). Each fdn in the fdn_set should be either in the slash or brace format. Because nci_async_request_start() does not issue any requests to the MIS to get information about the toponodes, performance gains are achieved.
If mis_name is not specified, it is assumed to be the local MIS (the MIS to which nci_init() initially connected). Returns OK if successful. Otherwise, it returns NOT_OK.
7.8 NCI Library Functions
Note All functions that return Result are either OK or NOT_OK. All functions that return Boolean are either TRUE or FALSE.
Several NCI functions use an argument mis_name, as the NCI supports MIS to MIS awareness. NCI accepts mis_name in the following formats:
- slash format (/systemId=name:"sol")
- string name ("sol")
The mis_name is the name of the MIS on which the given NCI function is effective. Unless otherwise specified, mis_name automatically maps to the local MIS that the NCI application is connected to. null_du is the default value, and represents the empty DataUnit.
TABLE 7-3 lists the NCI library functions.
7.9 NCI Global Variables
7.9.1 nci_error_reason
extern DataUnit nci_error_reason;NCI has a facility that allows you to diagnose errors using nci_error_reason. This global variable, of the DataUnit type, can be used to know the reason for any failures of any NCI function. This variable contains a meaningful reason only immediately after any NCI function returns an error. This variable is not re-initialized by NCI every time an NCI function is invoked. It is set only when NCI encounters an error.
7.9.2 topoNodeId Argument
Several of the NCI functions include the argument topoNodeId. NCI accepts topoNodeId in the form of a DataUnit and supports either of the following formats:
u_long topoNodeId;
DataUnit duTopoNodeId = DataUnit::printf("%u", topoNodeId);The topoNodeId should be constructed as shown in the above syntax before passing to NCI any of the functions that require topoNodeId. You can use sscanf() or sprintf() to simulate a comparable effect.
- mis_name:topoId
- topoId
7.10 NCI Functions
7.10.1 nci_action_add
Resultnci_action_add(NC_Transition &transq,const char *action,const char *arg0,const char *arg1,CDU mis_name= null_du);The function nci_action_add() adds the action action to the transition transq. The action can be either a condition, or mail, or unixcmd. For condition, arg0 is the name of the condition and arg1 is null. For mail, arg0 is the address and arg1 is the message. For unixcmd, arg0 is the UNIX command name and arg1 is the argument. transq is the handle on transition as returned by the nci_transition_find() function. The function returns TRUE if the action is added, FALSE if there is an error.
7.10.2 nci_action_delete
Resultnci_action_delete(NC_Transition &transq,const char *action,const char *arg0,const char *arg1);The function nci_action_delete() deletes the action action from the list of actions for transition transq. The action can be either a condition, or mail, or unixcmd. For condition, arg0 is the name of the condition and arg1 is null. For mail, arg0 is the address and arg1 is the message. For unixcmd, arg1 is the list of arguments specified by arg0. arg1 is in string format. transq is the handle on transition as returned by the function nci_transition_find(). The function returns TRUE if the action is deleted, FALSE if there is an error.
7.10.3 nci_async_request_start
Waiter
nci_async_request_start(const char* template_name,NCTopoInfoList topo_info_list,Callback user_cb,Timeout timeout_time = 3600.0 seconds);nci_async_request_start() returns a waiter that represents the asynchronous launch.
template_name is the name of the NC template that is used to launch the request.
topo_info_list is information about the toponodes against each of which the request is to be launched asynchronously.
user_cb is the callback, if installed by the user, that is called when the asynchronous launch completes, either successfully or not. user_cb is called by NCI. The call_data parameter of the callback is a pointer that must be used to construct NCAsyncResIterator object. If the call_data pointer is not used to construct the NCAsyncResIterator object, a memory leak may occur.
timeout_time is the timeout interval after which nci_async_request_start() times out and returns. Currently, it is recommended that you use the default timeout. Timeout for lower timer intervals is not supported in this release.
Note Waiter cancellation or waiter clobbering is not supported.
7.10.4 nci_condition_add
Resultnci_condition_add(const char *condition_name,const char *condition_desc,const char *condition,CDU mis_name = null_du);The function nci_condition_add() creates a condition object that can then be used for building NC templates. The condition itself is one or more lines separated by new lines specified in the Request Condition Language (RCL).
7.10.5 nci_condition_delete
Resultnci_condition_delete(const char *condition_name,CDU mis_name = null_du);The function nci_condition_delete() deletes an existing condition. If a condition is associated with a transition it cannot be deleted until the transitions are deleted.
7.10.6 nci_condition_get
char*nci_condition_get(const char *condition_name,char *conditionDesc,CDU mis_name = null_du);The function nci_condition_get() returns an ASCII string containing a Request Condition Language statement or statements.
7.10.7 nci_init
Resultnci_init(const char *location,DU& errorMsg);
Resultnci_initPlatform &platform,DU& errorMsg);The function nci_init() is an NCI library initialization routine and takes either a hostname (location) or a platform object (platform).
The function that takes location as the argument connects to the MIS on the host specified by location and keeps the platform object internal. Of course, one could retrieve such a platform object using the static method Platform::default_platform(). The function returns NOT_OK if it could not connect to the MIS on the host specified by location. Otherwise, it returns OK.
The funtion that takes platform as the argument assumes the platform object is connected to some MIS and uses that platform object to talk to that MIS. If the platform object is valid and if the platform object is connected to a valid MIS, then the function returns OK. Otherwise, it returns NOT_OK.
7.10.8 nci_parse_handle
Resultnci_parse_handle(const DataUnit &request_handle,DataUnit &template_name,DataUnit &topoNodeId);
Note NCParsedReqHandle class is responsible for parsing request handles returned by NCI functions. For backward compatibility, nci_parse_handle() is retained. However, it is recommended that NCParsedReqHandle be used wherever possible. This provides better insulation against any changes to the request handle implementation and more information can be extracted from the request handle.
The function nci_parse_handle() parses a given request handle and returns the template_name and the information about topoNodeId against which the request was launched. The request_handle must be a valid one returned by a previous relevant NCI function. It returns OK if parsing succeeds. Otherwise, it returns NOT_OK and template_name and topoNodeId are undefined.
7.10.9 nci_pollrate_add
Resultnci_pollrate_add(const char *pollrate_name,int rate,CDU mis_name = null_du);The function nci_pollrate_add() creates a new pollrate object in the MIS. This pollrate can be used in creating NC templates. The pollrate is in seconds.
7.10.10 nci_pollrate_delete
Resultnci_pollrate_delete(const char *pollrate_name,CDU mis_name = null_du);The function nci_pollrate_delete() deletes an existing pollrate object in the MIS.
7.10.11 nci_request_delete
Resultnci_request_delete(CDU request_handle);The function nci_request_delete() deletes a running request. The handle for the request must be passed. The handle can be obtained from either nci_request_start() or by nci_request_list(). These request calls are unconfirmed and asynchronous.
7.10.12 nci_request_dump
Array(DU)nci_request_dump(CDU request_handle);For the request identified by request_handle, the function nci_request_dump() returns the information about the current state, severity, and each variable's name, type, and value. For example, for three variables, eleven pieces of information are returned: current state, severity, and name, type, and value of each variable. The information is returned as the value of the function. If there is an error, an empty array is returned.
7.10.13 nci_request_info
Resultnci_request_info(CDU request_handle,DU& statename,DU& severity_name,int *severity);For the request identified by request_handle, the function nci_request_info() returns the name of state in statename, severity string in severity_name, and severity value in the integer pointed to by severity. The function returns TRUE if the request exists, FALSE otherwise.
7.10.14 nci_request_list
Array(DU)nci_request_list(CDU mis_name = null_du);The function nci_request_list() returns an array of request handles. nci_parse_handle() can be used to return the NC template name and topoNodeId.
7.10.15 nci_request_start
DUnci_request_start(const char *template_name,CDU topoNodeId,const char *handle);The function nci_request_start() starts a management request with template_name against the managed object associated with topoNodeId in the topology part of the MIT. If the request starts successfully, the request handle is returned. This handle can be used, in the nci_request_delete, to stop and thereby delete the running request. If the request fails to start, a null_du is returned.
7.10.15.1 Alternative Syntax #1
Array(DU)nci_request_start(const char *name,const Array(DU) &toponode_id_array,const char *handle);This function call performs the same job as the one above, except that multiple requests using the same NC template can be started against multiple topoNodes. One request is launched for each topoNode ID in the array. An array of handles is returned. Each handle in the array corresponds to a topoNode in the same index in the toponode_id_array.
7.10.15.2 Alternative Syntax #2
DUnci_request_start(const char *template_name,CDU oi,CDU topoNodeId,const char *handle);This function call increases performance by specifying a Fully Distinguished Name with oi. The function does not have to query the MIS for the FDN.
7.10.15.3 Alternative Syntax #3
DUnci_request_start(const char *template_name,const Array(DU) &oiSet,CDU topoNodeId,const char *handle);Performs the same job as the preceding function, except this function can take multiple FDNs and returns an array of handles.
7.10.15.4 Alternative Syntax #4
Array(DU)nci_request_start(const char *template_name,const Array(DU) &oi_array,const Array (DU) &toponode_id_array,const char *handle);These function calls are analogous to the two preceding calls, except that they start requests against any managed object (or objects, for the second call), even if no TopoNode corresponds to that object. Returned values are as described for their TopoNode counterparts.
The DU is the ObjectInstance in either absolute-pathname or FDN-name format. The DU is the value of $pollfdn when the request is created. The second version, above, differs from the first in that it allows you to launch one request for each DU in the array.
An array of handles is returned. Each handle in the array corresponds to a topoNode in the same index in the toponode_id_array. If a given request failed to start, the handle in the returned array is a null_du.
7.10.15.5 Alternative Syntax #5
Array(DU)nci_request_start(const char *template_name,const Array(Array(DU)) &oiSetArray,const Array(DU) &toponode_id_array,const char *handle);Performs the same job as the preceding function, except this function can take multiple FDNs.
7.10.16 nci_severity_add
Resultnci_severity_add(const char *severity_name,int severity,const char *color,CDU mis_name = null_du);The function nci_severity_add() creates a new severity level in the MIS. The severity level can be from 1 to 32000 and the color is any X11 color, such as red, purple, or yellow.
7.10.17 nci_severity_delete
Resultnci_severity_delete(char *severity_name,CDU mis_name = null_du);The function nci_severity_delete() deletes an existing severity in the MIS. The severity is deleted by name.
7.10.18 nci_state_add
Resultnci_state_add(NC_Defn &def,const char *state_name,const char *pollrate_name,const char *severity_name,const char *state_desc);The function nci_state_add() adds a state with name state_name, poll rate pollrate_name, severity severity_name, and description state_desc to the NC template identified by def. The function returns TRUE if the state is added, FALSE otherwise.
7.10.19 nci_state_delete
Resultnci_state_delete(NC_Defn &def,const char *state_name);The function nci_state_delete() deletes the state with name state_name from the NC template identified by def. The function returns TRUE if the state is deleted, FALSE otherwise.
7.10.20 nci_state_get
NC_Statenci_state_get(NC_Defn &def,const char *state_name);The function nci_state_get() gets the handle to identify the state with name state_name in the NC template identified by def. The function returns a valid NC_State, which is a handle on the Nerve Center state, and returns a default(invalid) NC_State if there is an error.
7.10.21 nci_template_add
Resultnci_template_add(NC_Defn &def,const char *name,const char *descrCDU mis_name = null_du);The function nci_template_add() is used when you have updated an existing NC template. The first time a NC template is created you use nci_template_store(). Subsequent edits require nci_template_add(). This function cannot be used to modify a NC template's name. An alternative is to use the function nci_template_copy() to copy the NC template using a different name, then delete the original NC template.
7.10.22 nci_template_copy
NC_Defnnci_template_copy(NC_Defn &source_defn,const char *newname,const char *descr,CDU mis_name = null_du);The function nci_template_copy() returns a handle for a new copy of NC template name. The handle of the original NC template must be passed in.
7.10.23 nci_template_create
NC_Defnnci_template_create(const char *template_name,const char *template_desc,CDU mis_name = null_du);The function nci_template_create() creates a handle for a NC template. After creation, the NC template can be built with other NCI library calls passing NC_Defn as the handle for the NC template.
7.10.24 nci_templete_delete
Resultnci_template_delete(NC_Defn &def);The function nci_template_delete() deletes an existing NC template from the MIS. This call fails if any requests are currently using this NC template.
7.10.25 nci_template_find
NC_Defnnci_template_find(const char *template_name,CDU mis_name = null_du);The function nci_template_find() is used to get the handle for an existing request for editing.
7.10.26 nci_template_revert
NC_Defnnci_template_revert(const char *template_name,CDU mis_name = null_du);The nci_template_revert()function allows you to undo changes you have made to the NC template. This function is effective only if you have not invoked nci_template_store() on the NC template you are changing.
Typical usage is to get the NC template definition by invoking nci_template_find(), and make changes to the NC template definition (such as adding states, conditions, and transitions). If you need to undo any changes to the NC template, invoke nci_template_revert() before any call to nci_template_store() is made.
7.10.27 nci_template_store
Resultnci_template_store(NC_Defn &def,const char *template_name,const char *descr,CDU mis_name = null_du);The function nci_template_store() is called after the NC template has been completely built. If nci_template_store() returns TRUE, the NC template is ready for event management.
7.10.28 nci_transition_add
Resultnci_transition_add(NC_Defn &def,const char *from,const char *to,const char *condition,const char *action,const char *arg0,const char *arg1);The function nci_transition_add() adds a transition to an existing NC template. The transition must have "from" and "to" states and the condition must exist or the call fails. Three possible actions are supported: unixcmd, condition, and mail. If UNIX command or mail actions are passed, there must be a double-quoted arg1.
7.10.29 nci_transition_delete
Resultnci_transition_delete(NC_Defn &def,const char *from_state,const char *to_state,const char *condition,const char *action,const char *arg0,const char *arg1);The function nci_transition_delete() deletes a transition between two states.
7.10.30 nci_transition_find
NC_Transitionnci_transition_find(NC_Defn &def,const char *from_state,const char *to_state,const char *condition);The function nci_transition_find() gets the transition in NC template identified by def going from the state from_state to to_state on the condition condition. The function returns a valid NC_Transition, which is a handle on the Nerve Center state-transition, and returns a default (invalid) NC_Transition if there is an error.
7.10.31 nci_transition_get
NC_Transitionnci_transition_get(NC_State &from_state,NC_State &to_state,const char *condition);7.10.31.1 Description
The function nci_transition_get() gets the handle on transition from the state identified by from_state to the state identified by to_state on the condition condition. The function returns a valid NC_Transition, which is a handle on the Nerve Center state-transition, and returns a default (invalid) NC_Transition if there is an error.
7.10.31.2 Event Request Example
This program creates pollrates, severities, and conditions, then uses them to define a NC template for managing an SNMP host.
Sun Microsystems, Inc. Copyright information. All rights reserved. |
Doc Set | Contents | Previous | Next | Index |