12.5. 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
.confor.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.
12.5.1. Viewing Current Configuration
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 12.12. 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]}logs=[id=11792, name=logs, config=Linux, group=Event Logs]
metadataCacheTimeout=SimpleProperty[metadataCacheTimeout] (Type: INTEGER)(Group: Content)
Example 12.13. 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]}get*Configuration methods.
Example 12.14. 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 = null12.5.2. Changing Simple Configuration Properties
- Search for the resource.
- Create a configuration object.
- 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').
- Run an update operation for the resource. For a resource configuration update, the method is
updateResourceConfiguration. For a plug-in configuration update, it isupdatePluginConfiguration.
Example 12.15. 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)

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.