Search in sources :

Example 21 with TransformationFailureException

use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.

the class ServiceHandler method addServiceCommands.

/**
 *     Add the needed services to the deploymentscript and try to match a suitable service from the provider.
 *
 *     @param alreadyHandledServices  services which are already created, so there have not to created twice
 *     @param showAllServiceOfferings if yes then adds all service offerings to deploymentscript
 */
public List<String> addServiceCommands(Boolean showAllServiceOfferings, List<String> alreadyHandledServices) {
    try {
        logger.info("Try to read service offerings of provider");
        List<String> adaptServiceList = readProviderServices(alreadyHandledServices);
        if (showAllServiceOfferings) {
            if (application.getProvider() != null && !application.getServices().isEmpty() && application.getConnection() != null) {
                logger.debug("List all possible services in the an extra file");
                addProviderServiceOfferings();
            }
        }
        return adaptServiceList;
    } catch (IOException e) {
        throw new TransformationFailureException("Fail to add services to deployment Script", e);
    }
}
Also used : TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) IOException(java.io.IOException)

Example 22 with TransformationFailureException

use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.

the class Connection method createCloudFoundryOperations.

/**
 *     create a Connection to a cloud foundry instance.
 *     A CLoudFoundryOperation could send cf commands
 */
private CloudFoundryOperations createCloudFoundryOperations() {
    CloudFoundryOperations cloudFoundryOperations;
    try {
        DefaultConnectionContext connectionContext = DefaultConnectionContext.builder().apiHost(apiHost).build();
        TokenProvider tokenProvider = PasswordGrantTokenProvider.builder().password(password).username(userName).build();
        ReactorCloudFoundryClient reactorClient = ReactorCloudFoundryClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
        cloudFoundryOperations = DefaultCloudFoundryOperations.builder().cloudFoundryClient(reactorClient).organization(organization).space(space).build();
    } catch (Exception e) {
        logger.error("Cant connect to Cloud Foundry instance");
        throw new TransformationFailureException("Could not connect to Cloud Foundry instance, Please check your credentials", e);
    }
    logger.info("Connect successfully to Cloud Foundry instance");
    return cloudFoundryOperations;
}
Also used : PasswordGrantTokenProvider(org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider) TokenProvider(org.cloudfoundry.reactor.TokenProvider) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) DefaultConnectionContext(org.cloudfoundry.reactor.DefaultConnectionContext) DefaultCloudFoundryOperations(org.cloudfoundry.operations.DefaultCloudFoundryOperations) CloudFoundryOperations(org.cloudfoundry.operations.CloudFoundryOperations) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) JSONException(org.json.JSONException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ReactorCloudFoundryClient(org.cloudfoundry.reactor.client.ReactorCloudFoundryClient)

Aggregations

TransformationFailureException (org.opentosca.toscana.plugins.util.TransformationFailureException)22 IOException (java.io.IOException)10 SdkClientException (com.amazonaws.SdkClientException)8 Compute (org.opentosca.toscana.model.node.Compute)8 SecurityGroup (com.scaleset.cfbuilder.ec2.SecurityGroup)6 Artifact (org.opentosca.toscana.model.artifact.Artifact)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ArrayList (java.util.ArrayList)3 JSONException (org.json.JSONException)3 RootNode (org.opentosca.toscana.model.node.RootNode)3 CFNCommand (com.scaleset.cfbuilder.ec2.metadata.CFNCommand)2 CFNPackage (com.scaleset.cfbuilder.ec2.metadata.CFNPackage)2 ComputeCapability (org.opentosca.toscana.model.capability.ComputeCapability)2 EndpointCapability (org.opentosca.toscana.model.capability.EndpointCapability)2 WebApplication (org.opentosca.toscana.model.node.WebApplication)2 Operation (org.opentosca.toscana.model.operation.Operation)2 Instance (com.scaleset.cfbuilder.ec2.Instance)1 CFNInit (com.scaleset.cfbuilder.ec2.metadata.CFNInit)1 DBInstance (com.scaleset.cfbuilder.rds.DBInstance)1 FileNotFoundException (java.io.FileNotFoundException)1