Search in sources :

Example 11 with Platform

use of org.opentosca.toscana.core.transformation.platform.Platform in project TOSCAna by StuPro-TOSCAna.

the class TransformationControllerTest method mockPlatformService.

private void mockPlatformService() {
    platformService = mock(PlatformService.class);
    Set<Platform> platforms = new HashSet<>();
    for (int i = 0; i < 5; i++) {
        HashSet<PlatformInput> inputs = new HashSet<>();
        for (PropertyType type : PropertyType.values()) {
            inputs.add(new PlatformInput(type.getTypeName() + "_input", type));
        }
        char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        if (i == 0) {
            inputs.add(new PlatformInput(PROPERTY_TEST_DEFAULT_VALUE_KEY, PropertyType.TEXT, "", false, INPUT_TEST_DEFAULT_VALUE));
        }
        platforms.add(new Platform("p-" + chars[i], "platform-" + (i + 1), inputs));
    }
    when(platformService.getSupportedPlatforms()).thenReturn(platforms);
    when(platformService.isSupported(any(Platform.class))).thenReturn(false);
    when(platformService.findPlatformById(anyString())).thenReturn(Optional.empty());
    for (Platform platform : platforms) {
        when(platformService.findPlatformById(platform.id)).thenReturn(Optional.of(platform));
        when(platformService.isSupported(platform)).thenReturn(true);
    }
}
Also used : PlatformService(org.opentosca.toscana.core.transformation.platform.PlatformService) Platform(org.opentosca.toscana.core.transformation.platform.Platform) PropertyType(org.opentosca.toscana.core.transformation.properties.PropertyType) MockMvcResultHandlers.print(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print) HashSet(java.util.HashSet) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput)

Example 12 with Platform

use of org.opentosca.toscana.core.transformation.platform.Platform in project TOSCAna by StuPro-TOSCAna.

the class TransformationControllerTest method mockTransformationService.

private void mockTransformationService() {
    transformationService = mock(TransformationService.class);
    when(transformationService.createTransformation(any(Csar.class), any(Platform.class))).then(iom -> {
        Csar csar = (Csar) iom.getArguments()[0];
        Platform platform = (Platform) iom.getArguments()[1];
        Transformation t = new TransformationImpl(csar, platform, logMock(), modelMock());
        csar.getTransformations().put(platform.id, t);
        return t;
    });
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) Platform(org.opentosca.toscana.core.transformation.platform.Platform) TransformationService(org.opentosca.toscana.core.transformation.TransformationService)

Example 13 with Platform

use of org.opentosca.toscana.core.transformation.platform.Platform in project TOSCAna by StuPro-TOSCAna.

the class PlatformControllerTest method platformDetails.

@Test
public void platformDetails() throws Exception {
    for (Platform platform : prov.getSupportedPlatforms()) {
        ResultActions resultActions = mvc.perform(get("/api/platforms/" + platform.id)).andDo(print());
        resultActions.andExpect(jsonPath("$.id").value(platform.id));
        resultActions.andExpect(jsonPath("$.name").value(platform.name));
        resultActions.andExpect(jsonPath("$._links.self.href").isString());
        resultActions.andExpect(jsonPath("$.supportsDeployment").value(platform.supportsDeployment));
        resultActions.andReturn();
    }
}
Also used : Platform(org.opentosca.toscana.core.transformation.platform.Platform) ResultActions(org.springframework.test.web.servlet.ResultActions) BaseTest(org.opentosca.toscana.core.BaseTest) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 14 with Platform

use of org.opentosca.toscana.core.transformation.platform.Platform in project TOSCAna by StuPro-TOSCAna.

the class CloudFormationPlugin method getPlatformDetails.

private static Platform getPlatformDetails() {
    String platformId = "cloudformation";
    String platformName = "AWS CloudFormation";
    Set<PlatformInput> platformProperties = new HashSet<>();
    String defaultKeyId = "";
    String defaultKeySecret = "";
    try {
        ProfileCredentialsProvider profileCredentialsProvider = new ProfileCredentialsProvider();
        AWSCredentials awsCredentials = profileCredentialsProvider.getCredentials();
        defaultKeyId = awsCredentials.getAWSAccessKeyId();
        defaultKeySecret = awsCredentials.getAWSSecretKey();
    } catch (Exception e) {
        logger.debug("Did not find credentials on the system");
    }
    String defaultRegion = AWS_REGION_DEFAULT;
    platformProperties.add(new PlatformInput(AWS_REGION_KEY, PropertyType.TEXT, "The AWS Region this should be transformed to. (The imageId of possible EC2 machines depend on this)", true, defaultRegion));
    platformProperties.add(new PlatformInput(AWS_ACCESS_KEY_ID_KEY, PropertyType.TEXT, "The Access key id", true, defaultKeyId));
    platformProperties.add(new PlatformInput(AWS_SECRET_KEY_KEY, PropertyType.SECRET, "The Access key secret", true, defaultKeySecret));
    platformProperties.add(new PlatformInput(AWS_KEYPAIR_KEY, PropertyType.BOOLEAN, "If enabled, adds a AWS 'Keypair' Parameter to the template in order to access EC2 Instances via SSH. Must be specified during Deplyoment.", true, "false"));
    return new Platform(platformId, platformName, platformProperties);
}
Also used : Platform(org.opentosca.toscana.core.transformation.platform.Platform) ProfileCredentialsProvider(com.amazonaws.auth.profile.ProfileCredentialsProvider) AWSCredentials(com.amazonaws.auth.AWSCredentials) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput) HashSet(java.util.HashSet)

Example 15 with Platform

use of org.opentosca.toscana.core.transformation.platform.Platform in project TOSCAna by StuPro-TOSCAna.

the class KubernetesPlugin method getPlatformDetails.

/**
 *     Constructs the Platform Object for the Kubernetes Plugin
 */
private static Platform getPlatformDetails() {
    String platformId = "kubernetes";
    String platformName = "Kubernetes";
    Set<PlatformInput> platformProperties = new HashSet<>();
    // Create the "Property Schema" for the Kubernetes Plugin
    // Add the Push Flag (has to be set to true to push)
    platformProperties.add(new PlatformInput(DOCKER_PUSH_TO_REGISTRY_PROPERTY_KEY, PropertyType.BOOLEAN, "Set this to true if the created docker images should be pushed to the given docker registry", true, "false"));
    // Add the Registry URL Property (if the value is empty DockerHub gets used internally)
    platformProperties.add(new PlatformInput(DOCKER_REGISTRY_URL_PROPERTY_KEY, PropertyType.TEXT, "The URL To the docker Registry. (Will default to DockerHub if empty)", false, ""));
    platformProperties.add(new PlatformInput(DOCKER_REGISTRY_USERNAME_PROPERTY_KEY, PropertyType.TEXT, "The Username of the user, used to push to the regsitry", false));
    platformProperties.add(new PlatformInput(DOCKER_REGISTRY_PASSWORD_PROPERTY_KEY, PropertyType.SECRET, "The password of the registry user", false));
    platformProperties.add(new PlatformInput(DOCKER_REGISTRY_REPOSITORY_PROPERTY_KEY, PropertyType.TEXT, "The name of the repository used to push the images onto.", false));
    return new Platform(platformId, platformName, platformProperties);
}
Also used : Platform(org.opentosca.toscana.core.transformation.platform.Platform) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput) HashSet(java.util.HashSet)

Aggregations

Platform (org.opentosca.toscana.core.transformation.platform.Platform)16 HashSet (java.util.HashSet)9 File (java.io.File)7 Csar (org.opentosca.toscana.core.csar.Csar)6 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)5 PlatformInput (org.opentosca.toscana.core.transformation.properties.PlatformInput)5 TransformationImpl (org.opentosca.toscana.core.transformation.TransformationImpl)4 ApiOperation (io.swagger.annotations.ApiOperation)3 Before (org.junit.Before)3 Test (org.junit.Test)3 Transformation (org.opentosca.toscana.core.transformation.Transformation)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ApiResponses (io.swagger.annotations.ApiResponses)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PlatformNotFoundException (org.opentosca.toscana.api.exceptions.PlatformNotFoundException)2 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1