Bug 833104

Summary: CLI - Unable to get resources from resource group
Product: [Other] RHQ Project Reporter: Filip Brychta <fbrychta>
Component: CLIAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED NOTABUG QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.4CC: hrupp, jshaughn
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-19 09:34:20 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:
Embargoed:
Attachments:
Description Flags
creatingResGroupsAndAddingMembers.js none

Description Filip Brychta 2012-06-18 15:07:14 UTC
Created attachment 592686 [details]
creatingResGroupsAndAddingMembers.js

Description of problem:
Unable to get resources from resource group using CLI. 

Version-Release number of selected component (if applicable):
Version: 3.1.0.GA
Build Number: b575169:a53e41e

How reproducible:
Always

Steps to Reproduce:
1. import at least one Linux platform to JON inventory
2. ./rhq-cli.sh -u rhqadmin -p rhqadmin -f /home/jon/js-files/creatingResGroupsAndAddingMembers.js
3. check output
  
Actual results:
Number of resources in the group doesn't match number of added resources to the group. Added: 1, in group: 0

Expected results:
No errors

Additional info:
Resource group is created successfully and Linux platform resource is correctly added (visible via GUI). Double checked that group id used in creatingResGroupsAndAddingMembers.js is correct. Haven't found any documentation or example so my script could be incorrect, please check that first.

Comment 1 Jay Shaughnessy 2012-06-18 16:26:17 UTC
The problem here is with the script. Or, rather the expectations of the script.


** This wait is unnecessary, the group additions are done synchronously
    // just to be sure
    sleep(5*1000);

** This is the problem.  getResourceGroup does not grab the lazy-loaded member
** data.  That is a slow thing to do so you have to ask for that data explicitly.
    // check that resources were added to the group
    var group = ResourceGroupManager.getResourceGroup(rg.id);
    var groupRes = group.getExplicitResources();

** Try changing to:

    var c = new ResourceGroupCriteria()
    c.addFilterId(rg.id)
    c.fetchExplicitResources(true)
    var group = ResourceGroupManager.findResourceGroupsByCriteria(c).get(0)
    var groupRes = group.getExplicitResources();


This should work as expected. Please close if satisfied.

Comment 2 Filip Brychta 2012-06-19 09:34:20 UTC
Jay's version works. Thank you. Closing it as NOTABUG