Search in sources :

Example 1 with OpenShiftClientException

use of org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException in project kie-wb-common by kiegroup.

the class OpenShiftClient method createFromTemplate.

private void createFromTemplate(OpenShiftRuntimeConfig runtimeConfig) throws OpenShiftClientException {
    OpenShiftTemplate template = new OpenShiftTemplate(this, runtimeConfig);
    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.putAll(OpenShiftParameters.fromRuntimeConfig(runtimeConfig));
    String kieServerContainerDeployment = runtimeConfig.getKieServerContainerDeployment();
    if (kieServerContainerDeployment != null && !kieServerContainerDeployment.trim().isEmpty()) {
        parameters.put(OpenShiftProperty.KIE_SERVER_CONTAINER_DEPLOYMENT.envKey(), kieServerContainerDeployment);
    }
    KubernetesList kubeList = template.process(parameters);
    if (kubeList != null && kubeList.getItems().size() > 0) {
        try {
            DeploymentConfig dc = getDeploymentConfig(kubeList, runtimeConfig.getServiceName());
            if (dc != null) {
                dc.getSpec().setReplicas(0);
            }
            String prjName = runtimeConfig.getProjectName();
            delegate.lists().inNamespace(prjName).create(kubeList);
        } catch (Throwable t) {
            throw new OpenShiftClientException(t.getMessage(), t);
        }
    }
}
Also used : OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) DoneableDeploymentConfig(io.fabric8.openshift.api.model.DoneableDeploymentConfig) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with OpenShiftClientException

use of org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeExecExecutor method destroy.

@Override
public void destroy(final RuntimeId runtimeId) {
    final Optional<OpenShiftProvider> _openshiftProvider = runtimeRegistry.getProvider(runtimeId.getProviderId(), OpenShiftProvider.class);
    if (!_openshiftProvider.isPresent()) {
        return;
    }
    OpenShiftProvider openshiftProvider = _openshiftProvider.get();
    try {
        LOG.info("Destroying runtime: " + runtimeId.getId());
        openshift.getOpenShiftClient(openshiftProvider).destroy(runtimeId.getId());
        LOG.info("Destroyed runtime: " + runtimeId.getId());
    } catch (OpenShiftClientException ex) {
        throw new RuntimeOperationException("Error Destroying runtime: " + runtimeId.getId(), ex);
    }
    runtimeRegistry.deregisterRuntime(runtimeId);
}
Also used : OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 3 with OpenShiftClientException

use of org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeExecExecutor method create.

private Optional<OpenShiftRuntime> create(final OpenShiftRuntimeConfig runtimeConfig) throws ProvisioningException {
    final Optional<OpenShiftProvider> _openshiftProvider = runtimeRegistry.getProvider(runtimeConfig.getProviderId(), OpenShiftProvider.class);
    if (!_openshiftProvider.isPresent()) {
        return Optional.empty();
    }
    OpenShiftProvider openshiftProvider = _openshiftProvider.get();
    OpenShiftClient openshiftClient = openshift.getOpenShiftClient(openshiftProvider);
    LOG.info("Creating runtime...");
    OpenShiftRuntimeState runtimeState;
    try {
        runtimeState = openshiftClient.create(runtimeConfig);
    } catch (OpenShiftClientException ex) {
        throw new ProvisioningException(ex.getMessage(), ex);
    }
    final String id = runtimeConfig.getRuntimeId().toString();
    LOG.info("Created runtime: " + id);
    OpenShiftRuntimeEndpoint endpoint = openshiftClient.getRuntimeEndpoint(id);
    return Optional.of(new OpenShiftRuntime(id, buildRuntimeName(runtimeConfig, id), runtimeConfig, openshiftProvider, endpoint, new OpenShiftRuntimeInfo(runtimeConfig), runtimeState));
}
Also used : OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) OpenShiftClient(org.guvnor.ala.openshift.access.OpenShiftClient) ProvisioningException(org.guvnor.ala.exceptions.ProvisioningException) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftRuntimeState(org.guvnor.ala.openshift.model.OpenShiftRuntimeState) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) OpenShiftRuntimeInfo(org.guvnor.ala.openshift.model.OpenShiftRuntimeInfo) OpenShiftRuntimeEndpoint(org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint)

Example 4 with OpenShiftClientException

use of org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeManager method pause.

@Override
public void pause(RuntimeId runtimeId) throws RuntimeOperationException {
    OpenShiftRuntime runtime = (OpenShiftRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        LOG.info("Pausing runtime: " + runtimeId.getId());
        openshift.getOpenShiftClient(runtime.getProviderId()).pause(runtime.getId());
        refresh(runtimeId);
        LOG.info("Paused runtime: " + runtimeId.getId());
    } catch (OpenShiftClientException ex) {
        LOG.error("Error Pausing runtime: " + runtimeId.getId(), ex);
        throw new RuntimeOperationException("Error Pausing runtime: " + runtimeId.getId(), ex);
    }
}
Also used : OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 5 with OpenShiftClientException

use of org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeManager method stop.

@Override
public void stop(RuntimeId runtimeId) throws RuntimeOperationException {
    OpenShiftRuntime runtime = (OpenShiftRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        LOG.info("Stopping runtime: " + runtimeId.getId());
        openshift.getOpenShiftClient(runtime.getProviderId()).stop(runtime.getId());
        refresh(runtimeId);
        LOG.info("Stopped runtime: " + runtimeId.getId());
    } catch (OpenShiftClientException ex) {
        LOG.error("Error Stopping runtime: " + runtimeId.getId(), ex);
        throw new RuntimeOperationException("Error Stopping runtime: " + runtimeId.getId(), ex);
    }
}
Also used : OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Aggregations

OpenShiftClientException (org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException)11 RuntimeOperationException (org.guvnor.ala.exceptions.RuntimeOperationException)6 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)6 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)4 OpenShiftRuntimeState (org.guvnor.ala.openshift.model.OpenShiftRuntimeState)3 OpenShiftProvider (org.guvnor.ala.openshift.model.OpenShiftProvider)2 OpenShiftRuntimeEndpoint (org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint)2 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 Service (io.fabric8.kubernetes.api.model.Service)1 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)1 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)1 DoneableDeploymentConfig (io.fabric8.openshift.api.model.DoneableDeploymentConfig)1 ImageStream (io.fabric8.openshift.api.model.ImageStream)1 Route (io.fabric8.openshift.api.model.Route)1 RoutePort (io.fabric8.openshift.api.model.RoutePort)1 RouteSpec (io.fabric8.openshift.api.model.RouteSpec)1 LinkedHashMap (java.util.LinkedHashMap)1 ProvisioningException (org.guvnor.ala.exceptions.ProvisioningException)1 OpenShiftClient (org.guvnor.ala.openshift.access.OpenShiftClient)1