Search in sources :

Example 11 with Image

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());
}
Also used : InstanceGroupType(com.sequenceiq.cloudbreak.api.model.InstanceGroupType) HashMap(java.util.HashMap) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Test(org.junit.Test)

Example 12 with Image

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());
}
Also used : InstanceGroupType(com.sequenceiq.cloudbreak.api.model.InstanceGroupType) HashMap(java.util.HashMap) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Test(org.junit.Test)

Example 13 with Image

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());
}
Also used : InstanceGroupType(com.sequenceiq.cloudbreak.api.model.InstanceGroupType) HashMap(java.util.HashMap) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Test(org.junit.Test)

Example 14 with Image

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));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) Event(reactor.bus.Event) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) PrepareImageResult(com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageResult) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) PrepareImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest)

Example 15 with Image

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());
    }
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ImageSettings(com.sequenceiq.cloudbreak.api.model.v2.ImageSettings)

Aggregations

Image (com.sequenceiq.cloudbreak.cloud.model.Image)20 InstanceGroupType (com.sequenceiq.cloudbreak.api.model.InstanceGroupType)8 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)7 HashMap (java.util.HashMap)7 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)6 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)5 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)5 PortDefinition (com.sequenceiq.cloudbreak.cloud.model.PortDefinition)5 Security (com.sequenceiq.cloudbreak.cloud.model.Security)5 SecurityRule (com.sequenceiq.cloudbreak.cloud.model.SecurityRule)5 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)5 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)4 Group (com.sequenceiq.cloudbreak.cloud.model.Group)4 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)4 ArrayList (java.util.ArrayList)4 Before (org.junit.Before)4 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)3 CheckImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)3 CheckImageResult (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult)3 Network (com.sequenceiq.cloudbreak.cloud.model.Network)3