use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducer method doUpload.
private void doUpload(Exchange exchange) {
final Message msg = exchange.getIn();
final String imageId = msg.getHeader(OpenstackConstants.ID, String.class);
ObjectHelper.notEmpty(imageId, "Image ID");
final Image in = messageHeadersToImage(msg, false);
final Payload payload = createPayload(msg);
final Image out = os.images().upload(imageId, payload, in);
msg.setBody(out);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Image in = messageToImage(msg);
final Image out = os.images().update(in);
msg.setBody(out);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducer method doCreate.
private void doCreate(Exchange exchange) {
final Message msg = exchange.getIn();
final Image in = messageHeadersToImage(msg, true);
final Payload payload = createPayload(msg);
final Image out = os.images().create(in, payload);
msg.setBody(out);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String imageId = msg.getHeader(OpenstackConstants.ID, String.class);
ObjectHelper.notEmpty(imageId, "ImageID");
final Image out = os.images().get(imageId);
msg.setBody(out);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducerTest method uploadWithUpdatingTest.
@Test
public void uploadWithUpdatingTest() throws Exception {
final String newName = "newName";
dummyImage.setName(newName);
when(osImage.getName()).thenReturn(newName);
msg.setHeader(OpenstackConstants.OPERATION, GlanceConstants.UPLOAD);
final String id = "id";
msg.setHeader(OpenstackConstants.ID, id);
msg.setHeader(OpenstackConstants.NAME, dummyImage.getName());
msg.setHeader(GlanceConstants.OWNER, dummyImage.getOwner());
msg.setHeader(GlanceConstants.MIN_DISK, dummyImage.getMinDisk());
msg.setHeader(GlanceConstants.MIN_RAM, dummyImage.getMinRam());
msg.setHeader(GlanceConstants.CHECKSUM, dummyImage.getChecksum());
msg.setHeader(GlanceConstants.DISK_FORMAT, dummyImage.getDiskFormat());
msg.setHeader(GlanceConstants.CONTAINER_FORMAT, dummyImage.getContainerFormat());
final File file = File.createTempFile("image", ".iso");
msg.setBody(file);
producer.process(exchange);
ArgumentCaptor<Payload> payloadCaptor = ArgumentCaptor.forClass(Payload.class);
ArgumentCaptor<String> imageIdCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<org.openstack4j.model.image.Image> imageCaptor = ArgumentCaptor.forClass(org.openstack4j.model.image.Image.class);
verify(imageService).upload(imageIdCaptor.capture(), payloadCaptor.capture(), imageCaptor.capture());
assertEquals(id, imageIdCaptor.getValue());
assertEquals(file, payloadCaptor.getValue().getRaw());
assertEquals(newName, imageCaptor.getValue().getName());
final Image result = msg.getBody(Image.class);
assertNotNull(result.getId());
assertEqualsImages(dummyImage, result);
}
Aggregations