Search in sources :

Example 1 with PlatformInput

use of org.opentosca.toscana.core.transformation.properties.PlatformInput in project TOSCAna by StuPro-TOSCAna.

the class CloudFoundryPlugin method getPlatformDetails.

private static Platform getPlatformDetails() {
    String platformId = "cloud-foundry";
    String platformName = "CloudFoundry";
    Set<PlatformInput> platformProperties = new HashSet<>();
    PlatformInput cfUserName = new PlatformInput(CF_PROPERTY_KEY_USERNAME, PropertyType.TEXT, "Username of CloudFoundry provideraccount", true);
    PlatformInput cfUserPw = new PlatformInput(CF_PROPERTY_KEY_PASSWORD, PropertyType.SECRET, "Password of CloudFoundry provideraccount", true);
    PlatformInput cfEndpoint = new PlatformInput(CF_PROPERTY_KEY_API, PropertyType.TEXT, "The endpoint of the provider", true);
    PlatformInput cfSpace = new PlatformInput(CF_PROPERTY_KEY_SPACE, PropertyType.TEXT, "The space of the useraccount which should be used to deploy", true);
    PlatformInput cfOrganization = new PlatformInput(CF_PROPERTY_KEY_ORGANIZATION, PropertyType.TEXT, "The organization of the useraccount which should be used to deploy", true);
    platformProperties.add(cfUserName);
    platformProperties.add(cfUserPw);
    platformProperties.add(cfEndpoint);
    platformProperties.add(cfSpace);
    platformProperties.add(cfOrganization);
    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)

Example 2 with PlatformInput

use of org.opentosca.toscana.core.transformation.properties.PlatformInput in project TOSCAna by StuPro-TOSCAna.

the class TransformationPropertyHandlingTest method setUp.

@Before
public void setUp() throws Exception {
    Csar csar = new CsarImpl(new File(""), MOCK_CSAR_NAME, log);
    HashSet<PlatformInput> props = new HashSet<>();
    for (int i = 0; i < 10; i++) {
        props.add(new PlatformInput("prop-" + i, PropertyType.UNSIGNED_INTEGER, "No real Description", // Only mark the first 5 properties as required
        i < 5));
    }
    Platform p = new Platform("test", "Test Platform", props);
    transformation = new TransformationImpl(csar, p, log, modelMock());
    properties = transformation.getInputs();
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) Platform(org.opentosca.toscana.core.transformation.platform.Platform) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) File(java.io.File) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 3 with PlatformInput

use of org.opentosca.toscana.core.transformation.properties.PlatformInput in project TOSCAna by StuPro-TOSCAna.

the class TransformationControllerTest method testGetOutputs.

// </editor-fold>
// <editor-fold desc="Output Tests">
@Test
public void testGetOutputs() throws Exception {
    List<Transformation> transformations = preInitNonCreationTests();
    Transformation t = transformations.get(0);
    when(t.getState()).thenReturn(TransformationState.DONE);
    String outputKey = "test_output";
    List<OutputProperty> outputs = Lists.newArrayList(new PlatformInput(outputKey, PropertyType.TEXT, "", true, "some value"));
    when(t.getOutputs()).thenReturn(outputs);
    mvc.perform(get(GET_OUTPUT_URL)).andDo(print()).andExpect(status().is(200)).andExpect(jsonPath("$.outputs").isArray()).andExpect(jsonPath("$.links[0].href").value("http://localhost" + GET_OUTPUT_URL)).andExpect(jsonPath("$.outputs[0].key").value(outputKey)).andReturn();
}
Also used : Transformation(org.opentosca.toscana.core.transformation.Transformation) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) OutputProperty(org.opentosca.toscana.core.transformation.properties.OutputProperty) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput) Test(org.junit.Test) BaseSpringTest(org.opentosca.toscana.core.BaseSpringTest)

Example 4 with PlatformInput

use of org.opentosca.toscana.core.transformation.properties.PlatformInput 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 5 with PlatformInput

use of org.opentosca.toscana.core.transformation.properties.PlatformInput 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)

Aggregations

PlatformInput (org.opentosca.toscana.core.transformation.properties.PlatformInput)6 HashSet (java.util.HashSet)5 Platform (org.opentosca.toscana.core.transformation.platform.Platform)5 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)1 File (java.io.File)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 BaseSpringTest (org.opentosca.toscana.core.BaseSpringTest)1 Csar (org.opentosca.toscana.core.csar.Csar)1 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)1 Transformation (org.opentosca.toscana.core.transformation.Transformation)1 PlatformService (org.opentosca.toscana.core.transformation.platform.PlatformService)1 OutputProperty (org.opentosca.toscana.core.transformation.properties.OutputProperty)1 PropertyType (org.opentosca.toscana.core.transformation.properties.PropertyType)1 MockMvcResultHandlers.print (org.springframework.test.web.servlet.result.MockMvcResultHandlers.print)1