Red Hat Training

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

6.2. Default Locations for Script Module Sources

The require statement loads a modules from an identified location to be used in a script. The JBoss ON CLI, CLI script, or server-side script can load a module from any of several locations, for both the local and remote sources.
The require line has the format sourceType:/path/moduleFile.
The default module locations are defined in the following list.
Modules Directory
Description — Loads the specified module file from a configured location on the local system. The CLI has a system property (RHQ_CLI_MODULES_DIR) which defines a default directory for modules.
The location can be set or changed by updating the rhq-cli-env.sh file or by setting it at the command line, as shown in the examples below:
RHQ_CLI_MODULES_DIR=/opt/rhq/modules
RHQ_CLI_MODULES_DIR=/opt/rhq/modules; bin/rhq-cli.sh
Available For — CLI
Local Filesystem
Loads the specified module file from an absolute path on the local system.
Format — file:/path
Example:
var myModule = require("file:/opt/jon/js-modules/myModule"); //This will load the module from a file called "myModule.js" in the /opt/jon/js-modules directory on the local filesystem.
Available For — CLI
JBoss ON Repository
Downloads the specified module file from the given JBoss ON repository. Because this connects to the server, a user must be logged into the JBoss ON server first.
Format — rhq://repositories/repo_name/module_name
Example:
var myModule = require("rhq://repositories/myRepo/myModule"); //This will load the module stored in the RHQ server repository "myRepo" called "myModule.js"
Available for — CLI, Server
JBoss ON Downloads
Downloads the specified module file from the downloads location on the JBoss ON server. JBoss ON could make some scripts available that can be used for alert server-side scripts or for the CLI. Because this connects to the server, a user must be logged into the JBoss ON server first.
Format — rhq://downloads/path/module_name
Example:
var myModule = require("rhq://downloads/script-modules/util"); //This will load the module stored in the RHQ server downloads section called "js/util.js"
Available For — CLI, Server