Solstice EM C++ Source Code
Examples
Solstice EM is supplied with a number of source
code examples that show how to use the Solstice EM C++
application programming interfaces (APIs) to develop network
management applications. The examples are contained in
subdirectories of the /opt/SUNWconn/em/src directory. For
detailed information about an example, refer to the README file supplied with the
example.
This appendix introduces the C++ source code
examples supplied with Solstice EM.
A.1 Guidelines for
Compiling the Examples
To simplify compiling the examples, a Makefile is supplied with each
example.
Note Before trying to compile an
example, make sure that the output files are written to a
directory you have write access to. The file access
permissions of the directories under /opt/SUNWconn allow only the root user
to write these directories.
If you want to compile an example by using the
CC command, refer to Chapter 14 for
guidelines on how to compile applications developed with the
Solstice EM C++ APIs.
To compile the examples, you must use version 5.2
of the SunTM Workshop C++
compiler. To verify the compiler version, type the following
command:
A.2 Satellite
Example
The satellite example illustrates applications to
manage a number of satellites by:
- Monitoring the traffic on the
satellites
- Controlling the geographical coordinates of
the satellites
- Monitoring alarms and events
- Changing communication parameters of the
satellites
The example is contained in subdirectories of the
/opt/SUNWconn/em/src/satellite
directory. The files in each subdirectory illustrate a
particular aspect of the application development process as
shown in TABLE A-1.
TABLE A-1 Subdirectories of the
Satellite Example Directory
|
mgmt_info |
Developing the object model of the
satellites |
|
platform |
Enabling an application to access managed
objects |
|
actions |
Retrieving data from the metadata
repository |
|
objects |
Performing operations on managed
objects |
|
collection |
Performing management operations on object
collections |
|
graphics |
Handling events in a GUI
application |
|
security |
Making applications and managed objects
secure |
|
simulate |
Simulating events |
|
discover |
Handling network topology |
|
complex |
Encoding and decoding complex data
types |
|
performance |
Optimizing performance by saving memory and
speeding up event processing |
|
low_level |
Optimizing performance by using the low-level
portable management interface (PMI) API |
A.3 High-Level PMI
Examples
The /opt/SUNWconn/em/src/pmi_hi directory
contains examples that show how to use the high-level PMI.
The examples show how to accomplish tasks related to several
different aspects of network management as described in the
following subsections.
A.3.1 Managed Object
Examples
TABLE A-2
lists examples showing how to perform management operations
on managed objects. The examples are contained in the /opt/SUNWconn/em/src/pmi_hi
directory.
TABLE A-2 Managed Object
Examples for the High-Level
PMI
|
get.cc |
Synchronously gets the value of the specified
attribute for the specified managed object. If no
attribute is specified, the program gets the values of all
attributes for the specified managed object. If no arguments
are specified, the program gets the values of all attributes
for the topology database topoType object named Host. To start the program after
compiling it, type: |
|
prompt% get [fdn moc [attribute]]
|
|
Where:
fdn is the fully
distinguished name (FDN) of the managed object.
moc is the managed
object class of the object.
attribute is the
attribute you want to get.
|
|
get_asyn.cc |
Asynchronously gets an attribute value of a
managed object. This example is an
asynchronous version of get.cc. |
|
set.cc |
Synchronously sets the value of the specified
attribute for the specified managed object. If no arguments
are specified, the program sets the poll rate of the NerveCenter PollRate Fast object to 777. To start the
program after compiling it, type: |
|
prompt% set fdn moc attribute value
|
|
Where:
fdn is the FDN of the
managed object.
moc is the managed
object class of the object.
attribute is the
attribute you want to set.
value is the value you
want to set the attribute to.
|
|
set_asyn.cc |
Asynchronously sets an attribute value of a
managed object. This example is an
asynchronous version of set.cc. |
|
image_boot.cc |
Loads information on the specified attributes of
the specified managed object. If no attributes are specified,
information on all attributes of the managed object is
loaded. To start the program after compiling it,
type: |
|
prompt% image_boot
-d fdn [-a attr1
-a attr2 ...
-a attrN
] |
|
Where:
fdn is the FDN of the
managed object.
attri
are the specified attribute names.
If no attributes are specified, all attributes are
obtained.
|
|
object_count.cc |
Counts all local objects, stores FDN entries in a
hash table, and searches the entries in the hash
table. |
A.3.2 Object Collection
Examples
TABLE A-3
lists examples showing how to perform management operations
on object collections. The examples are contained in the
/opt/SUNWconn/em/src/pmi_hi
directory.
TABLE A-3 Object Collection
Examples for the High-Level
PMI
|
album.cc |
Synchronously derives an object collection. For
each object in the collection, the example program prints the
FDN of the object, and for each attribute its name and value.
To start the program after compiling it,
type: |
|
prompt% album
[-h hostName]
|
|
Where hostName is the name
of the host where the MIS is running. If it is not specified,
localhost is
assumed. |
|
album_asyn.cc |
Asynchronously derives an object collection. This
example is an asynchronous version of album.cc. |
|
album_logObj.cc |
Derives a collection of all log objects created under the host
where the MIS is running. If a new log object is created, an Image instance representing it is added
to the object collection. |
|
album_wait.cc |
Derives an object collection the membership of
which is maintained automatically. |
|
derive_rpc.cc |
Derives an object collection for RPC groups, for
the specified host and MIS. |
|
derive_snmp.cc |
Derives an object collection for SNMP MIB II
groups, for the specified host and MIS. |
A.3.3 Event Handling
Examples
TABLE A-4
lists examples showing how to handle events. The examples are
contained in the /opt/SUNWconn/em/src/pmi_hi
directory.
TABLE A-4 Event Handling
Examples for the High-Level
PMI
|
efd.cc |
Creates an event forwarding discriminator (EFD)
and sets up an MIS to forward events to another
MIS. |
|
event_send1.cc |
Sends an event notification containing the event
name, event information, and a default time
stamp. |
|
event_send2.cc |
Sends an event notification containing the event
name, event information, and a custom time
stamp. |
|
event_send3.cc |
Sends an event notification containing the event
name, event information, and a custom time stamp in ASN.1
notation. |
|
event.cc |
Listens for all events and prints the contents of
any event it receives. |
|
event_app1.cc |
Listens for specific event types and prints the
contents of any event it receives. |
|
event_app2.cc |
Listens for events of all types that happen to
instances of the specified managed object classes. To start
the program after compiling it, type: |
|
prompt% event_app2
moc1 moc2 ... mocN
|
|
Where moci
are the specified managed object
classes. |
|
event_create_logObj.cc |
Listens for and prints log object creation events.
|
|
plat_get_conn_fd.cc |
Gets and prints the file descriptor for an MIS
connection. |
A.3.4 Log Record Handling
Examples
TABLE A-5
lists examples showing how to handle log records. The
examples are contained in the /opt/SUNWconn/em/src/pmi_hi
directory
TABLE A-5 Log Record Handling
Examples for the High-Level
PMI
|
create.cc |
Synchronously creates a log object. |
|
create_asyn.cc |
Asynchronously creates a log object. This example is an
asynchronous version of create.cc. |
|
delete.cc |
Deletes the specified log object. |
|
delete_asyn.cc |
Asynchronously deletes the specified log object. This example is an
asynchronous version of delete.cc. |
A.3.5 Network Topology
Examples
TABLE A-6
lists examples showing how to read and modify topology node
data. The examples are contained in the /opt/SUNWconn/em/src/pmi_hi/topo_user_data directory.
TABLE A-6 Network Topology
Examples for the High-Level
PMI
|
get_topoNodeUserData.cc |
Gets the value of a topology node attribute in
compound and scalar format. |
|
set_topoNodeUserData.cc |
Sets the value of a topology node
attribute. |
A.3.6 FDN Translation
Examples
TABLE A-5
lists examples showing how to translate FDNs of managed
objects into nicknames. The examples are contained in the
/opt/SUNWconn/em/src/pmi_hi/dn_translation directory.
TABLE A-7 FDN Translation
Examples for the High-Level
PMI
|
fdn_translate.cc |
Gets partial nicknames of Image instances that represent managed
objects. |
|
get_nickname_NNsvr.cc |
Retrieves the FDN translation of a managed object
and sets the nickname of an Image
instance to the translated name. |
|
set_nickname_NNsvr.cc |
Sets the nickname of an Image instance and defines this
nickname in the nickname server. |
A.3.7 Graphical
Application Examples
The /opt/SUNWconn/em/src/pmi_hi/cmipconfig
directory contains an example of a graphical application for
setting up MIS-to-MIS communication. For information on the
components of this example, refer to the /opt/SUNWconn/em/src/pmi_hi/cmipconfig/README<
/font> file.
A.3.8 MDR Action
Examples
The /opt/SUNWconn/em/src/pmi_hi/mdr_action.cc file contains an example of how to use actions to retrieve
data from the metadata repository (MDR).
A.3.9 Encoding and
Decoding Examples
The /opt/SUNWconn/em/src/pmi_hi/morf_topoNode.cc
font> file contains an example of how to use the Morf class to split a compound data
attribute value into scalar data values.
A.4 Scenario
Examples
The scenario examples show how to use several
components of Solstice EM together to develop a complete
network management solution. The examples are contained in
subdirectories of the /opt/SUNWconn/em/src/scenario
directory. The scenarios are covered by the files in one or
more of the subdirectories as follows:
TABLE A-8 Scenario
Examples
|
Adding and managing a new class of
device |
example1
example2 |
|
Using PMI client applications to present
information |
example3
example4
example5 |
|
Sharing information among PMI client
applications |
example6 |
|
Using multiple MISs |
example7
example8
example9 |
For more information on each example, refer to
the README file in the
subdirectory that contains the example.
A.5 Security
Examples
The security examples show how to use the access
control mechanisms of Solstice EM to make applications and
managed objects secure.
A.5.1 Access Control API
Examples
TABLE A-9
lists examples showing how to use the access control API to
make applications and managed objects secure. The examples
are contained in the /opt/SUNWconn/em/src/ac_api
directory.
TABLE A-9 Access Control API
Examples
|
app_feature_list.cc |
Lists applications and their
features. |
|
create_em_user.cc |
Configures access control for
applications. |
|
create_rule.cc |
Creates a security rule. |
|
create_target.cc |
Configures access control for managed
objects. |
|
list_security_defaults.cc
td>
|
Lists security defaults. |
A.5.2 Access Control
Engine API Examples
TABLE A-9
lists examples showing how to use the access control engine
API to make a management protocol adapter (MPA) or protocol
driver module (PDM) secure. The examples are contained in the
/opt/SUNWconn/em/src/mpa_pdm/src
directory.
TABLE 17-1
Access Control Engine API
Examples
|
mpapdm_ace.cc |
Implements the MpapdmAuxServer class. |
|
msgio.cc |
Checks access control and cleans up access
control objects. |
|
req_mngt.cc |
Checks access control on pending MPA PDM
requests. |
|
samp_main.cc |
Initializes access control
objects. |
A.5.3 Password Request
Example
The /opt/SUNWconn/em/src/pmi_hi/passwd_dialog/dial
og_box.cc file contains an example of how to create a
dialog box that requests a password from a user to before
allowing access to an application.
A.5.4
Application-Feature-Level Example
The /opt/SUNWconn/em/src/pmi_hi/access_feature/access
_feature_level.cc file contains an example of how to
use the high-level PMI to add feature-level access control to
an application.
A.6 Low-Level PMI
Examples
TABLE A-10
lists examples showing how to use the low-level PMI. The
examples are in the /opt/SUNWconn/em/src/pmi_low
directory.
TABLE A-10 Low-Level PMI
Example Programs
|
album_low.cc |
Sends a scoped GetReq command. The high-level PMI
equivalent is Album::derive with
scoping. |
|
boot_low.cc |
Sends a GetReq
command with a selected attribute list. The high-level PMI
equivalent is Image::boot(attrlist). |
|
create_low.cc |
Sends a CreateReq
command with a selected attribute list. The high-level PMI
equivalent is Image::set calls
followed by Image::create. |
|
delete_low.cc |
Sends a DeleteReq
command. The high-level PMI equivalent is Image::destroy. |
|
event_gen_low.cc |
Sends events directly to the event manager in the
MIS. |
|
filter_low.cc |
Sends a scoped, filtered GetReq command. The high level PMI
equivalent is Album::derive with
scoping and filtering. |
|
set_low.cc |
Sends a SetReq
command with a selected attribute list. The high-level PMI
equivalent is Image::set calls
followed by Image::store. |
|
simple_low.cc |
Sends a simple GetReq
command for the root object. No attributes are retrieved.
There is no high level PMI equivalent. |
A.7 Object Modeling
Example
The /opt/SUNWconn/em/src/gdmo_sample
directory contains the GDMO definition and ASN.1 module
specification of an example managed object class.
A.8 Object Development
Examples
The object development examples show how to use
object development tools (ODT) to develop object behaviors.
Each example is contained in a subdirectory of the /opt/SUNWconn/src/odt directory as
listed in TABLE A-11.
TABLE A-11 Object
Development Examples
|
cellSample |
Defines a set of complex intra-object behaviors.
This example monitors an object. If the behavior of the
monitored object changes, the example changes the behavior of
the monitored object's neighboring objects. |
|
chai |
Monitors an attribute named chaiReady to determine if there is any
chai tea ready to drink. If not, the example sends an action
named brewChai to make more chai
tea. |
|
demoPing |
Defines behavior of a native
agent. |
|
demoregistry |
Provides an MIS client function to operate as a
remote agent. This example demonstrates how to register an
application, similar to a licensing
facility. |
|
demoServer |
Provides an MIS server function to operate as a
remote agent. This example provides support required for the
demoregistry and diskInfo examples. |
|
diskInfo |
Demonstrates behavior to get information from a
process that is outside the MIS. |
A.9 Miscellaneous
Examples
The examples listed in TABLE A-12
are in subdirectories of the /opt/SUNWconn/em/src directory.
TABLE A-12 Miscellaneous
API Examples
|
app_api |
Using the application-to-application
API |
|
grapher_api |
Using the grapher API |
|
topo_api |
Using the topology API |
|
viewer_api |
Using the viewer API |
|
mpa_pdm |
Developing an MPA or PDM |
|
nci |
Sending Nerve Center requests |
|
nn |
Getting and setting nicknames |
|
objop |
Creating and modifying managed objects by using
the em_objop
utility |
|
odt |
Developing object behaviors |
|
overload |
Using the overload control mechanism of the CMIP
MPA |
|
sql |
Generating reports by using the structured query
language (SQL) |