Bug 1375587

Summary: CLI examples for creating and editing Dynagroup definitions are incorrect
Product: [JBoss] JBoss Operations Network Reporter: dsteigne
Component: DocumentationAssignee: mmurray
Status: CLOSED CURRENTRELEASE QA Contact: Vojta Prusa <vprusa>
Severity: high Docs Contact:
Priority: high    
Version: JON 3.3.6CC: vprusa
Target Milestone: GA   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-16 03:43:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description dsteigne 2016-09-13 13:50:20 UTC
Document URL: 
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Operations_Network/3.3/html/Writing_JON_Command-Line_Scripts/sect-Resources_and_Groups.html#Creating_and_Editing_Dynagroups

Section Number and Name: 

12.4.3. Creating and Editing Dynagroups

Describe the issue: 

On the create script setExpression replaces the existing, so will only use the last one, it should be something more like:

// create the new dynagroup
var dynaGroupDef = new GroupDefinition("Linux Group");
var expr = "resource.type.name=Linux" + "\n" + "resource.type.category=Platform"
dynaGroupDef.setExpression(expr);
var def = GroupDefinitionManager.createGroupDefinition(dynaGroupDef);

// calculate the group members
GroupDefinitionManager.calculateGroupMembership(def.getId());

For the editing script, the get is incorrect and errors and the setExpression needs to be the desired full expression not just the additional, for example:

// search for the dynagroup
criteria = new ResourceGroupDefinitionCriteria()
criteria.addFilterName("Linux Group");
var orig = GroupDefinitionManager.findGroupDefinitionsByCriteria(criteria)

// get the dynagroup entry
var originalGroupDef = orig.get(0)

// add the new expression
var expr = "resource.type.name=Linux" + "\n" + "resource.type.category=Platform" + "\n" + "resource.availability=UP"
originalGroupDef.setExpression(expr);
var def = GroupDefinitionManager.updateGroupDefinition(originalGroupDef);

// calculate the group members
GroupDefinitionManager.calculateGroupMembership(def.getId());




Suggestions for improvement: 

Additional information:

Comment 5 Vojta Prusa 2017-02-06 15:36:29 UTC
Suggested changes match the stage doc.