Search in sources :

Example 6 with ProvisioningException

use of org.guvnor.ala.exceptions.ProvisioningException in project kie-wb-common by kiegroup.

the class OpenShiftProviderConfigExecutor method apply.

@Override
public Optional<OpenShiftProvider> apply(final OpenShiftProviderConfig openshiftProviderConfig) {
    if (openshiftProviderConfig.getName() == null || openshiftProviderConfig.getName().isEmpty()) {
        throw new ProvisioningException("No name was provided for the OpenShiftProviderConfig.getName() " + "configuration parameter. You might probably have to properly set " + "the pipeline input parameter: " + ProviderConfig.PROVIDER_NAME);
    }
    Provider provider = runtimeRegistry.getProvider(openshiftProviderConfig.getName());
    OpenShiftProvider openshiftProvider;
    if (provider != null) {
        if (!(provider instanceof OpenShiftProvider)) {
            throw new ProvisioningException("The provider: " + openshiftProviderConfig.getName() + " must be an instance of " + OpenShiftProviderConfig.class + " but is: " + provider.getClass());
        } else {
            openshiftProvider = (OpenShiftProvider) provider;
        }
    } else {
        openshiftProvider = new OpenShiftProviderImpl(openshiftProviderConfig.getName(), openshiftProviderConfig);
        runtimeRegistry.registerProvider(openshiftProvider);
    }
    return Optional.of(openshiftProvider);
}
Also used : ProvisioningException(org.guvnor.ala.exceptions.ProvisioningException) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftProviderConfig(org.guvnor.ala.openshift.config.OpenShiftProviderConfig) Provider(org.guvnor.ala.runtime.providers.Provider) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftProviderImpl(org.guvnor.ala.openshift.model.OpenShiftProviderImpl)

Aggregations

ProvisioningException (org.guvnor.ala.exceptions.ProvisioningException)6 WildflyProvider (org.guvnor.ala.wildfly.model.WildflyProvider)3 Date (java.util.Date)2 OpenShiftProvider (org.guvnor.ala.openshift.model.OpenShiftProvider)2 Provider (org.guvnor.ala.runtime.providers.Provider)2 WildflyRuntimeEndpoint (org.guvnor.ala.wildfly.model.WildflyRuntimeEndpoint)2 DockerException (com.spotify.docker.client.DockerException)1 ContainerConfig (com.spotify.docker.client.messages.ContainerConfig)1 ContainerCreation (com.spotify.docker.client.messages.ContainerCreation)1 HostConfig (com.spotify.docker.client.messages.HostConfig)1 PortBinding (com.spotify.docker.client.messages.PortBinding)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DockerProvider (org.guvnor.ala.docker.model.DockerProvider)1 DockerRuntime (org.guvnor.ala.docker.model.DockerRuntime)1 DockerRuntimeEndpoint (org.guvnor.ala.docker.model.DockerRuntimeEndpoint)1 DockerRuntimeInfo (org.guvnor.ala.docker.model.DockerRuntimeInfo)1 DockerRuntimeState (org.guvnor.ala.docker.model.DockerRuntimeState)1