Listing all properties for a class/classes in APIs

In the past I have wanted to be able to list all the properties for a class and then use that list to create an export.  In the past I would use dmctl to get a list of the properties and then incorporate that list into my program/script.  Recently I discovered a class that has operations that does this for me.  I was able to use this to meet a request to extract all the properties and values for all the instrumentation for passing to another system.  I used this class to create an adapter that accomplished this.  The code is below:

 

/*

* Copyright 2015 by EMC Corporation ("EMC"). All rights reserved.

*

* UNPUBLISHED CONFIDENTIAL AND PROPRIETARY PROPERTY OF EMC. The

* copyright notice above does not evidence any actual or intended

* publication of this software. Disclosure and dissemination are

* pursuant to separate agreements. Unauthorized use, distribution

* or dissemination are strictly prohibited.

*

* ic-get-all-instrumentation.asl

*/

 

default dataFileName      = "outputData-" . numeric(time()) . ".dat";

default domainManagerName = "INCHARGE-DEFAULT";

default extStatusDict     = "";

 

print("dataFileName: " . dataFileName);

print("domainManagerName: " . domainManagerName);

print("extStatusDict: " . extStatusDict);

 

START {

    .. eol

} do {

/*

* Get the handle to the status StringDictionary and set the initial status

*/

    extStatusDict  = self->object("GA_StringDictionary", extStatusDict);

    extStatusDict->insert(domainManagerName, "started");

/*

* Creat the output file

*/   

    outputFile     = self->object("ACT_File", "perfDataACTFile-" . domainManagerName);

    if (outputFile->isNull()) {

        outputFile = self->create("ACT_File", "perfDataACTFile-" . domainManagerName);

    }

    outputFile->fileName = dataFileName;

/*

* Create the topology source factory so that we can use the getClassSchema operation which will give us all the properties for the object

*/

    dxaObj = object("DXA_TopologySourceFactory", "DXA-TopologySourceFactory");

    if (dxaObj->isNull()) {

       dxaObj = create("DXA_TopologySourceFactory", "DXA-TopologySourceFactory");

    }

/*

* Process each instrumentation object

*/

    classPropTable = table();

    foreach instrName (getInstances("ICIM_Instrumentation")) {

        instrObj                      = object(instrName);

        partObj                       = instrObj->Instruments;

        nodeObj                       = partObj->getSystem();

        className                     = instrObj->CreationClassName;

/*

* If the schema for the class has not already been retrieved and stored do so now

*/

        if (!defined(classPropTable[className])) {

            classPropTable[className] = list();

            classPropText             = dxaObj->getClassSchema(className);

            classPropList             = list();

            classPropList             = PARSE_CLASS_SCHEMA(classPropText);

            classPropTable[className] = classPropList;

        }

/*

* Write the instrumentation start and the records for each property

*/

        outputFile->writeln("<instr device=" . nodeObj->Name . " devtype=" . nodeObj->CreationClassName . " part=" . partObj->Name . " parttype=" . partObj->CreationClassName . ">");

        foreach propEntry (classPropTable[className]) {

            propName                  = propEntry[0];

            propType                  = propEntry[1];

            propDescr                 = propEntry[2];

            outputFile->writeln("\t<prop metric=" . propName . " type=" . propType . ">" . instrObj->*propName . "</prop>")?IGNORE;

        }

        outputFile->writeln("</instr>");

    }

/*

* Set the completed status

*/

    extStatusDict->insert(domainManagerName, "completed");

}

/*

* Parses the returned string from getClassSchema opertion and returns a list of the properties

*/

PARSE_CLASS_SCHEMA(classSchemaText) {

    input = classSchemaText;

    local classPropList = list();

 

    rep(PARSE_ONE_PROPERTY)

} do {

    return classPropList;

}

 

PARSE_ONE_PROPERTY {

    local stringValue = "";

   

    propName:  word

    propType:  integer

    propDescr: rep(notany("\n"))

               "\n"

} do {

   classPropList += list(propName, propType, propDescr);

}

 

The customer that I was working with wanted to explore the extraction of all the performance data for import into a DB.  I am not sure how practical this approach is but this script does work.

 

I there are questions please let me know.