org.cloudfoundry.client.lib.domain.Staging Java Examples

The following examples show how to use org.cloudfoundry.client.lib.domain.Staging. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StagingParametersParser.java    From multiapps-controller with Apache License 2.0 6 votes vote down vote up
@Override
public Staging parse(List<Map<String, Object>> parametersList) {
    String command = (String) getPropertyValue(parametersList, SupportedParameters.COMMAND, null);
    List<String> buildpacks = getPluralOrSingular(parametersList, SupportedParameters.BUILDPACKS, SupportedParameters.BUILDPACK);
    String stack = (String) getPropertyValue(parametersList, SupportedParameters.STACK, null);
    Integer healthCheckTimeout = (Integer) getPropertyValue(parametersList, SupportedParameters.HEALTH_CHECK_TIMEOUT, null);
    String healthCheckType = (String) getPropertyValue(parametersList, SupportedParameters.HEALTH_CHECK_TYPE, null);
    String healthCheckHttpEndpoint = (String) getPropertyValue(parametersList, SupportedParameters.HEALTH_CHECK_HTTP_ENDPOINT,
                                                               getDefaultHealthCheckHttpEndpoint(healthCheckType));
    Boolean isSshEnabled = (Boolean) getPropertyValue(parametersList, SupportedParameters.ENABLE_SSH, null);
    DockerInfo dockerInfo = new DockerInfoParser().parse(parametersList);
    return ImmutableStaging.builder()
                           .command(command)
                           .buildpacks(buildpacks)
                           .stack(stack)
                           .healthCheckTimeout(healthCheckTimeout)
                           .healthCheckType(healthCheckType)
                           .healthCheckHttpEndpoint(healthCheckHttpEndpoint)
                           .isSshEnabled(isSshEnabled)
                           .dockerInfo(dockerInfo)
                           .build();
}
 
Example #2
Source File: StagingApplicationAttributeUpdater.java    From multiapps-controller with Apache License 2.0 6 votes vote down vote up
private boolean hasStagingChanged(Staging staging, Staging existingStaging) {
    List<String> buildpacks = staging.getBuildpacks();
    String command = staging.getCommand();
    String stack = staging.getStack();
    Integer healthCheckTimeout = staging.getHealthCheckTimeout();
    String healthCheckType = staging.getHealthCheckType();
    String healthCheckHttpEndpoint = staging.getHealthCheckHttpEndpoint();
    Boolean sshEnabled = staging.isSshEnabled();
    return (buildpacks != null && !buildpacks.equals(existingStaging.getBuildpacks()))
        || (command != null && !command.equals(existingStaging.getCommand()))
        || (stack != null && !stack.equals(existingStaging.getStack()))
        || (healthCheckTimeout != null && !healthCheckTimeout.equals(existingStaging.getHealthCheckTimeout()))
        || (healthCheckType != null && !healthCheckType.equals(existingStaging.getHealthCheckType()))
        || (healthCheckHttpEndpoint != null && !healthCheckHttpEndpoint.equals(existingStaging.getHealthCheckHttpEndpoint()))
        || (sshEnabled != null && !sshEnabled.equals(existingStaging.isSshEnabled())
            || isDockerInfoModified(existingStaging.getDockerInfo(), staging.getDockerInfo()));
}
 
Example #3
Source File: RawCloudApplicationTest.java    From cf-java-client-sap with Apache License 2.0 6 votes vote down vote up
private static CloudApplication buildApplication(Staging staging) {
    return ImmutableCloudApplication.builder()
                                    .metadata(RawCloudEntityTest.EXPECTED_METADATA)
                                    .name(RawCloudEntityTest.NAME)
                                    .uris(EXPECTED_URIS)
                                    .memory(MEMORY)
                                    .diskQuota(DISK_QUOTA)
                                    .instances(INSTANCES)
                                    .runningInstances(RUNNING_INSTANCES)
                                    .state(EXPECTED_STATE)
                                    .packageState(EXPECTED_PACKAGE_STATE)
                                    .stagingError(STAGING_ERROR)
                                    .staging(staging)
                                    .services(EXPECTED_SERVICES)
                                    .env(EXPECTED_ENVIRONMENT)
                                    .space(SPACE)
                                    .build();
}
 
Example #4
Source File: RawCloudApplication.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private static Staging parseStaging(SummaryApplicationResponse summary, Derivable<CloudStack> stack) {
    return ImmutableStaging.builder()
                           .addBuildpack(summary.getBuildpack())
                           .command(summary.getCommand())
                           .detectedBuildpack(summary.getDetectedBuildpack())
                           .healthCheckHttpEndpoint(summary.getHealthCheckHttpEndpoint())
                           .healthCheckTimeout(summary.getHealthCheckTimeout())
                           .healthCheckType(summary.getHealthCheckType())
                           .isSshEnabled(summary.getEnableSsh())
                           .dockerInfo(parseDockerInfo(summary))
                           .stack(parseStackName(stack))
                           .build();
}
 
Example #5
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
@Override
public void updateApplicationStaging(String applicationName, Staging staging) {
    UUID applicationGuid = getRequiredApplicationGuid(applicationName);
    UpdateApplicationRequest.Builder requestBuilder = UpdateApplicationRequest.builder();
    requestBuilder.applicationId(applicationGuid.toString());
    if (staging != null) {
        requestBuilder.buildpack(staging.getBuildpack())
                      .command(staging.getCommand())
                      .healthCheckHttpEndpoint(staging.getHealthCheckHttpEndpoint())
                      .healthCheckTimeout(staging.getHealthCheckTimeout())
                      .healthCheckType(staging.getHealthCheckType())
                      .enableSsh(staging.isSshEnabled());
        String stackName = staging.getStack();
        if (stackName != null) {
            UUID stackGuid = getStack(stackName).getMetadata()
                                                .getGuid();
            requestBuilder.stackId(stackGuid.toString());
        }
        if (staging.getDockerInfo() != null) {
            requestBuilder.dockerImage(staging.getDockerInfo()
                                              .getImage());
            DockerCredentials dockerCredentials = staging.getDockerInfo()
                                                         .getCredentials();
            if (dockerCredentials != null) {
                requestBuilder.dockerCredentials(org.cloudfoundry.client.v2.applications.DockerCredentials.builder()
                                                                                                          .username(dockerCredentials.getUsername())
                                                                                                          .password(dockerCredentials.getPassword())
                                                                                                          .build());
            }
        }
    }
    delegate.applicationsV2()
            .update(requestBuilder.build())
            .block();

    if (shouldUpdateWithV3Buildpacks(staging)) {
        updateBuildpacks(applicationGuid, staging.getBuildpacks());
    }
}
 
Example #6
Source File: LoggingCloudControllerClient.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Override
public void createApplication(String applicationName, Staging staging, Integer disk, Integer memory, List<String> uris,
                              DockerInfo dockerInfo) {
    logger.debug(Messages.CREATING_APPLICATION_0_WITH_DISK_QUOTA_1_MEMORY_2_URIS_3_AND_STAGING_4, applicationName, disk, memory, uris,
                 SecureSerialization.toJson(staging));
    delegate.createApplication(applicationName, staging, disk, memory, uris, dockerInfo);
}
 
Example #7
Source File: RawCloudApplicationTest.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private static Staging buildStaging() {
    return ImmutableStaging.builder()
                           .buildpacks(Arrays.asList(BUILDPACK))
                           .command(COMMAND)
                           .detectedBuildpack(DETECTED_BUILDPACK)
                           .dockerInfo(DOCKER_INFO)
                           .healthCheckHttpEndpoint(HEALTH_CHECK_HTTP_ENDPOINT)
                           .healthCheckTimeout(HEALTH_CHECK_TIMEOUT)
                           .healthCheckType(HEALTH_CHECK_TYPE)
                           .isSshEnabled(SSH_ENABLED)
                           .stack(STACK_NAME)
                           .build();
}
 
Example #8
Source File: CloudControllerClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
@Override
public void updateApplicationStaging(String applicationName, Staging staging) {
    handleExceptions(() -> delegate.updateApplicationStaging(applicationName, staging));
}
 
Example #9
Source File: ResilientCloudControllerClient.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String applicationName, Staging staging, Integer memory, List<String> uris) {
    executeWithRetry(() -> delegate.createApplication(applicationName, staging, memory, uris));
}
 
Example #10
Source File: ResilientCloudControllerClient.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
public void updateApplicationStaging(String applicationName, Staging staging) {
    executeWithRetry(() -> delegate.updateApplicationStaging(applicationName, staging));
}
 
Example #11
Source File: ResilientCloudControllerClient.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String applicationName, Staging staging, Integer disk, Integer memory, List<String> uris,
                              DockerInfo dockerInfo) {
    executeWithRetry(() -> delegate.createApplication(applicationName, staging, disk, memory, uris, dockerInfo));
}
 
Example #12
Source File: StagingApplicationAttributeUpdater.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean shouldUpdateAttribute(CloudApplication existingApplication, CloudApplication application) {
    Staging staging = application.getStaging();
    Staging existingStaging = existingApplication.getStaging();
    return hasStagingChanged(staging, existingStaging);
}
 
Example #13
Source File: LoggingCloudControllerClient.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
public void updateApplicationStaging(String applicationName, Staging staging) {
    logger.debug(Messages.UPDATING_STAGING_OF_APPLICATION_0_TO_1, applicationName, SecureSerialization.toJson(staging));
    delegate.updateApplicationStaging(applicationName, staging);
}
 
Example #14
Source File: LoggingCloudControllerClient.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String applicationName, Staging staging, Integer memory, List<String> uris) {
    logger.debug(Messages.CREATING_APPLICATION_0_WITH_MEMORY_1_URIS_2_AND_STAGING_3, applicationName, memory, uris,
                 SecureSerialization.toJson(staging));
    delegate.createApplication(applicationName, staging, memory, uris);
}
 
Example #15
Source File: RawCloudApplicationTest.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private static CloudApplication buildApplicationWithoutDockerCredentials() {
    Staging staging = buildStaging();
    Staging stagingWithoutDockerCredentials = ImmutableStaging.copyOf(staging)
                                                              .withDockerInfo(DOCKER_INFO_WITHOUT_CREDENTIALS);
    return buildApplication(stagingWithoutDockerCredentials);
}
 
Example #16
Source File: RawCloudApplicationTest.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private static CloudApplication buildApplicationWithoutDockerInfo() {
    Staging staging = buildStaging();
    Staging stagingWithoutDockerInfo = ImmutableStaging.copyOf(staging)
                                                       .withDockerInfo(null);
    return buildApplication(stagingWithoutDockerInfo);
}
 
Example #17
Source File: CloudControllerClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String applicationName, Staging staging, Integer disk, Integer memory, List<String> uris,
                              DockerInfo dockerInfo) {
    handleExceptions(() -> delegate.createApplication(applicationName, staging, disk, memory, uris, dockerInfo));
}
 
Example #18
Source File: CloudControllerClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String applicationName, Staging staging, Integer memory, List<String> uris) {
    handleExceptions(() -> delegate.createApplication(applicationName, staging, memory, uris));
}
 
Example #19
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private boolean shouldUpdateWithV3Buildpacks(Staging staging) {
    return staging.getBuildpacks()
                  .size() > 1;
}
 
Example #20
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String name, Staging staging, Integer diskQuota, Integer memory, List<String> uris,
                              DockerInfo dockerInfo) {
    CreateApplicationRequest.Builder requestBuilder = CreateApplicationRequest.builder()
                                                                              .spaceId(getTargetSpaceGuid().toString())
                                                                              .name(name)
                                                                              .memory(memory)
                                                                              .diskQuota(diskQuota)
                                                                              .instances(1)
                                                                              .state(CloudApplication.State.STOPPED.toString());
    if (dockerInfo != null) {
        requestBuilder.dockerImage(dockerInfo.getImage());
        DockerCredentials dockerCredentials = dockerInfo.getCredentials();
        if (dockerCredentials != null) {
            requestBuilder.dockerCredentials(org.cloudfoundry.client.v2.applications.DockerCredentials.builder()
                                                                                                      .username(dockerCredentials.getUsername())
                                                                                                      .password(dockerCredentials.getPassword())
                                                                                                      .build());
        }
    }
    if (staging != null) {
        requestBuilder.buildpack(staging.getBuildpack())
                      .command(staging.getCommand())
                      .healthCheckHttpEndpoint(staging.getHealthCheckHttpEndpoint())
                      .healthCheckTimeout(staging.getHealthCheckTimeout())
                      .healthCheckType(staging.getHealthCheckType())
                      .enableSsh(staging.isSshEnabled());
        String stackName = staging.getStack();
        if (stackName != null) {
            CloudStack stack = getStack(stackName);
            UUID stackGuid = stack.getMetadata()
                                  .getGuid();
            requestBuilder.stackId(stackGuid.toString());
        }
    }

    CreateApplicationResponse response = delegate.applicationsV2()
                                                 .create(requestBuilder.build())
                                                 .block();
    UUID newAppGuid = UUID.fromString(response.getMetadata()
                                              .getId());

    if (shouldUpdateWithV3Buildpacks(staging)) {
        updateBuildpacks(newAppGuid, staging.getBuildpacks());
    }

    if (!CollectionUtils.isEmpty(uris)) {
        addUris(uris, newAppGuid);
    }
}
 
Example #21
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
@Override
public void createApplication(String name, Staging staging, Integer memory, List<String> uris) {
    createApplication(name, staging, null, memory, uris, null);
}
 
Example #22
Source File: CloudControllerClient.java    From cf-java-client-sap with Apache License 2.0 2 votes vote down vote up
/**
 * Create application.
 *
 * @param applicationName application name
 * @param staging staging info
 * @param memory memory to use in MB
 * @param uris list of URIs for the app
 * @param serviceInstanceNames list of service instance names to bind to app
 */
void createApplication(String applicationName, Staging staging, Integer memory, List<String> uris);
 
Example #23
Source File: CloudControllerClient.java    From cf-java-client-sap with Apache License 2.0 2 votes vote down vote up
/**
 * Update application staging information.
 *
 * @param applicationName name of appplication
 * @param staging staging information for the app
 */
void updateApplicationStaging(String applicationName, Staging staging);
 
Example #24
Source File: CloudControllerClient.java    From cf-java-client-sap with Apache License 2.0 2 votes vote down vote up
/**
 * Create application.
 *
 * @param applicationName application name
 * @param staging staging info
 * @param disk disk quota to use in MB
 * @param memory memory to use in MB
 * @param uris list of URIs for the app
 * @param serviceInstanceNames list of service instance names to bind to app
 * @param dockerInfo docker params(image, username, password)
 */
void createApplication(String applicationName, Staging staging, Integer disk, Integer memory, List<String> uris, DockerInfo dockerInfo);
 
Example #25
Source File: CloudControllerRestClient.java    From cf-java-client-sap with Apache License 2.0 votes vote down vote up
void updateApplicationStaging(String applicationName, Staging staging); 
Example #26
Source File: CloudControllerRestClient.java    From cf-java-client-sap with Apache License 2.0 votes vote down vote up
void createApplication(String applicationName, Staging staging, Integer disk, Integer memory, List<String> uris, DockerInfo dockerInfo); 
Example #27
Source File: CloudControllerRestClient.java    From cf-java-client-sap with Apache License 2.0 votes vote down vote up
void createApplication(String applicationName, Staging staging, Integer memory, List<String> uris);