Bug 835464 - Changing Simple Configuration Properties example is incorrect
Changing Simple Configuration Properties example is incorrect
Status: CLOSED CURRENTRELEASE
Product: JBoss Operations Network
Classification: JBoss
Component: Documentation (Show other bugs)
JON 3.1.0
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Deon Ballard
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-26 05:04 EDT by Filip Brychta
Modified: 2014-10-23 08:29 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-07-20 12:51:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Filip Brychta 2012-06-26 05:04:45 EDT
Description of problem:
Changing Simple Configuration Properties example from http://docs.redhat.com/docs/en-US/JBoss_Operations_Network/3.1/html/Dev_Writing_JON_Command-Line_Scripts/config.html is incorrect.

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

//create the config object
var config = new Configuration();   <<<< [1]

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

// run the update operation
ConfigurationManager.updateResourceConfiguration(resource.id,config) <<<< [3]

Problems:
[1] new (empty) configuration is created, [2] one simple value is set, [3] old configuration is replaced by new one and all other values from old config are lost.

Test:
var config = ConfigurationManager.getResourceConfiguration(resource.id);
pretty.print(config);

output:
Configuration [19413] - null
  workgroup = example



Fixed example:

// 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)

Note You need to log in before you can comment on or make changes to this bug.