6. Resource Configuration

There are two areas of resource configuration:
  • The plug-in configuration. In the web UI, this is called the connection setting; it is the information which the agent uses to discover and connect to the resource, such as a PID file path or a port number.
    Every resource has some kind of plug-in configuration.
  • Resource configuration. Configuration properties are drawn from the configuration files for a resource, such as .conf or .xml. The configuration files and properties that are exposed within JBoss ON are defined in the plug-in descriptor.
    Resource configuration is optional, and many resources do not support configuration editing or only expose a subset of possible properties.

Note

When changing the configuration for a resource, it is simplest to use the configuration editor with a proxy resource, as in Example 7, “Changing Configuration Properties”.
The configuration editor is only available with the interactive CLI; for running an alert script or script automatic changes to resource configuration, the remote API can be used directly.

6.1. Viewing Current Configuration

Plug-in (connection settings) configuration and resource configuration are both defined per resource type, in the resource type's plug-in descriptor.
The get*ConfigurationDefinitionForResourceType methods can display the descriptor-defined templates used for the resource type's configuration. These are the configuration properties available to every resource of that type.

Example 9. Viewing Plug-in Configuration for a Resource Type

rhqadmin@localhost:7080$ var res = ResourceTypeManager.getResourceTypeByNameAndPlugin('Linux','Platforms') //get the resource type ID

rhqadmin@localhost:7080$ ConfigurationManager.getPluginConfigurationDefinitionForResourceType(res.id) //use the type ID to search for the resource type template

ConfigurationDefinition:
         configurationFormat: Structured
             defaultTemplate: ConfigurationTemplate[id=10443, name=default, config=Linux]
                 description:
            groupDefinitions: [PropertyGroupDefinition[id=10058, name=Content], PropertyGroupDefinition[id=10059, name=Event Logs]]
                          id: 10437
                        name: Linux
        nonGroupedProperties: []
         propertyDefinitions: {logs=PropertyDefinitionList[id=11792, name=logs, config=Linux, group=Event Logs], metadataCacheTimeout=SimpleProperty[metadataCacheTimeout] (Type: INTEGER)(Group: Content), enableContentDiscovery=SimpleProperty[enableContentDiscovery] (Type: BOOLEAN)(Group: Content), enableInternalYumServer=SimpleProperty[enableInternalYumServer] (Type: BOOLEAN)(Group: Content), yumPort=SimpleProperty[yumPort] (Type: INTEGER)(Group: Content)}
           	  templates: {default=ConfigurationTemplate[id=10443, name=default, config=Linux]}
The propertyDefinitions parameter contains the information about the configuration properties that can be set, including details about the configuration property setup. For example, for the event logs configuration:
logs=[id=11792, name=logs, config=Linux, group=Event Logs]
The property name is logs, and the type of property is a list, PropertyDefinitionList. The property list ID is 11792, though not every type of property has a template ID. The event log properties are organized together in the Event Logs group.
The cache timeout property has a slightly different configuration. This is a simple property type (SimpleProperty), and the expected value is given in the Type: element. The group for the property is Content.
metadataCacheTimeout=SimpleProperty[metadataCacheTimeout] (Type: INTEGER)(Group: Content)
Group settings for a property are mainly used to create a logical organization in the web UI. For the event logs configuration, all of the members in the properties list belong to the group, and only those values. For the cache timeout, it belongs to the content group but other, discrete properties also belong to the group, so the way the group is defined is different.
The resource configuration template can be retrieved similarly to retrieving the plug-in configuration template.

Example 10. Viewing the Configuration Properties for the Resource Type

rhqadmin@localhost:7080$ var res = ResourceTypeManager.getResourceTypeByNameAndPlugin('Samba Server', 'Samba') //get the resource type ID

rhqadmin@localhost:7080$ ConfigurationManager.getResourceConfigurationDefinitionForResourceType(res.id)
ConfigurationDefinition:
         configurationFormat: Structured
             defaultTemplate: ConfigurationTemplate[id=11123, name=default, config=Samba Server]
                 description:
            groupDefinitions: [PropertyGroupDefinition[id=10905, name=Basic Configurations], PropertyGroupDefinition[id=10906, name=Security], PropertyGroupDefinition[id=10907, name=Printing], PropertyGroupDefinition[id=10908, name=Active Server Directory]]
                          id: 11087
                        name: Samba Server
        nonGroupedProperties: []
         propertyDefinitions: {winbind enum groups=SimpleProperty[winbind enum groups] (Type: BOOLEAN)(Group: Active Server Directory), winbind separator=SimpleProperty[winbind separator] (Type: STRING)(Group: Active Server Directory), cups options=SimpleProperty[cups options] (Type: STRING)(Group: Printing), workgroup=SimpleProperty[workgroup] (Type: STRING)(Group: Basic Configurations), encrypt passwords=SimpleProperty[encrypt passwords] (Type: BOOLEAN)(Group: Security), winbind enum users=SimpleProperty[winbind enum users] (Type: BOOLEAN)(Group: Active Server Directory), security=SimpleProperty[security] (Type: STRING)(Group: Security), template shell=SimpleProperty[template shell] (Type: STRING)(Group: Active Server Directory), password=SimpleProperty[password] (Type: PASSWORD)(Group: Active Server Directory), load printers=SimpleProperty[load printers] (Type: BOOLEAN)(Group: Printing), username=SimpleProperty[username] (Type: STRING)(Group: Active Server Directory), realm=SimpleProperty[realm] (Type: STRING)(Group: Active Server Directory), idmap gid=SimpleProperty[idmap gid] (Type: STRING)(Group: Active Server Directory), server string=SimpleProperty[server string] (Type: STRING)(Group: Basic Configurations), controller=SimpleProperty[controller] (Type: STRING)(Group: Active Server Directory), enableRecycleBin=SimpleProperty[enableRecycleBin] (Type: BOOLEAN)(Group: Basic Configurations), idmap uid=SimpleProperty[idmap uid] (Type: STRING)(Group: Active Server Directory)}
                   templates: {default=ConfigurationTemplate[id=11123, name=default, config=Samba Server]}
The property values for a specific resource can be viewed using the get*Configuration methods.

Note

If you are only viewing the resource configuration and are running the interactive CLI, this is done more easily using a proxy resource, as in Example 7, “Changing Configuration Properties”.

Example 11. Viewing a Resource's Configuration Settings

rhqadmin@localhost:7080$ criteria = new ResourceCriteria(); // find the resource
rhqadmin@localhost:7080$ criteria.addFilterResourceTypeName('Samba')
rhqadmin@localhost:7080$ criteria.addFilterAgentName('agent1.example.com')
rhqadmin@localhost:7080$ var resource = ResourceManager.findResourcesByCriteria(criteria);

rhqadmin@localhost:7080$ ConfigurationManager.getResourceConfiguration(resource.get(0).id)
Configuration [12082] - Loaded from Augeas at Wed May 02 12:04:24 EDT 2012
  winbind separator = null
  winbind enum groups = null
  cups options = null
  workgroup = null
  winbind enum users = null
  encrypt passwords = null
  security = null
  template shell = null
  password = null
  load printers = null
  username = null
  realm = null
  idmap gid = null
  server string = null
  controller = null
  enableRecycleBin = false
  idmap uid = null

6.2. Changing Simple Configuration Properties

The way that a configuration property is edited depends on the type of property, whether it is simple, list, or map. The process for changing configuration is the same for both plug-in configuration properties and resource configuration properties.
The steps in this script:
  1. Search for the resource.
  2. Create a configuration object.
  3. Set the new property value. The method to set the property value depends on the format of the property. In this case, it uses setSimpleValue since this is a simple property. For a simple property, the value is set by passing ('property','value').
  4. Run an update operation for the resource. For a resource configuration update, the method is updateResourceConfiguration. For a plug-in configuration update, it is updatePluginConfiguration.

Example 12. Changing a Simple Property

// find the resource
criteria = new ResourceCriteria(); 
criteria.addFilterResourceTypeName('Samba')
// this only updates the resource for this specific agent
criteria.addFilterAgentName('agent1.example.com')
var resources = ResourceManager.findResourcesByCriteria(criteria);

//get current configuration
var config = ConfigurationManager.getResourceConfiguration(resources.get(0).id);

//set the new value in the form 'property', 'value'
config.setSimpleValue("workgroup","example")

// run the update operation
ConfigurationManager.updateResourceConfiguration(resources.get(0).id,config)