Show Table of Contents
20.2. Deploying Bundles
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)
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.
rhqadmin@localhost:7080$ var crit = new BundleVersionCriteria()
rhqadmin@localhost:7080$ crit.addFilterBundleName(name)
rhqadmin@localhost:7080$ var vers = BundleManager.findBundleVersionsByCriteria(crit)
rhqadmin@localhost:7080$ if( vers != null ) { \
rhqadmin@localhost:7080$ if( vers.size() > 1 ) { \
rhqadmin@localhost:7080$ for( i =0; i < vers.size(); ++i) { \
rhqadmin@localhost:7080$ ver = vers.get(i); \
rhqadmin@localhost:7080$ println("Version: " + ver.version + " " + "ID: " + ver.id) \
rhqadmin@localhost:7080$ } \
rhqadmin@localhost:7080$ } \
rhqadmin@localhost:7080$ else if( vers.size() == 1 ) { \
rhqadmin@localhost:7080$ ver = vers.get(0); \
rhqadmin@localhost:7080$ println("Version: " + ver.version + + " " + "ID: " + ver.id) \
rhqadmin@localhost:7080$ } \
rhqadmin@localhost:7080$ }
Version: 2.0 ID: 10021
Version: 1.0 ID: 10012
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:
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);
}
The next creates the deployment (through the remote API) and then schedules the deployment.
... 8< ...
var deployment = BundleManager.createBundleDeployment(bundleVersionId, destinationId, description, deploymentConfig);
deployment = BundleManager.scheduleBundleDeployment(deployment.id, isCleanDeployment);
... 8< ...
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.