Jclouds Component

Available as of Camel 2.9

This component allows interaction with cloud provider key-value engines (blobstores) and compute services. The component uses jclouds which is
a library that provides abstractions for blobstores and compute services.

ComputeService simplifies the task of managing machines in the cloud. For example, you can use ComputeService to start 5 machines and install your software on them.
BlobStore simplifies dealing with key-value providers such as Amazon S3. For example, BlobStore can give you a simple Map view of a container.

The camel jclouds component allows you to use both abstractions, as it specifes two types of endpoint the JcloudsBlobStoreEndpoint and the JcloudsComputeEndpoint. You can have both producers and consumers on a blobstore endpoint but you can only have producers on compute endpoints.

Maven users will need to add the following dependency to their pom.xml for this component:

Configuring the component

The camel jclouds component will make use of multiple jclouds blobstores and compute services as long as they are passed to the component during initialization. The component accepts a list blobstores and compute services. Here is how it can be configured.

As you can see the component is capable of handling multiple blobstores and compute services. The actual implementation that will be used by each endpoint is specified by passing the provider inside the URI.

URI format

The provider id is the name of the cloud provider that provides the target service (e.g. aws-s3 or aws_ec2).

You can append query options to the URI in the following format, ?option=value&option=value&...

Blobstore URI Options

Name

Default Value

Description

operation

PUT

Producer Only. Specifies the type of operation that will be performed to the blobstore. Allowed values are PUT, GET.

container

null

The name of the blob container.

blobName

null

The name of the blob.

You can have as many of these options as you like.

For producer endpoint you can override all of the above URI options by passing the appropriate headers to the message.

Message Headers for blobstore

Header

Description

CamelJcloudsOperation

The operation to be performed on the blob. The valid options are

  • PUT
  • GET

CamelJcloudsContainer

The name of the blob container.

CamelJcloudsBlobName

The name of the blob.

Blobstore Usage Samples

Example 1: Putting to the blob

This example will show you how you can store any message inside a blob using the jclouds component.

In the above example you can override any of the URI parameters with headers on the message.
Here is how the above example would look like using xml to define our route.

Example 2: Getting/Reading from a blob

This example will show you how you can read the contnet of a blob using the jclouds component.

In the above example you can override any of the URI parameters with headers on the message.
Here is how the above example would look like using xml to define our route.

Example 3: Consuming a blob

This example will consume all blob that are under the specified container. The generated exchange will contain the payload of the blob as body.

You can achieve the same goal by using xml, as you can see below.

Compute Service URI Options

Name

Default Value

Description

operation

PUT

Specifies the type of operation that will be performed to the compute service. Allowed values are CREATE_NODE, RUNS_CRIPT, DESTROY_NODE, LIST_NODES, LIST_IMAGES, LIST_HARDWARE.

imageId

null

CREATE_NODE operation only The imageId that will be used for creating a node. Values depend on the actual cloud provider.

locationId

null

CREATE_NODE operation only The location that will be used for creating a node. Values depend on the actual cloud provider.

hardwareId

null

CREATE_NODE operation only The hardware that will be used for creating a node. Values depend on the actual cloud provider.

group

null

CREATE_NODE operation only The group that will be assigned to the newly created node. Values depend on the actual cloud provider.

nodeId

null

RUN_SCRIPT & DESTROY_NODE operation only The id of the node that will run the script or destroyed.

user

null

RUN_SCRIPT operation only The user on the target node that will run the script.

The combination of parameters for use with the compute service depend on the operation.

Compute Usage Samples

Below are some examples that demonstrate the use of jclouds compute producer in java dsl and spring/blueprint xml.

Example 1: Listing the available images.

This will create a message that will contain the list of images inside its body. You can also do the same using xml.

Example 2: Create a new node.

This will create a new node on the cloud provider. The out message in this case will be a set of metadata that contains information about the newly created node (e.g. the ip, hostname etc). Here is the same using spring xml.

Example 3: Run a shell script on running node.

The sample above will retrieve the body of the in message, which is expected to contain the shell script to be executed. Once the script is retrieved, it will be sent to the node for execution under the specified user (in order case ubuntu). The target node is specified using its nodeId. The nodeId can be retrieved either upon the creation of the node, it will be part of the resulting metadata or by a executing a LIST_NODES operation.

Note This will require that the compute service that will be passed to the component, to be initialized with the appropriate jclouds ssh capable module (e.g. jsch or sshj).

Here is the same using spring xml.

See also

If you want to find out more about jclouds here is list of interesting resources
Jclouds Blobstore wiki
Jclouds Compute wiki

© 2004-2014 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram