use of org.openstack4j.model.storage.block.VolumeSnapshot in project camel by apache.
the class SnapshotProducer method doCreate.
private void doCreate(Exchange exchange) {
final Message msg = exchange.getIn();
final VolumeSnapshot in = messageToSnapshot(msg);
final VolumeSnapshot out = os.blockStorage().snapshots().create(in);
msg.setBody(out);
}
use of org.openstack4j.model.storage.block.VolumeSnapshot in project camel by apache.
the class SnapshotProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(CinderConstants.SNAPSHOT_ID, String.class), String.class);
ObjectHelper.notEmpty(id, "Snapshot ID");
final VolumeSnapshot out = os.blockStorage().snapshots().get(id);
msg.setBody(out);
}
use of org.openstack4j.model.storage.block.VolumeSnapshot 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;
}
use of org.openstack4j.model.storage.block.VolumeSnapshot in project camel by apache.
the class VolumeSnapshotProducerTest method createVolumeTest.
@Test
public void createVolumeTest() throws Exception {
when(endpoint.getOperation()).thenReturn(OpenstackConstants.CREATE);
msg.setBody(dummyVolumeSnapshot);
producer.process(exchange);
final VolumeSnapshot result = msg.getBody(VolumeSnapshot.class);
assertEqualsVolumeSnapshots(dummyVolumeSnapshot, result);
assertNotNull(result.getId());
}
use of org.openstack4j.model.storage.block.VolumeSnapshot in project camel by apache.
the class SnapshotProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(CinderConstants.SNAPSHOT_ID, String.class), String.class);
final VolumeSnapshot vs = messageToSnapshot(msg);
ObjectHelper.notEmpty(id, "Cinder Snapshot ID");
final ActionResponse out = os.blockStorage().snapshots().update(id, vs.getName(), vs.getDescription());
checkFailure(out, msg, "Update volume snapshot " + id);
}
Aggregations