use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class ResourceEquality method equals.
public static boolean equals(Object left, Object right) {
if (right == left) {
return true;
}
if (!(left instanceof IResource)) {
throw new IllegalArgumentException();
}
IResource thiz = (IResource) left;
if (right == null || right.getClass() != left.getClass()) {
return false;
}
IResource other = (IResource) right;
return thiz.getNamespaceName().equals(other.getNamespaceName()) && thiz.getKind().equals(other.getKind()) && thiz.getName().equals(other.getName());
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftLaunchController method pollState.
protected int pollState(IProgressMonitor monitor) {
IResource resource = null;
Exception e = null;
resource = OpenShiftServerUtils.getResource(getServer(), monitor);
if (resource == null) {
OpenShiftCoreActivator.pluginLog().logError("The OpenShift resource for server " + getServer().getName() + " could not be reached.", e);
return IServer.STATE_STOPPED;
}
return IServer.STATE_STARTED;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftServerUtils method createRSync.
/**
* Creates an {@link RSync}
*
* @param server the {@link IServer} on which the {@code rsync} operation will be performed
* @return the {@link RSync} to be used to execute the command.
* @throws CoreException
*/
public static RSync createRSync(final IServer server, IProgressMonitor monitor) throws CoreException {
final IResource resource = getResourceChecked(server, monitor);
String podPath = getOrLoadPodPath(server, resource);
return createRSync(resource, podPath, server);
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftServerUtils method getResource.
/**
* Returns the OpenShift resource (service, replication controller) for the
* given server. Returns {@code null} if none was found.
* It gets the resource name and type from server settings and requests the
* resource from the OpenShit server. It should thus <strong>NOT</strong> be called from the
* UI thread.
*
* @param server
* the server (attributes) to get the resource name from
* @param connection
* the connection (to the OpenShift server) to retrieve the resource
* from
* @return the OpenShift resource
*/
public static IResource getResource(IServerAttributes server, Connection connection, IProgressMonitor monitor) {
if (connection == null) {
return null;
}
String uniqueId = getResourceUniqueId(server);
String projectName = OpenShiftResourceUniqueId.getProjectName(uniqueId);
String kind = OpenShiftResourceUniqueId.getKind(uniqueId);
List<IResource> resources = connection.getResources(kind, projectName);
IResource resource = OpenShiftResourceUniqueId.getByUniqueId(uniqueId, resources);
if (resource != null) {
WatchManager.getInstance().startWatch(resource.getProject(), connection);
}
return resource;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenshiftJMXConnectionProvider method computeJolokiaURL.
protected String computeJolokiaURL(IServer server) {
IResource resource = OpenShiftServerUtils.getResource(server, new NullProgressMonitor());
if (resource != null) {
String projName = resource.getNamespaceName();
List<IPod> pods = ResourceUtils.getPodsFor(resource, resource.getProject().getResources(ResourceKind.POD));
if (!pods.isEmpty()) {
String podName = pods.get(0).getName();
String host = server.getHost();
String portUrlPart = getOpenShiftPort(server);
String jolokiaPort = getJolokiaPort(pods.get(0));
return "https://" + host + portUrlPart + "/api/v1/namespaces/" + projName + "/pods/https:" + podName + ":" + jolokiaPort + "/proxy/jolokia/";
}
}
return null;
}
Aggregations