use of com.sequenceiq.cloudbreak.cloud.model.Image in project cloudbreak by hortonworks.
the class JsonTest method testMembers.
@Test
public void testMembers() throws JsonProcessingException {
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "CORE");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
Json json = new Json(image);
Assert.assertEquals("{\"imageName\":\"cb-centos66-amb200-2015-05-25\",\"userdata\":{\"CORE\":\"CORE\"},\"osType\":\"redhat6\"," + "\"imageCatalogUrl\":\"\",\"imageCatalogName\":\"default\",\"imageId\":\"default-id\"}", json.getValue());
}
use of com.sequenceiq.cloudbreak.cloud.model.Image in project cloudbreak by hortonworks.
the class JsonTest method testMultipleSerialisation.
// The reason for this to check whether serialisetion-deserialisation-serialisation results the same json
@Test
public void testMultipleSerialisation() throws IOException {
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "CORE");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
Json json = new Json(image);
String expected = json.getValue();
Image covertedAgain = json.get(Image.class);
json = new Json(covertedAgain);
Assert.assertEquals(expected, json.getValue());
}
use of com.sequenceiq.cloudbreak.cloud.model.Image in project cloudbreak by hortonworks.
the class JsonTest method testMultipleSerialisationWithOtherConstructorOfImage.
@Test
public void testMultipleSerialisationWithOtherConstructorOfImage() throws IOException {
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "CORE");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
Json json = new Json(image);
String expected = json.getValue();
Image covertedAgain = json.get(Image.class);
json = new Json(covertedAgain);
Assert.assertEquals(expected, json.getValue());
}
use of com.sequenceiq.cloudbreak.cloud.model.Image in project cloudbreak by hortonworks.
the class PrepareImageHandler method accept.
@Override
public void accept(Event<PrepareImageRequest> event) {
LOGGER.info("Received event: {}", event);
PrepareImageRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
Image image = request.getImage();
CloudStack stack = request.getStack();
connector.setup().prepareImage(auth, stack, image);
PrepareImageResult result = new PrepareImageResult(request);
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
LOGGER.info("Prepare image finished for {}", cloudContext);
} catch (RuntimeException e) {
PrepareImageResult failure = new PrepareImageResult(e, request);
request.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(event.getHeaders(), failure));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.Image in project cloudbreak by hortonworks.
the class StackToStackV2RequestConverter method prepareImage.
private void prepareImage(Stack source, StackV2Request stackV2Request) {
try {
Image image = componentConfigProvider.getImage(source.getId());
ImageSettings is = new ImageSettings();
is.setImageId(Strings.isNullOrEmpty(image.getImageId()) ? "" : image.getImageId());
is.setImageCatalog(Strings.isNullOrEmpty(image.getImageCatalogName()) ? "" : image.getImageCatalogName());
stackV2Request.setImageSettings(is);
} catch (CloudbreakImageNotFoundException e) {
LOGGER.error(e.toString());
}
}
Aggregations