11.4. Available Utility and Sample Scripts

Several scripts are provided that supply additional functionality, like simplified functions for parsing search results, deploying bundles, or managing drift. These utility scripts add functions without performing any concrete task. They are available as a reference for and extension to custom scripts. These example functions can be copied into a script file or can be loaded before a script is run, as in Section 6.1, “About Script Dependencies and Exporting Functions”.
A couple of scripts are available that both provide additional functions (for reference or ease of use) and also perform management tasks when run. This scripts can be used directly to manage resources, without having to write a custom script.
IMPORTANT
Utility and sample scripts have not been extensively tested and may not be updated between releases. These are included for convenience and for real-life, complete examples of writing server scripts.
Test these scripts for quality and consistency within your environment.

Table 11.1. Utility and Sample Scripts

Script Description Location
CommonJS Module Utility Scripts
util.js
Defines search functions for iterating through an array of object (foreach), to return the first matching object (find) or to return all matching objects (findAll). It also has functions for converting information from JavaScript hashes to JBoss ON configuration objects and back.
The same as the samples/util.js script, but written as a CommonJS module.
cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/modules/
bundles.js
Defines functions to create and deploy a bundle, create a bundle destination, or get information on supported base directories for a resource.
The same as the samples/bundles.js script, but written as a CommonJS module.
cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/modules/
drift.js
Defines functions to create and diff snapshots, get a definition, and show the history for a resource or specific file.
The same as the samples/drift.js script, but written as a CommonJS module.
cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/modules/
jbossas.js
Defines several functions to manage EAP 6 / AS 7 resources, including deploying web applications and managing EAP clusters.
The same as the samples/deploy-to-and-restart-JBAS.js and samples/add-as7-standalone-server-to-cluster.js scripts, but combined and written as a CommonJS module.
cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/modules/
Utility Scripts
util.js Defines search functions for iterating through an array of object (foreach), to return the first matching object (find) or to return all matching objects (findAll). It also has functions for converting information from JavaScript hashes to JBoss ON configuration objects and back. cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/
measurement_utils.js Defines functions to enable, disable, or update metric schedules. cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/
bundles.js Defines functions to create and deploy a bundle, create a bundle destination, or get information on supported base directories for a resource. cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/
drift.js Defines functions to create and diff snapshots, get a definition, and show the history for a resource or specific file. cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/
Sample Scripts
add-as7-standalone-server-to-cluster.js Defines a series of functions that add a specified AS 7 to a cluster. cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/
deploy-to-and-restart-JBAS.js Defines two functions to deploy new content to EAP servers and to update existing content. With the proper variables set, this script can be run directly to deploy content and restart the given app server. cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/
fix-bundle-deployment.js An example server-side alert script that reverts a bundle deployment to a specified version. serverRoot/jon-server-3.3/jbossas/server/default/deploy/rhq.ear/rhq-downloads/cli-alert-scripts/