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));
}
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));
}
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());
}
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());
}
Aggregations