Bug 833104 - CLI - Unable to get resources from resource group
CLI - Unable to get resources from resource group
Product: RHQ Project
Classification: Other
Component: CLI (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
Depends On:
  Show dependency treegraph
Reported: 2012-06-18 11:07 EDT by Filip Brychta
Modified: 2012-06-19 05:34 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-06-19 05:34:20 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
creatingResGroupsAndAddingMembers.js (1.46 KB, application/javascript)
2012-06-18 11:07 EDT, Filip Brychta
no flags Details

  None (edit)
Description Filip Brychta 2012-06-18 11:07:14 EDT
Created attachment 592686 [details]

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:

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 12:26:17 EDT
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

** 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()
    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 05:34:20 EDT
Jay's version works. Thank you. Closing it as NOTABUG

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