Search in sources :

Example 1 with OpenShiftClient

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

the class OpenShiftAccessInterfaceImpl method newOpenShiftClient.

@Override
public OpenShiftClient newOpenShiftClient(final ProviderConfig providerConfig) {
    checkInstanceOf("providerConfig", providerConfig, OpenShiftProviderConfig.class);
    OpenShiftConfig clientConfig = buildOpenShiftConfig((OpenShiftProviderConfig) providerConfig);
    return new OpenShiftClient(new DefaultOpenShiftClient(clientConfig));
}
Also used : OpenShiftClient(org.guvnor.ala.openshift.access.OpenShiftClient) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) OpenShiftConfig(io.fabric8.openshift.client.OpenShiftConfig) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient)

Example 2 with OpenShiftClient

use of org.guvnor.ala.openshift.access.OpenShiftClient 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 3 with OpenShiftClient

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

the class OpenShiftExecutorTest method testProviderConfigReuse.

/**
 * Make sure we can reuse the provider for two different runtimes.
 * TODO: replace with more lightweight image and non-internal (minishift?) environment.
 * @throws Exception
 */
@Test
public void testProviderConfigReuse() throws Exception {
    OpenShiftProviderConfigImpl providerConfig = new OpenShiftProviderConfigImpl().clear();
    providerConfig.setName(getClass().getSimpleName());
    providerConfig.setKubernetesMaster("https://ce-os-rhel-master.usersys.redhat.com:8443");
    providerConfig.setKubernetesAuthBasicUsername("admin");
    providerConfig.setKubernetesAuthBasicPassword("admin");
    OpenShiftClient client = new OpenShiftAccessInterfaceImpl().newOpenShiftClient(providerConfig);
    OpenShiftRuntimeConfigImpl runtimeConfigA = createRuntimeConfig("tpcr1");
    OpenShiftRuntimeConfigImpl runtimeConfigB = createRuntimeConfig("tpcr2");
    client.create(runtimeConfigA);
    client.create(runtimeConfigB);
    client.destroy(runtimeConfigA.getRuntimeId().toString());
    client.destroy(runtimeConfigB.getRuntimeId().toString());
}
Also used : OpenShiftRuntimeConfigImpl(org.guvnor.ala.openshift.config.impl.OpenShiftRuntimeConfigImpl) OpenShiftAccessInterfaceImpl(org.guvnor.ala.openshift.access.impl.OpenShiftAccessInterfaceImpl) OpenShiftClient(org.guvnor.ala.openshift.access.OpenShiftClient) OpenShiftProviderConfigImpl(org.guvnor.ala.openshift.config.impl.OpenShiftProviderConfigImpl) Test(org.junit.Test)

Example 4 with OpenShiftClient

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

the class OpenShiftAccessInterfaceImpl method getOpenShiftClient.

@Override
public OpenShiftClient getOpenShiftClient(final ProviderId providerId) {
    if (!clientMap.containsKey(providerId.getId())) {
        checkInstanceOf("providerId", providerId, OpenShiftProvider.class);
        ProviderConfig providerConfig = ((OpenShiftProvider) providerId).getConfig();
        OpenShiftClient client = newOpenShiftClient(providerConfig);
        clientMap.put(providerId.getId(), client);
    }
    return clientMap.get(providerId.getId());
}
Also used : ProviderConfig(org.guvnor.ala.config.ProviderConfig) OpenShiftProviderConfig(org.guvnor.ala.openshift.config.OpenShiftProviderConfig) OpenShiftClient(org.guvnor.ala.openshift.access.OpenShiftClient) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider)

Aggregations

OpenShiftClient (org.guvnor.ala.openshift.access.OpenShiftClient)4 DefaultOpenShiftClient (io.fabric8.openshift.client.DefaultOpenShiftClient)2 OpenShiftProvider (org.guvnor.ala.openshift.model.OpenShiftProvider)2 OpenShiftConfig (io.fabric8.openshift.client.OpenShiftConfig)1 ProviderConfig (org.guvnor.ala.config.ProviderConfig)1 ProvisioningException (org.guvnor.ala.exceptions.ProvisioningException)1 OpenShiftClientException (org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException)1 OpenShiftAccessInterfaceImpl (org.guvnor.ala.openshift.access.impl.OpenShiftAccessInterfaceImpl)1 OpenShiftProviderConfig (org.guvnor.ala.openshift.config.OpenShiftProviderConfig)1 OpenShiftProviderConfigImpl (org.guvnor.ala.openshift.config.impl.OpenShiftProviderConfigImpl)1 OpenShiftRuntimeConfigImpl (org.guvnor.ala.openshift.config.impl.OpenShiftRuntimeConfigImpl)1 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)1 OpenShiftRuntimeEndpoint (org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint)1 OpenShiftRuntimeInfo (org.guvnor.ala.openshift.model.OpenShiftRuntimeInfo)1 OpenShiftRuntimeState (org.guvnor.ala.openshift.model.OpenShiftRuntimeState)1 Test (org.junit.Test)1