Search in sources :

Example 11 with TransformationContext

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

the class BaseTransformTest method initContext.

/**
 *     initializes the transformation context
 */
protected TransformationContext initContext() throws Exception {
    Csar csar = new CsarImpl(tmpdir, "csarId", logMock());
    Transformation t = new TransformationImpl(csar, plugin.getPlatform(), logMock(), model);
    Transformation transformation = spy(t);
    when(transformation.getInputs()).thenReturn(inputs);
    return new TransformationContext(transformation, workingDir);
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext)

Example 12 with TransformationContext

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

the class ExportingImageBuilderIT method testBuildShaImage.

@Test
public void testBuildShaImage() throws Exception {
    assumeTrue(DockerTestUtils.isDockerAvailable());
    // Create Dockerfile and the corresponding Binary file
    shaDigest = buildSHADockerfile();
    init();
    TransformationContext ctx = mock(TransformationContext.class);
    when(ctx.getPluginFileAccess()).thenReturn(access);
    when(ctx.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Mock Logger"));
    imageBuilder = instantiateImageBuilder(ctx);
    logger.info("Building Image");
    imageBuilder.buildImage();
    logger.info("Storing Image");
    imageBuilder.storeImage();
    validate(imageBuilder.getTag());
}
Also used : TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) Test(org.junit.Test) BaseDockerfileTest(org.opentosca.toscana.plugins.kubernetes.docker.BaseDockerfileTest) IntegrationTest(org.opentosca.toscana.IntegrationTest)

Example 13 with TransformationContext

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

the class ToscanaPlugin method transform.

/**
 *     This method will transform  given model (contained in the TransformationContext instance) and will store the result
 *     in a directory provided by the context.
 *     <p>
 *     Performs the execution in phases in the order that has been defined during the construction of the object
 */
public void transform(LifecycleT lifecycle) throws Exception {
    TransformationContext context = lifecycle.getContext();
    Logger logger = context.getLogger(getClass());
    long time = System.currentTimeMillis();
    List<ExecutionPhase> phases = lifecycle.getLifecyclePhases();
    int taskCount = countExecutionPhases(context, phases);
    logger.info("This transformation has {} phases", taskCount);
    for (int i = 0; i < phases.size(); i++) {
        ExecutionPhase phase = phases.get(i);
        if (phase.shouldExecute(context)) {
            logger.info("Executing phase '{}' ({} of {})", phase.getName(), (i + 1), taskCount);
            phase.execute(lifecycle);
        } else {
            phase.skip();
            logger.info("Skipping phase '{}' ({} of {})", phase.getName(), (i + 1), taskCount);
        }
    }
    time = System.currentTimeMillis() - time;
    logger.info("Transformation finished after {} ms", time);
}
Also used : Logger(org.slf4j.Logger) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext)

Aggregations

TransformationContext (org.opentosca.toscana.core.transformation.TransformationContext)13 File (java.io.File)4 Before (org.junit.Before)4 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)4 Test (org.junit.Test)3 Csar (org.opentosca.toscana.core.csar.Csar)3 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)3 Transformation (org.opentosca.toscana.core.transformation.Transformation)3 TransformationImpl (org.opentosca.toscana.core.transformation.TransformationImpl)3 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)3 Logger (org.slf4j.Logger)3 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)2 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)2 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)2 IOException (java.io.IOException)1 Random (java.util.Random)1 IntegrationTest (org.opentosca.toscana.IntegrationTest)1 NoSuchPropertyException (org.opentosca.toscana.core.transformation.properties.NoSuchPropertyException)1 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)1 OsCapability (org.opentosca.toscana.model.capability.OsCapability)1