Deploying a bundle sends a bundle version to a specific destination. The cliRoot/rhq-remoting-cli-4.9.0.JON320GA/samples/modules/bundles.js file has a function, deployBundle, which makes this pretty easy, but you need to obtain some information first.
Get the ID for the destination. This searches for the destination by name.
rhqadmin@localhost:7080$ var destinationName = "New Destination"
rhqadmin@localhost:7080$ var destcrit = new BundleDestinationCriteria()
rhqadmin@localhost:7080$ destcrit.addFilterName(destinationName)
var dest = BundleManager.findBundleDestinationsByCriteria(destcrit)
rhqadmin@localhost:7080$ var destinationName = "New Destination"
rhqadmin@localhost:7080$ var destcrit = new BundleDestinationCriteria()
rhqadmin@localhost:7080$ destcrit.addFilterName(destinationName)
var dest = BundleManager.findBundleDestinationsByCriteria(destcrit)
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Then, get the ID number for the bundle version to deploy. Any version can be deployed, not just the most recent. This little script prints all of the versions for the bundle, with their ID numbers.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
With those two ID numbers, you can deploy the bundle. The first parameter is the destination ID, then the bundle version ID, then a configuration object if the bundle configuration has any tokens to realize. In this example, no properties are passed, so the value is null. Details about the configuration are in the comments in the bundles.js file and general configuration information is in Section 12.5.2, “Changing Simple Configuration Properties”.
rhqadmin@localhost:7080$ deployBundle(dest.get(0).id,10021,null,'my description',true)
BundleDeployment:
bundleVersion: BundleVersion[id=10021,name=null,version=null]
configuration: Configuration[id=15021]
ctime: 1337286719259
description: my description
destination: BundleDestination[id=10021, bundle=driftBundle, group=Linux Group - Thu May 10 15:10:28 EDT 2012, name=NewDestination]
duration: 0
errorMessage:
id: 10051
live: true
mtime: 1337286719259
name: Deployment [1] of Version [2.0] to [NewDestination]
replacedBundleDeploymentId:
resourceDeployments: [BundleResourceDeployment: bdd=[BundleDeployment[id=10051, name=Deployment [1] of Version [2.0] to [new-test]]], resource=[Resource[id=10001, uuid=535b3f54-0bd8-4653-bdd3-323ea69b98fd, type={Platforms}Linux, key=gs-dl585g2-01.rhts.eng.bos.redhat.com, name=server.example.com, parent=<null>, version=Linux 2.6.32-220.el6.x86_64]]]
status: Failure
subjectName: rhqadmin
tags:
rhqadmin@localhost:7080$ deployBundle(dest.get(0).id,10021,null,'my description',true)
BundleDeployment:
bundleVersion: BundleVersion[id=10021,name=null,version=null]
configuration: Configuration[id=15021]
ctime: 1337286719259
description: my description
destination: BundleDestination[id=10021, bundle=driftBundle, group=Linux Group - Thu May 10 15:10:28 EDT 2012, name=NewDestination]
duration: 0
errorMessage:
id: 10051
live: true
mtime: 1337286719259
name: Deployment [1] of Version [2.0] to [NewDestination]
replacedBundleDeploymentId:
resourceDeployments: [BundleResourceDeployment: bdd=[BundleDeployment[id=10051, name=Deployment [1] of Version [2.0] to [new-test]]], resource=[Resource[id=10001, uuid=535b3f54-0bd8-4653-bdd3-323ea69b98fd, type={Platforms}Linux, key=gs-dl585g2-01.rhts.eng.bos.redhat.com, name=server.example.com, parent=<null>, version=Linux 2.6.32-220.el6.x86_64]]]
status: Failure
subjectName: rhqadmin
tags:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The deployBundle function runs through a couple of steps to manage the deployment. This uses one of the functions from the util.js file to convert the deployment configuration (if any is sent) into the proper into a hash.
... 8< ...
var deploymentConfig = deploymentConfiguration;
if (!(deploymentConfiguration instanceof Configuration)) {
deploymentConfig = asConfiguration(deploymentConfiguration);
}
... 8< ...
var deploymentConfig = deploymentConfiguration;
if (!(deploymentConfiguration instanceof Configuration)) {
deploymentConfig = asConfiguration(deploymentConfiguration);
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The next creates the deployment (through the remote API) and then schedules the deployment.