Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

20.3. Reverting a Bundle

Reverting a bundle automatically moves a destination one step backward, from whatever version is currently deployed to whatever version was last deployed.
This is done only with the remote API, not using any functions from the bundles.js file.
The method to run is scheduleRevertBundleDeployment. This requires two interesting pieces of information. The first is the destination ID, which can be retrieved with a simple criteria search.
rhqadmin@localhost:7080$ var destinationName = "NewDestination"
rhqadmin@localhost:7080$ var destCrit = new BundleDestinationCriteria()
rhqadmin@localhost:7080$ destCrit.addFilterName(destinationName)

rhqadmin@localhost:7080$ var dest = BundleManager.findBundleDestinationsByCriteria(destCrit)
The next, and more interesting, piece of information is the deployment description. The description is what is passed to the revert method to help identify the deployment to revert.
rhqadmin@localhost:7080$ var depCrit = new BundleDeploymentCriteria()
rhqadmin@localhost:7080$ depCrit.addFilterDestinationName(destinationName)
rhqadmin@localhost:7080$ var deploy = BundleManager.findBundleDeploymentsByCriteria(depCrit)
rhqadmin@localhost:7080$ var dep = deploy.get(0);
rhqadmin@localhost:7080$ var description = dep.description;
The last part actually invokes the method.
rhqadmin@localhost:7080$ BundleManager.scheduleRevertBundleDeployment(dest.get(0).id, description, true)