Search in sources :

Example 1 with DefaultConnectionContext

use of org.cloudfoundry.reactor.DefaultConnectionContext 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)

Example 2 with DefaultConnectionContext

use of org.cloudfoundry.reactor.DefaultConnectionContext in project promregator by promregator.

the class ReactiveCFAccessorImpl method constructCloudFoundryClient.

@PostConstruct
private void constructCloudFoundryClient() throws ConfigurationException {
    ProxyConfiguration proxyConfiguration = this.proxyConfiguration();
    DefaultConnectionContext connectionContext = this.connectionContext(proxyConfiguration);
    PasswordGrantTokenProvider tokenProvider = this.tokenProvider();
    this.cloudFoundryClient = this.cloudFoundryClient(connectionContext, tokenProvider);
}
Also used : ProxyConfiguration(org.cloudfoundry.reactor.ProxyConfiguration) DefaultConnectionContext(org.cloudfoundry.reactor.DefaultConnectionContext) PasswordGrantTokenProvider(org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider) PostConstruct(javax.annotation.PostConstruct)

Aggregations

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