Configuring Profile Properties and Standard Actions

This article provides information about probe profile standard actions and properties.
uimpga-ga
This article provides information about probe profile standard actions and properties.
Contents
Defining Profile Actions
There are three standard profile options and actions that you can use for managing probe profiles in the probe configuration UI.
  • Add Profile
  • Delete Profile
  • Verify Selection
The following image shows how these actions are displayed in the probe configuration GUI.
Profile Actions.png
The following code is taken from the local_dirscan probe example. This code presents an
Add directory Resource
option when you click Options (...) next to a robot name. After you add a directory resource, click the
Action
button to see
Verify Directory Configuration
.
Delete Profile
appears when you click Options (...) next to a profile name.
... @Override public void addDefaultProbeConfigurationToGraph() { ElementDef resDef = ElementDef.getElementDef("RESOURCE"); resDef.addStandardAction(IProbeResourceTypeInfo.StandardActionType.DeleteProfileAction); resDef.addStandardAction(IProbeResourceTypeInfo.StandardActionType.VerifySelectionAction, "Verify Directory Configuration"); resDef.addStandardAction(IProbeResourceTypeInfo.StandardActionType.AddProfileActionOnProbe, "Add directory Resource"); ... }
Defining and Reading Standard Profile Properties
There are several standard profile properties required by many probes. The following illustration shows an example of profile properties required for the mock_vm_host probe.
Add New Profile Properties.png
The displayed properties was realized by the following code in the addDefaultProbeConfigurationToGraph() in the mock_vm_host example:
@Override public void addDefaultProbeConfigurationToGraph() { // Set the properties that will be available when a new profile is created in the probe configuration UI CtdPropertyDefinitionsList profilePropDefs = CtdPropertyDefinitionsList.createCtdPropertyDefinitionsList("RESOURCE", getGraph()); profilePropDefs.addStandardIdentifierProperty(); profilePropDefs.addStandardHostProperty(); profilePropDefs.addStandardPortProperty(); profilePropDefs.addStandardUserNameProperty(); profilePropDefs.addStandardPasswordProperty(); profilePropDefs.addStandardAlarmMessageProperty(); profilePropDefs.addStandardIntervalProperty(); profilePropDefs.addStandardActiveProperty(); super.addDefaultProbeConfigurationToGraph(); }
You can later read the values of these standard properties through the ResourceConfiguration object as shown below:
public IInventoryDataset getUpdatedInventory(ResourceConfig resourceConfig, IInventoryDataset previousDataset) throws NimException, InterruptedException { String host = resourceConfig.getResourceProperty("host"); int port = Integer.parseInt(resourceConfig.getResourceProperty("port")); String username=resourceConfig.getResourceProperty("user"); ... }
As the previous sample code shows, to read a standard property you must know the key by which it is saved. The following table lists all the standard properties and how to read them.
Name
CtDPropertyDefinitionsList method
To read via ResourceConfig
Host
addStandardHostProperty()
getResourceProperty(“host”)
Port
addStandardPortProperty()
getResourceProperty("port")
Username
addStandardUserNameProperty()
getResourceProperty("user")
Password
addStandardPasswordProperty()
getResourceProperty("pass")
SSL
addStandardSSLCheckboxProperty()
getResourceProperty("ssl")
Active
addStandardActiveProperty()
getResourceProperty("active")
ProfileID
addStandardIdentifierProperty()
getResourceProperty("id")
Interval
addStandardIntervalProperty()
getResourceProperty("interval")
Alarm
addStandardAlarmMessageProperty()
getResourceProperty("msg")
Defining and Reading Custom Profile Properties
The following illustration shows an example of a custom profile property named the "Target Directory" for the local_dirscan probe.
Add Directory Resource Properties.png
This property is defined using the following code:
public void addDefaultProbeConfigurationToGraph() { CtdPropertyDefinitionsList profilePropDefs = CtdPropertyDefinitionsList.createCtdPropertyDefinitionsList("RESOURCE", getGraph()); profilePropDefs.addStringPropertyUsingEditField("target_directory", "Target Directory", "C:\\tmp"); profilePropDefs.setCfgPathname("target_directory", "properties/target_directory"); ... super.addDefaultProbeConfigurationToGraph(); }
You can later read the values of your custom properties through the ResourceConfiguration object:
String targetDir = resourceConfig.getResourceProperty("target_directory");
Defining and Reading Probe Setup Properties
A Probe Setup property is a global property configured for the probe; not for a specific profile. Probe Setup properties display when you click the probe name in the navigation tree. The following illustration shows how the
Log Level
Setup property appears in the probe configuration GUI.
Probe Setup Property.png
You add a Probe Setup property using the method addDefaultProbeConfigurationToGraph() with the following code:
public void addDefaultProbeConfigurationToGraph() { ... // add SETUP properties CtdPropertyDefinitionsList setupPropDefs = CtdPropertyDefinitionsList.createCtdPropertyDefinitionsList("SETUP", getGraph()); // adds the traversal depth property, with a default value setupPropDefs.addIntegerPropertyUsingEditField(TRAVERSAL_DEPTH_PROP, "Directory Traversal Depth", 4); ... super.addDefaultProbeConfigurationToGraph(); }
You read the value for this property in getUpdatedInventory() as follows:
int traversalDepth = NimConfig.getInstance().getValueAsInt("/setup", TRAVERSAL_DEPTH_PROP, 4);
Reading and Decoding the Standard Password Property
The standard password property is encrypted by default. To decrypt the password, use the com.nimsoft.nimbus.NimSecurity class:
String passwordEncoded = resourceConfig.getResourceProperty("pass"); String passwordDecoded = new NimSecurity().decryptUTF8(PROBE_NAME, passwordEncoded);
Adding a Drop-Down List
The ability to create a custom drop-down list is contained in the underlying libraries included with the Probe-SDK. Import the following classes to your main probe class.
import com.nimsoft.ids.ctd.base.CtdOptionList;
import com.nimsoft.ids.ctd.ui.CtdOption;
import com.nimsoft.ids.ctd.ui.definitions.CtdDropDownDefinition;
import com.nimsoft.pf.common.CtdBuilderUtils;
These classes are included in the Probe-SDK with the pf-common and ctdgraph libraries.
Add a drop-down list as shown in the following example implementation of addDefaultProbeConfigurationToGraph().
public void addDefaultProbeConfigurationToGraph() {
    // Set the properties that will be available when a new profile is created in the probe configuration UI
    CtdPropertyDefinitionsList profilePropDefs = CtdPropertyDefinitionsList.createCtdPropertyDefinitionsList("RESOURCE", getGraph());
   
    // Create the option list for the drop down select and add to graph.
    // The CtdOptionList must be added to the graph AND the CtdDropDownDefinition or it wont display in UI
    CtdOption myOptions[] = new CtdOption[] {
            new CtdOption("option_key_1","option_label_1"),
            new CtdOption("option_key_2","option_label_2"),
            new CtdOption("option_key_3","option_label_3")};
    CtdOptionList optionList = CtdOptionList.CtdOptionListBuilder.builder().setName("MyOptionList").setOptions(myOptions).build();
    getGraph().addOptionList(optionList);
    // Create the drop down using the option list from above
    CtdDropDownDefinition myDropDown = CtdBuilderUtils.buildDropDownDef("my_drop_down", "My Drop down", optionList);
    myDropDown.setDefaultValue("option_key_2");
    myDropDown.setRequired(true);
    // Add the drop down to the property definition list
    profilePropDefs.add(myDropDown);
   
    // Add any other standard or custom properties required for configuration
    ...
    // Finally, make the call to update the default configuration and get these settings published to UIM so that they
    // appear correctly in the probe configuration UI
    super.addDefaultProbeConfigurationToGraph();
}