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);
}
}
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;
});
}
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();
}
}
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);
}
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);
}
Aggregations