use of com.openshift.restclient.ClientBuilder in project jbosstools-openshift by jbosstools.
the class ConnectionTest method should_not_equals_if_different_user.
@Test
public void should_not_equals_if_different_user() throws Exception {
// given
Connection two = new Connection(new ClientBuilder("https://localhost:8443").build(), null);
two.setUsername("bar");
// when
// then
assertThat(connection).isNotEqualTo(two);
}
use of com.openshift.restclient.ClientBuilder in project jbosstools-openshift by jbosstools.
the class VagrantPoller method checkOpenShiftHealth.
protected boolean checkOpenShiftHealth(String url, int timeout) throws OpenShiftNotReadyPollingException {
ISSLCertificateCallback sslCallback = new LazySSLCertificateCallback();
IClient client = new ClientBuilder(url).sslCertificateCallback(sslCallback).withConnectTimeout(timeout, TimeUnit.MILLISECONDS).build();
Exception e = null;
try {
if ("ok".equals(client.getServerReadyStatus()))
return true;
} catch (OpenShiftException ex) {
e = ex;
}
String msg = NLS.bind("The CDK VM is up and running, but OpenShift is unreachable at url {0}. " + "The VM may not have been registered successfully. Please check your console output for more information", url);
throw new OpenShiftNotReadyPollingException(CDKCoreActivator.statusFactory().errorStatus(CDKCoreActivator.PLUGIN_ID, msg, e, OpenShiftNotReadyPollingException.OPENSHIFT_UNREACHABLE_CODE));
}
use of com.openshift.restclient.ClientBuilder in project wildfly-swarm by wildfly-swarm.
the class ClientService method openshiftClient.
private IClient openshiftClient() throws IOException {
String kubeHost = serviceHost("kubernetes");
int kubePort = servicePort("kubernetes");
Path tokenFile = Paths.get("/var/run/secrets/kubernetes.io/serviceaccount/token");
String scheme = "http";
String token = null;
if (Files.exists(tokenFile)) {
token = new String(Files.readAllBytes(tokenFile));
scheme = "https";
}
return new ClientBuilder(scheme + "://" + kubeHost + ":" + kubePort).usingToken(token).build();
}
use of com.openshift.restclient.ClientBuilder in project jbosstools-openshift by jbosstools.
the class MinishiftPoller method checkOpenShiftHealth.
protected boolean checkOpenShiftHealth(String url, int timeout) throws OpenShiftNotReadyPollingException {
ISSLCertificateCallback sslCallback = new LazySSLCertificateCallback();
IClient client = new ClientBuilder(url).sslCertificateCallback(sslCallback).withConnectTimeout(timeout, TimeUnit.MILLISECONDS).build();
Exception e = null;
try {
String v = client.getServerReadyStatus();
if ("ok".equals(v))
return true;
} catch (OpenShiftException ex) {
e = ex;
}
String msg = NLS.bind("The CDK VM is up and running, but OpenShift is unreachable at url {0}. " + "The VM may not have been registered successfully. Please check your console output for more information", url);
throw new OpenShiftNotReadyPollingException(CDKCoreActivator.statusFactory().errorStatus(CDKCoreActivator.PLUGIN_ID, msg, e, OpenShiftNotReadyPollingException.OPENSHIFT_UNREACHABLE_CODE));
}
use of com.openshift.restclient.ClientBuilder in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method fulfill.
@Override
public void fulfill() {
this.connection = ConnectionUtils.getConnectionOrDefault(serviceSpec.connectionURL());
assertNotNull(NLS.bind("No connection for {0} exists", serviceSpec.connectionURL()), connection);
final String projectName = TestUtils.getValueOrDefault(serviceSpec.project(), DatastoreOS3.TEST_PROJECT);
assertTrue(NLS.bind("No project {0} exists on server {1}", projectName, connection.getHost()), OpenShift3NativeResourceUtils.hasProject(projectName, connection));
final String serviceName = serviceSpec.service();
final String templateName = serviceSpec.template();
IResourceFactory factory = new ClientBuilder(connection.getHost()).build().getResourceFactory();
try {
// try if template comes from a URL
URL url = new URL(templateName);
template = factory.create(url.openStream());
} catch (MalformedURLException ex) {
// template is not a URL, try a path to local file instead
if (new File(templateName).exists()) {
try {
template = factory.create(new FileInputStream(templateName));
} catch (FileNotFoundException e) {
throw new RedDeerException("Unable to read local template", e);
}
} else {
// it is not an external template
template = connection.getResource(ResourceKind.TEMPLATE, OpenShiftResources.OPENSHIFT_PROJECT, templateName);
}
} catch (IOException ex) {
throw new RedDeerException("Unable to read template from URL", ex);
}
assertNotNull(template);
this.service = getOrCreateService(projectName, serviceName, template);
if (serviceSpec.waitForBuild()) {
waitForResources(serviceName, projectName, service);
waitForUI(serviceName, projectName);
}
}
Aggregations