Search in sources :

Example 1 with IDomain

use of com.openshift.client.IDomain in project camel by apache.

the class OpenShiftConsumer method poll.

@Override
protected int poll() throws Exception {
    String openshiftServer = OpenShiftHelper.getOpenShiftServer(getEndpoint());
    IDomain domain = OpenShiftHelper.loginAndGetDomain(getEndpoint(), openshiftServer);
    if (domain == null) {
        return 0;
    }
    return doPollOnChange(domain);
}
Also used : IDomain(com.openshift.client.IDomain)

Example 2 with IDomain

use of com.openshift.client.IDomain in project camel by apache.

the class OpenShiftHelper method loginAndGetDomain.

public static IDomain loginAndGetDomain(OpenShiftEndpoint endpoint, String openshiftServer) {
    // grab all applications
    IOpenShiftConnection connection = new OpenShiftConnectionFactory().getConnection(endpoint.getClientId(), endpoint.getUsername(), endpoint.getPassword(), openshiftServer);
    IUser user = connection.getUser();
    IDomain domain;
    if (endpoint.getDomain() != null) {
        domain = user.getDomain(endpoint.getDomain());
    } else {
        domain = user.getDefaultDomain();
    }
    return domain;
}
Also used : IDomain(com.openshift.client.IDomain) IOpenShiftConnection(com.openshift.client.IOpenShiftConnection) IUser(com.openshift.client.IUser) OpenShiftConnectionFactory(com.openshift.client.OpenShiftConnectionFactory)

Example 3 with IDomain

use of com.openshift.client.IDomain in project camel by apache.

the class OpenShiftProducer method process.

@Override
public void process(Exchange exchange) throws Exception {
    String openshiftServer = OpenShiftHelper.getOpenShiftServer(getEndpoint());
    IDomain domain = OpenShiftHelper.loginAndGetDomain(getEndpoint(), openshiftServer);
    if (domain == null) {
        throw new CamelExchangeException("User has no domain with id " + getEndpoint().getDomain(), exchange);
    }
    OpenShiftOperation operation = exchange.getIn().getHeader(OpenShiftConstants.OPERATION, getEndpoint().getOperation(), OpenShiftOperation.class);
    switch(operation) {
        case start:
            doStart(exchange, domain);
            break;
        case stop:
            doStop(exchange, domain);
            break;
        case restart:
            doRestart(exchange, domain);
            break;
        case state:
            doState(exchange, domain);
            break;
        case getStandaloneCartridge:
            doGetStandaloneCartridge(exchange, domain);
            break;
        case getEmbeddedCartridges:
            doGetEmbeddedCartridges(exchange, domain);
            break;
        case getGitUrl:
            doGetGitUrl(exchange, domain);
            break;
        case addEmbeddedCartridge:
            doAddEmbeddedCartridge(exchange, domain);
            break;
        case removeEmbeddedCartridge:
            doRemoveEmbeddedCartridge(exchange, domain);
            break;
        case scaleUp:
            doScaleUp(exchange, domain);
            break;
        case scaleDown:
            doScaleDown(exchange, domain);
            break;
        case getDeploymentType:
            doGetDeploymentType(exchange, domain);
            break;
        case setDeploymentType:
            doSetDeploymentType(exchange, domain);
            break;
        case addEnvironmentVariable:
            doAddEnvironmentVariable(exchange, domain);
            break;
        case addMultipleEnvironmentVariables:
            doAddMultipleEnvironmentVariables(exchange, domain);
            break;
        case updateEnvironmentVariable:
            doUpdateEnvironmentVariable(exchange, domain);
            break;
        case getAllEnvironmentVariables:
            doGetAllEnvironmentVariables(exchange, domain);
            break;
        case getEnvironmentVariableValue:
            doGetEnvironmentVariableValue(exchange, domain);
            break;
        case removeEnvironmentVariable:
            doRemoveEnvironmentVariable(exchange, domain);
            break;
        case getGearProfile:
            doGetGearProfile(exchange, domain);
            break;
        case addAlias:
            doAddAlias(exchange, domain);
            break;
        case removeAlias:
            doRemoveAlias(exchange, domain);
            break;
        case getAliases:
            doGetAliases(exchange, domain);
            break;
        case list:
        default:
            // and do list by default
            if (getEndpoint().getMode().equals("json")) {
                doListJson(exchange, domain);
            } else {
                doListPojo(exchange, domain);
            }
            break;
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IDomain(com.openshift.client.IDomain)

Aggregations

IDomain (com.openshift.client.IDomain)3 IOpenShiftConnection (com.openshift.client.IOpenShiftConnection)1 IUser (com.openshift.client.IUser)1 OpenShiftConnectionFactory (com.openshift.client.OpenShiftConnectionFactory)1 CamelExchangeException (org.apache.camel.CamelExchangeException)1