Camel Components

OpenStack Cinder

Deprecated: This openstack-cinder is deprecated and may be removed in a future release.

Since Camel 2.19

Only producer is supported

The Openstack Cinder component allows messages to be sent to an OpenStack block storage services.

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-openstack</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.

URI Format

openstack-cinder://hosturl[?options]

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The OpenStack Cinder component supports the following options which are listed below.

Name Description Default Type

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

Endpoint Options

The OpenStack Cinder endpoint is configured using URI syntax:

openstack-cinder:host

With the following path and query parameters:

Path Parameters

Name Description Default Type

host (producer)

Required The URL of the OpenStack Identity service (Keystone) to authenticate with, for example http://controller:5000/v3.

String

Query Parameters

Name Description Default Type

apiVersion (producer)

The version of the OpenStack Identity API to authenticate with: V3 or V2.

Enum values:

  • V2

  • V3

V3

String

config (producer)

The openstack4j client configuration (org.openstack4j.core.transport.Config), for example to set connection and read timeouts, an SSLContext or a proxy. When not set, the openstack4j defaults are used.

Config

domain (producer)

The name of the domain the user belongs to, used to authenticate with Identity API V3 (not used with V2).

default

String

operation (producer)

The operation to perform: create, get, getAll, update or delete, and for volumes also getAllTypes.

String

password (producer)

Required The password of the OpenStack user.

String

project (producer)

Required The ID of the project to scope the authentication to (the tenant ID with Identity API V2).

String

subsystem (producer)

Required The kind of Cinder resource to manage: volumes or snapshots.

Enum values:

  • snapshots

  • volumes

String

username (producer)

Required The name of the OpenStack user to authenticate as.

String

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

Message Headers

The OpenStack Cinder component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelOpenstackCinderSize (volume)

Constant: SIZE

The size of the volume in GiB.

Integer

CamelOpenstackCinderVolumeType (volume)

Constant: VOLUME_TYPE

The name or ID of the volume type.

String

CamelOpenstackCinderImageRef (volume)

Constant: IMAGE_REF

The ID of the image to create the volume from.

String

CamelOpenstackCinderSnapshotId (volume)

Constant: SNAPSHOT_ID

The ID of the snapshot, such as the snapshot to create the volume from.

String

CamelOpenstackCinderIsBootable (volume)

Constant: IS_BOOTABLE

Whether the volume is bootable.

Boolean

CamelOpenstackCinderVolumeId (snapshot)

Constant: VOLUME_ID

The ID of the volume, such as the volume to take the snapshot of.

String

CamelOpenstackCinderForce (snapshot)

Constant: FORCE

Whether to take the snapshot even when the volume is attached to a server.

Boolean

CamelOpenstackOperation (producer)

Constant: OPERATION

The operation to perform.

String

CamelOpenstackId (producer)

Constant: ID

The ID of the resource to act on.

String

CamelOpenstackName (producer)

Constant: NAME

The name of the resource, such as the volume, image or server to create, or the key pair or container to act on.

String

CamelOpenstackDescription (producer)

Constant: DESCRIPTION

The description of the volume or snapshot.

String

Message Body

The message body at each side of the OpenStack Cinder component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

any

Read by create and update only: a Volume or VolumeSnapshot of openstack4j, or else the fields from headers such as CamelOpenstackName. The other operations take the id from a header.

Producer output

pojo, list, null or unchanged

The Volume or VolumeSnapshot of openstack4j created or read (null when get finds none), a List of them for getAll and of VolumeType for getAllTypes; update and delete keep the body.

  • With operation=create: pojo

  • With operation=get: pojo or null

  • With operation=getAll: list

  • With operation=getAllTypes: list

  • With operation=update: unchanged

  • With operation=delete: unchanged

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Usage

You can use the following settings for each subsystem:

Volumes

Operations you can perform with the Volume producer

Operation Description

create

Create new volume.

get

Get the volume.

getAll

Get all volumes.

getAllTypes

Get volume types.

update

Update the volume.

delete

Delete the volume.

If you need more precise volume settings, you can create a new object of the type org.openstack4j.model.storage.block.Volume and send in the message body.

Snapshots

Operations you can perform with the Snapshot producer

Operation Description

create

Create a new snapshot.

get

Get the snapshot.

getAll

Get all snapshots.

update

Update the snapshot.

delete

Delete the snapshot.

If you need more precise snapshot settings, you can create a new object of the type org.openstack4j.model.storage.block.VolumeSnapshot and send in the message body.

Example

The following route creates a volume of 10 GB and logs its id. The endpoint is the address of the identity service (Keystone), and the credentials are property placeholders:

- route:
    from:
      uri: direct:createVolume
      steps:
        - setHeader:
            name: CamelOpenstackName
            expression:
              constant:
                expression: "orders-data"
        - setHeader:
            name: CamelOpenstackCinderSize
            expression:
              constant:
                expression: "10"
        - to:
            uri: openstack-cinder:http://controller:5000/v3
            parameters:
              username: "{{openstack.username}}"
              password: "{{openstack.password}}"
              project: "{{openstack.project}}"
              subsystem: volumes
              operation: create
        - log:
            message: "Created volume ${body.id}"