Bug 833104 - CLI - Unable to get resources from resource group
Summary: CLI - Unable to get resources from resource group
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI
Version: 4.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: RHQ Project Maintainer
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-18 15:07 UTC by Filip Brychta
Modified: 2012-06-19 09:34 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-06-19 09:34:20 UTC
Embargoed:


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

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


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