Bug 1309481 - Remote API is missing ability to retrieve and revert historic plug-in and resource configuration
Remote API is missing ability to retrieve and revert historic plug-in and res...
Status: CLOSED ERRATA
Product: JBoss Operations Network
Classification: JBoss
Component: CLI (Show other bugs)
JON 3.3.5
Unspecified Unspecified
high Severity high
: DR01
: JON 3.3.6
Assigned To: Josejulio Martínez
Filip Brychta
: Triaged
Depends On: 1309480
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-17 18:00 EST by Larry O'Leary
Modified: 2016-07-27 11:32 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1309480
Environment:
Last Closed: 2016-07-27 11:32:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2169271 None None None 2016-02-17 18:21 EST

  None (edit)
Description Larry O'Leary 2016-02-17 18:00:18 EST
This issue also applies to 3.3.5.

+++ This bug was initially created as a clone of Bug #1309480 +++

Description of problem:
ConfigurationManagerRemote interface does not expose a method to apply/revert configuration from configuration history/updates.

This prevents a client from using the remote API to manage configuration for a resource and its connection settings based on prior configuration updates.

Version-Release number of selected component (if applicable):
3.1.2

How reproducible:
Always

Steps to Reproduce:
1.  Import a resource.
2.  Make configuration changes.
3.  Use the remote API to retrieve the resource's plug-in configuration updates:

> // Get all plugin configuration updates for the Resource myResource
> var myConnectionHistory = myResource.getPluginConfigurationUpdates();


Actual results:
myConnectionHistory contains a list of ids but there is no way to get the configuration update record showing the date/time of the update along with who applied it and its status along with the actual Configuration object so that it can be reapplied to the resource.

Expected results:
myConnectionHistory should contain a list of PluginConfigurationUpdate which includes all the details of the update including Configuration.

Additionally, it should be possible to pass a resource ID and configuration update ID to a method of ConfigurationManager to have the server reapply the desired configuration update. This would be similar to the Rollback function provided in the configuration history pages of the UI.

Additional info:
It appears that some/all of this functionality is exposed in the local interface so perhaps this is just a matter of moving local methods over to the remote interface.
Comment 1 Josejulio Martínez 2016-02-23 14:37:59 EST
commit 94e3588359b5d4d6fa4cb9b57c7c17b2a533b56f
Author: Josejulio Mart\u00ednez <jmartine@redhat.com>
Date:   Mon Feb 22 19:16:48 2016 -0600

    Bug 1309481 - Remote API is missing ability to retrieve and revert historic plug-in and resource configuration
    
    Exposed to remote API the following methods of ConfigurationManager.
    
    findPluginConfigurationUpdatesByCriteria
    findResourceConfigurationUpdatesByCriteria
    rollbackPluginConfiguration
    rollbackResourceConfiguration
Comment 2 Josejulio Martínez 2016-02-23 14:39:15 EST
Exposed some methods of ConfigurationManager, also there already were some helpful methods: 

# Methods already exposed.
## Current plugin/resource configuration.
- getPluginConfiguration
- getResourceConfiguration

## Update plugin/resource configuration
- updatePluginConfiguration
- updateResourceConfiguration

# Newly Exposed methods
## Find plugins/resource updates.
- findPluginConfigurationUpdatesByCriteria
- findResourceConfigurationUpdatesByCriteria

## Rollback plugin/resource to configuration
- rollbackPluginConfiguration
- rollbackResourceConfiguration


#Sample usage

var res_id = 10004;
// Fetch current configuration.
ConfigurationManager.getResourceConfiguration(res_id);

// Fetch all configurations for resource.
var criteria = new ResourceConfigurationUpdateCriteria();
criteria.addFilterResourceIds([new java.lang.Integer(res_id)]);
criteria.fetchConfiguration(true);
var config_updates = ConfigurationManager.findResourceConfigurationUpdatesByCriteria(criteria);

// Newest configuration.
config_updates.get(config_updates.size());
// Rollback to previous configuration (if any)
if (config_updates.size() > 1) {
	ConfigurationManager.updateResourceConfiguration(res_id, config_updates.get(config_updates.size()-2).getConfiguration());
	// or...
	// ConfigurationManager.rollbackResourceConfiguration(res_id, config_updates.get(config_updates.size()-2).getId());
}
Comment 3 Josejulio Martínez 2016-02-23 19:43:28 EST
There is a mistake on the Sample usage,

Instead of 
  config_updates.get(config_updates.size());
Should be
  config_updates.get(config_updates.size()-1);
Comment 4 Mike McCune 2016-03-28 18:47:43 EDT
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune@redhat.com with any questions
Comment 6 Simeon Pinder 2016-06-17 21:11:40 EDT
Moving to ON_QA as available to test with JON 3.3.6 DR01 brew build:
https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=499890
Comment 7 Filip Brychta 2016-06-28 12:12:49 EDT
All added functions are working.
Only problem I found is that it's not possible to get actual plugin configuration from PluginConfigurationUpdate.

Following script will throw an exception:
var criteria = new PluginConfigurationUpdateCriteria();
criteria.addFilterResourceIds([new java.lang.Integer(10002)]);
criteria.fetchConfiguration(true);
criteria.addSortCreatedTime(PageOrdering.ASC)
var configUpdatesPre = ConfigurationManager.findPluginConfigurationUpdatesByCriteria(criteria);
pretty.print(configUpdatesPre)
var conf = configUpdatesPre.get(0).getConfiguration();
pretty.print(conf)

Caused by: javax.ejb.EJBException: [Warning] org.hibernate.LazyInitializationException: could not initialize proxy - no Session
	at org.rhq.enterprise.server.remote.RemoteSafeInvocationHandler.invoke(RemoteSafeInvocationHandler.java:122)
	at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:967)
	at org.jboss.remoting.transport.servlet.ServletServerInvoker.processRequest(ServletServerInvoker.java:416)


The exception is only visible when criteria.fetchConfiguration(true); is used and there already are some PluginConfigurationUpdates available.
Comment 8 Josejulio Martínez 2016-06-28 12:36:51 EDT
If you need to fetch the configuration from PluginConfigurationUpdates, you will also need to fetch the resource:

 criteria.fetchResource(true);

It seems to be needed in order to correctly fetch the Configuration, ResourceConfigurationUpdates does fetch the Resource by default.
Comment 9 Filip Brychta 2016-06-29 04:11:05 EDT
It's working correctly with criteria.fetchResource(true);
Comment 10 errata-xmlrpc 2016-07-27 11:32:45 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-1519.html

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