HP-UX CMGR A.02.00 Administrator's and Developer's Guide
4 Developing a CMGR Plug-in
This chapter describes how to extend CMGR’s functionality by developing a new
element handler and a new variable validation function for CMGR.
4.1 Developing an Element Handler
CMGR uses Perl modules to process CMGR template elements. The rules for writing
a handler for a new element are:
1. Select a lower-case name for the new element. For “Example Plug-in” (page 41),
we chose the element <myconf>.
2. Update CMGR’s template Document Type Definition (DTD) with the new element.
The DTD file is /etc/opt/hpcmgr/templates/cmgr.dtd.
• Create an <!ELEMENT> entry for the new element and add the allowable child
elements for the new element (such as data, help, success, and failure).
• Define the attributes (such as if and id, allowed for the new element with
<!ATTLIST>.
• Add the new element to the allowable child elements for the head, prologue,
and body elements.
3. Create or update an existing template with the new element.
4. The file, module name, and function names for the handler are based upon the
XML element name (element_name) that it implements:
• The handler must be included in a Perl module. The module name for the
handler must be “Cmgr::Element_name” where Element_name has the
first letter capitalized.
• The filename for the module is /opt/hpcmgr/lib/Cmgr/
Element_name.pm where Element_name has the first character capitalized.
• The handler function name is “process_element_name”. Note that the
first character of the element name is not capitalized.
For example, if the element is <myconf>, then the module filename is /opt/
hpcmgr/lib/Cmgr/Myconf.pm, the module name is Cmgr::Myconf and the
handler function name is process_myconf().
5. Write the handler function. The handler function must accept $context (as the
first parameter) and $node (as the second parameter). The $context parameter
is a handle for accessing template variables, and the $node parameter is a handle
4.1 Developing an Element Handler 39