Bug 816599 - Resource.getOperationHistories() returns no data
Resource.getOperationHistories() returns no data
Product: JBoss Operations Network
Classification: JBoss
Component: CLI (Show other bugs)
JON 3.1.0
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
Depends On:
  Show dependency treegraph
Reported: 2012-04-26 09:40 EDT by Viet Nguyen
Modified: 2012-05-08 15:33 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-04-30 10:40:02 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)
test case (558 bytes, text/javascript)
2012-04-26 09:41 EDT, Viet Nguyen
no flags Details

  None (edit)
Description Viet Nguyen 2012-04-26 09:40:49 EDT
Description of problem:

Version-Release number of selected component (if applicable):
JON 3.0.1.GA
CLI 4.2.0.JON.3.0.1.GA

How reproducible:

Steps to Reproduce:
1. schedule viewProcessList on a resource type="Linux"
2. call resource.getOperationHistories()
Actual results:
empty list

Expected results:

Additional info:
See attached test script
Comment 1 Viet Nguyen 2012-04-26 09:41:14 EDT
Created attachment 580480 [details]
test case
Comment 2 Lukas Krejci 2012-04-30 10:40:02 EDT
While this is slightly non-trivial to learn, the operation histories are not loaded along with the resource unless specifically asked for.

Also in your script you do:

var server = resources.get(0);

... schedule an operation on the server resource ...

var histories = server.getOperationHistories()

Unfortunately, this doesn't work like that. The resources you obtain from the server are not "connected" to the live data, so calling the getOperationHistories() method on the "server" resource WILL NOT query the RHQ server for the current state of that collection, but rather will return the histories AS THEY WERE, when the "server" resource was retrieved from the RHQ server (and btw, because the operation histories are NOT fetched with the resource by default, the list would be empty anyway).

To obtain the histories, you need to:

var historyCriteria = new ResourceOperationHistoryCriteria;
var histories = OperationManager.findResourceOperationHistoriesByCriteria(historyCriteria)
Comment 3 Lukas Krejci 2012-04-30 10:42:24 EDT
One other way to do it is to:

var resourceCriteria = new ResourceCriteria;
... setup the resource criteria to find the resources you want ...
var resources = ResourceManager.findResourcesByCriteria(resourceCriteria)

now you can:

var history = resources.get(0).operationHistories;
Comment 4 Viet Nguyen 2012-04-30 17:04:38 EDT
Thanks for the tips.  I tried both ways and were getting history objects back but the conguration object is null

var resourceCriteria = new ResourceCriteria;
var resources = ResourceManager.findResourcesByCriteria(resourceCriteria);

var histories = resources.get(0).getOperationHistories();
for(i=0; i<histories.size(); i++) {
	var config = histories.get(i).getResults();
Comment 5 Viet Nguyen 2012-04-30 17:30:02 EDT
Another word if I schedule operation X does getOperationHistories give me the ability to see X?
Comment 6 Lukas Krejci 2012-05-02 04:21:03 EDT
First the "results question":

Unfortunately using the resourceCriteria, you cannot specify that you want to fetch the results of the operations and so the results will always be empty if you use only ResourceCriteria object.

This is done to minimize the traffic and DB load. The workflow is supposed to be:
1) query the operation histories
2) loop through them, find the interesting one
3) query additional details on it

To get the results of the operation, you therefore need to ask the RHQ server again like:

var opHistCrit = new ResourceOperationHistoryCriteria;
... set up the opHistCrit to find the history entry you want, either using "addFilterId" method or any other "addFilter" method available ...
//if you want to fetch the parameters passed to the operation, you also need to

var histories = OperationManager.findResourceOperationHistoriesByCriteria(opHistCrit)

The name of the operation can be determined from:


This is always available on the history object, so you don't need to do any other queries to get at the name, even if you use just the ResourceCriteria to get the operation history on resources.
Comment 7 Viet Nguyen 2012-05-07 16:39:17 EDT
User error! it's working now.  I missed 1 very important call:

Comment 8 Mike Foley 2012-05-08 15:33:32 EDT
per BZ triage ... crouch, loleary, foley

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