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.
<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.
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,*.yamlfiles, 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 |
|---|---|---|---|
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 | |
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 |
|---|---|---|---|
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 |
|---|---|---|---|
The version of the OpenStack Identity API to authenticate with: V3 or V2. Enum values:
| V3 | String | |
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 | ||
The name of the domain the user belongs to, used to authenticate with Identity API V3 (not used with V2). | default | String | |
The operation to perform: create, get, getAll, update or delete, and for volumes also getAllTypes. | String | ||
Required The password of the OpenStack user. | String | ||
Required The ID of the project to scope the authentication to (the tenant ID with Identity API V2). | String | ||
Required The kind of Cinder resource to manage: volumes or snapshots. Enum values:
| String | ||
Required The name of the OpenStack user to authenticate as. | String | ||
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: | The size of the volume in GiB. | Integer | |
CamelOpenstackCinderVolumeType (volume) Constant: | The name or ID of the volume type. | String | |
CamelOpenstackCinderImageRef (volume) Constant: | The ID of the image to create the volume from. | String | |
CamelOpenstackCinderSnapshotId (volume) Constant: | The ID of the snapshot, such as the snapshot to create the volume from. | String | |
CamelOpenstackCinderIsBootable (volume) Constant: | Whether the volume is bootable. | Boolean | |
CamelOpenstackCinderVolumeId (snapshot) Constant: | The ID of the volume, such as the volume to take the snapshot of. | String | |
CamelOpenstackCinderForce (snapshot) Constant: | Whether to take the snapshot even when the volume is attached to a server. | Boolean | |
CamelOpenstackOperation (producer) Constant: | The operation to perform. | String | |
| Constant: | The ID of the resource to act on. | String | |
| Constant: | 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: | 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 |
| 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 |
| 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.
|
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 new volume. |
| Get the volume. |
| Get all volumes. |
| Get volume types. |
| Update the volume. |
| 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 a new snapshot. |
| Get the snapshot. |
| Get all snapshots. |
| Update the snapshot. |
| 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}"