Bug 1309481 - Remote API is missing ability to retrieve and revert historic plug-in and resource configuration
Summary: Remote API is missing ability to retrieve and revert historic plug-in and res...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: CLI
Version: JON 3.3.5
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: DR01
: JON 3.3.6
Assignee: Josejulio Martínez
QA Contact: Filip Brychta
URL:
Whiteboard:
Depends On: 1309480
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-17 23:00 UTC by Larry O'Leary
Modified: 2019-11-14 07:27 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1309480
Environment:
Last Closed: 2016-07-27 15:32:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2169271 0 None None None 2016-02-17 23:21:06 UTC
Red Hat Product Errata RHSA-2016:1519 0 normal SHIPPED_LIVE Critical: Red Hat JBoss Operations Network 3.3.6 update 2016-08-26 00:44:36 UTC

Description Larry O'Leary 2016-02-17 23:00:18 UTC
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 19:37:59 UTC
commit 94e3588359b5d4d6fa4cb9b57c7c17b2a533b56f
Author: Josejulio Mart\u00ednez <jmartine>
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 19:39:15 UTC
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-24 00:43:28 UTC
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 22:47:43 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 6 Simeon Pinder 2016-06-18 01:11:40 UTC
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 16:12:49 UTC
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 16:36:51 UTC
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 08:11:05 UTC
It's working correctly with criteria.fetchResource(true);

Comment 10 errata-xmlrpc 2016-07-27 15:32:45 UTC
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.