use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doScaleDown.
protected void doScaleDown(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
ApplicationScale scale = app.getApplicationScale();
if (scale.getValue().equals(ApplicationScale.NO_SCALE.getValue())) {
log.info("Scaling on application with id " + name + " is not enabled");
} else {
app.scaleDown();
ApplicationScale result = app.getApplicationScale();
exchange.getIn().setBody(result.getValue());
}
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doGetEmbeddedCartridges.
protected void doGetEmbeddedCartridges(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
List<IEmbeddedCartridge> p = app.getEmbeddedCartridges();
exchange.getIn().setBody(p);
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doGetStandaloneCartridge.
protected void doGetStandaloneCartridge(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
IDeployedStandaloneCartridge p = app.getCartridge();
exchange.getIn().setBody(p.getDisplayName());
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doAddMultipleEnvironmentVariables.
protected void doAddMultipleEnvironmentVariables(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
Map environmentVariables = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_MAP, getEndpoint().getApplication(), Map.class);
if (!app.canUpdateEnvironmentVariables()) {
throw new CamelExchangeException("The application with id " + name + " can't update Environment Variables", exchange);
}
if (ObjectHelper.isNotEmpty(environmentVariables)) {
Map<String, IEnvironmentVariable> result = app.addEnvironmentVariables(environmentVariables);
exchange.getIn().setBody(result);
} else {
throw new CamelExchangeException("Environment variables not correctly specified", exchange);
}
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doRestart.
protected void doRestart(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
app.restart();
}
}
Aggregations