Search in sources :

Example 6 with IApplication

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());
        }
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication) ApplicationScale(com.openshift.client.ApplicationScale)

Example 7 with IApplication

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);
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication) IEmbeddedCartridge(com.openshift.client.cartridge.IEmbeddedCartridge)

Example 8 with IApplication

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());
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication) IDeployedStandaloneCartridge(com.openshift.client.cartridge.IDeployedStandaloneCartridge)

Example 9 with IApplication

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);
        }
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication) IEnvironmentVariable(com.openshift.client.IEnvironmentVariable) Map(java.util.Map)

Example 10 with IApplication

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();
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication)

Aggregations

IApplication (com.openshift.client.IApplication)25 CamelExchangeException (org.apache.camel.CamelExchangeException)23 IEnvironmentVariable (com.openshift.client.IEnvironmentVariable)5 IEmbeddedCartridge (com.openshift.client.cartridge.IEmbeddedCartridge)4 ApplicationScale (com.openshift.client.ApplicationScale)2 LatestEmbeddableCartridge (com.openshift.client.cartridge.query.LatestEmbeddableCartridge)2 IGear (com.openshift.client.IGear)1 IGearGroup (com.openshift.client.IGearGroup)1 IGearProfile (com.openshift.client.IGearProfile)1 OpenShiftException (com.openshift.client.OpenShiftException)1 IDeployedStandaloneCartridge (com.openshift.client.cartridge.IDeployedStandaloneCartridge)1 IEmbeddableCartridge (com.openshift.client.cartridge.IEmbeddableCartridge)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Endpoint (org.apache.camel.Endpoint)1 Exchange (org.apache.camel.Exchange)1