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.
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
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()); }
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);
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions
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
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.
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.
It's working correctly with criteria.fetchResource(true);
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