Search in sources :

Example 1 with VolumeSnapshotBuilder

use of org.openstack4j.model.storage.block.builder.VolumeSnapshotBuilder in project camel by apache.

the class SnapshotProducer method messageToSnapshot.

private VolumeSnapshot messageToSnapshot(Message message) {
    VolumeSnapshot volume = message.getBody(VolumeSnapshot.class);
    if (volume == null) {
        Map headers = message.getHeaders();
        VolumeSnapshotBuilder builder = Builders.volumeSnapshot();
        final String name = message.getHeader(OpenstackConstants.NAME, String.class);
        ObjectHelper.notEmpty(name, "Name");
        builder.name(name);
        if (headers.containsKey(OpenstackConstants.DESCRIPTION)) {
            builder.description(message.getHeader(OpenstackConstants.DESCRIPTION, String.class));
        }
        if (headers.containsKey(CinderConstants.VOLUME_ID)) {
            builder.volume(message.getHeader(CinderConstants.VOLUME_ID, String.class));
        }
        if (headers.containsKey(CinderConstants.FORCE)) {
            builder.force(message.getHeader(CinderConstants.FORCE, Boolean.class));
        }
        volume = builder.build();
    }
    return volume;
}
Also used : VolumeSnapshotBuilder(org.openstack4j.model.storage.block.builder.VolumeSnapshotBuilder) VolumeSnapshot(org.openstack4j.model.storage.block.VolumeSnapshot) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 VolumeSnapshot (org.openstack4j.model.storage.block.VolumeSnapshot)1 VolumeSnapshotBuilder (org.openstack4j.model.storage.block.builder.VolumeSnapshotBuilder)1