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);
}
}
}
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);
}
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));
}
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);
}
}
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);
}
}
Aggregations