Search in sources :

Example 1 with OpenShiftProvider

use of org.guvnor.ala.openshift.model.OpenShiftProvider 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 2 with OpenShiftProvider

use of org.guvnor.ala.openshift.model.OpenShiftProvider 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);
}
Also used : OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 3 with OpenShiftProvider

use of org.guvnor.ala.openshift.model.OpenShiftProvider in project kie-wb-common by kiegroup.

the class RuntimeEndpointsTestIT method checkOpenShiftService.

/**
 * Can be used if internal to red hat.
 * TODO: replace with more lightweight image and non-internal (minishift?) environment
 * @throws Exception
 */
@Ignore
public void checkOpenShiftService() throws Exception {
    Client client = ClientBuilder.newClient();
    WebTarget target = client.target(APP_URL);
    ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
    RuntimeProvisioningService proxy = restEasyTarget.proxy(RuntimeProvisioningService.class);
    ProviderTypeList allProviderTypes = proxy.getProviderTypes(0, 10, "", true);
    assertNotNull(allProviderTypes);
    assertEquals(3, allProviderTypes.getItems().size());
    OpenShiftProviderConfigImpl openshiftProviderConfig = createProviderConfig();
    proxy.registerProvider(openshiftProviderConfig);
    ProviderList allProviders = proxy.getProviders(0, 10, "", true);
    assertEquals(1, allProviders.getItems().size());
    assertTrue(allProviders.getItems().get(0) instanceof OpenShiftProvider);
    OpenShiftProvider openshiftProvider = (OpenShiftProvider) allProviders.getItems().get(0);
    OpenShiftRuntimeConfig runtimeConfig = createRuntimeConfig(openshiftProvider, "coss1");
    @SuppressWarnings("unused") OpenShiftRuntime openshiftRuntime = getOpenShiftRuntime(proxy, 0, null);
    String runtimeId = proxy.newRuntime(runtimeConfig);
    openshiftRuntime = getOpenShiftRuntime(proxy, 1, OpenShiftRuntimeState.READY);
    proxy.startRuntime(runtimeId);
    openshiftRuntime = getOpenShiftRuntime(proxy, 1, OpenShiftRuntimeState.RUNNING);
    proxy.stopRuntime(runtimeId);
    openshiftRuntime = getOpenShiftRuntime(proxy, 1, OpenShiftRuntimeState.READY);
    proxy.destroyRuntime(runtimeId, true);
    openshiftRuntime = getOpenShiftRuntime(proxy, 0, null);
}
Also used : ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) RuntimeProvisioningService(org.guvnor.ala.services.api.RuntimeProvisioningService) OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) OpenShiftProviderConfigImpl(org.guvnor.ala.openshift.config.impl.OpenShiftProviderConfigImpl) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) OpenShiftRuntimeConfig(org.guvnor.ala.openshift.config.OpenShiftRuntimeConfig) Ignore(org.junit.Ignore)

Example 4 with OpenShiftProvider

use of org.guvnor.ala.openshift.model.OpenShiftProvider 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)

Example 5 with OpenShiftProvider

use of org.guvnor.ala.openshift.model.OpenShiftProvider in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeMarshallerTest method getValue.

@Override
public OpenShiftRuntime getValue() {
    OpenShiftProvider providerId = createOpenShiftProvider();
    OpenShiftRuntimeConfig runtimeConfig = new ContextAwareOpenShiftRuntimeExecConfig(RUNTIME_NAME, providerId, APPLICATION_NAME, KIE_SERVER_CONTAINER_DEPLOYMENT, PROJECT_NAME, RESOURCE_SECRETS_URI, RESOURCE_STREAMS_URI, RESOURCE_TEMPLATE_NAME, RESOURCE_TEMPLATE_PARAM_DELIMITER, RESOURCE_TEMPLATE_PARAM_ASSIGNER, RESOURCE_TEMPLATE_PARAM_VALUES, RESOURCE_TEMPLATE_URI, SERVICE_NAME);
    return new OpenShiftRuntime(RUNTIME_ID, RUNTIME_NAME, runtimeConfig, providerId, new OpenShiftRuntimeEndpoint(PROTOCOL, HOST, PORT, CONTEXT), new OpenShiftRuntimeInfo(runtimeConfig), new OpenShiftRuntimeState(STATE, STARTED_AT));
}
Also used : ContextAwareOpenShiftRuntimeExecConfig(org.guvnor.ala.openshift.config.impl.ContextAwareOpenShiftRuntimeExecConfig) OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) OpenShiftProviderImplMarshallerTest.createOpenShiftProvider(org.guvnor.ala.openshift.marshalling.OpenShiftProviderImplMarshallerTest.createOpenShiftProvider) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftRuntimeState(org.guvnor.ala.openshift.model.OpenShiftRuntimeState) OpenShiftRuntimeInfo(org.guvnor.ala.openshift.model.OpenShiftRuntimeInfo) OpenShiftRuntimeEndpoint(org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint) OpenShiftRuntimeConfig(org.guvnor.ala.openshift.config.OpenShiftRuntimeConfig)

Aggregations

OpenShiftProvider (org.guvnor.ala.openshift.model.OpenShiftProvider)7 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)3 ProvisioningException (org.guvnor.ala.exceptions.ProvisioningException)2 OpenShiftClient (org.guvnor.ala.openshift.access.OpenShiftClient)2 OpenShiftClientException (org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException)2 OpenShiftProviderConfig (org.guvnor.ala.openshift.config.OpenShiftProviderConfig)2 OpenShiftRuntimeConfig (org.guvnor.ala.openshift.config.OpenShiftRuntimeConfig)2 OpenShiftRuntimeEndpoint (org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint)2 OpenShiftRuntimeInfo (org.guvnor.ala.openshift.model.OpenShiftRuntimeInfo)2 OpenShiftRuntimeState (org.guvnor.ala.openshift.model.OpenShiftRuntimeState)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 DefaultOpenShiftClient (io.fabric8.openshift.client.DefaultOpenShiftClient)1 Client (javax.ws.rs.client.Client)1 WebTarget (javax.ws.rs.client.WebTarget)1 ProviderConfig (org.guvnor.ala.config.ProviderConfig)1 RuntimeOperationException (org.guvnor.ala.exceptions.RuntimeOperationException)1 ContextAwareOpenShiftRuntimeExecConfig (org.guvnor.ala.openshift.config.impl.ContextAwareOpenShiftRuntimeExecConfig)1 OpenShiftProviderConfigImpl (org.guvnor.ala.openshift.config.impl.OpenShiftProviderConfigImpl)1 OpenShiftProviderImplMarshallerTest.createOpenShiftProvider (org.guvnor.ala.openshift.marshalling.OpenShiftProviderImplMarshallerTest.createOpenShiftProvider)1 OpenShiftProviderImpl (org.guvnor.ala.openshift.model.OpenShiftProviderImpl)1