Search in sources :

Example 1 with ReactorCloudFoundryClient

use of org.cloudfoundry.reactor.client.ReactorCloudFoundryClient 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

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CloudFoundryOperations (org.cloudfoundry.operations.CloudFoundryOperations)1 DefaultCloudFoundryOperations (org.cloudfoundry.operations.DefaultCloudFoundryOperations)1 DefaultConnectionContext (org.cloudfoundry.reactor.DefaultConnectionContext)1 TokenProvider (org.cloudfoundry.reactor.TokenProvider)1 ReactorCloudFoundryClient (org.cloudfoundry.reactor.client.ReactorCloudFoundryClient)1 PasswordGrantTokenProvider (org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider)1 JSONException (org.json.JSONException)1 TransformationFailureException (org.opentosca.toscana.plugins.util.TransformationFailureException)1