Search in sources :

Example 51 with IResource

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());
}
Also used : IResource(com.openshift.restclient.model.IResource)

Example 52 with IResource

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;
}
Also used : IResource(com.openshift.restclient.model.IResource) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) OpenShiftServerUtils.toCoreException(org.jboss.tools.openshift.core.server.OpenShiftServerUtils.toCoreException) IOException(java.io.IOException)

Example 53 with IResource

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);
}
Also used : IResource(com.openshift.restclient.model.IResource)

Example 54 with IResource

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;
}
Also used : IResource(com.openshift.restclient.model.IResource)

Example 55 with IResource

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IResource(com.openshift.restclient.model.IResource) IPod(com.openshift.restclient.model.IPod)

Aggregations

IResource (com.openshift.restclient.model.IResource)101 Test (org.junit.Test)32 Connection (org.jboss.tools.openshift.core.connection.Connection)27 IProject (com.openshift.restclient.model.IProject)14 IStatus (org.eclipse.core.runtime.IStatus)12 Collection (java.util.Collection)10 ServerResourceViewModel (org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel)9 IReplicationController (com.openshift.restclient.model.IReplicationController)8 IService (com.openshift.restclient.model.IService)8 ArrayList (java.util.ArrayList)8 CoreException (org.eclipse.core.runtime.CoreException)8 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)7 Status (org.eclipse.core.runtime.Status)7 ISelection (org.eclipse.jface.viewers.ISelection)7 OpenShiftException (com.openshift.restclient.OpenShiftException)6 ResourceKind (com.openshift.restclient.ResourceKind)6 IPod (com.openshift.restclient.model.IPod)6 List (java.util.List)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IBuildConfig (com.openshift.restclient.model.IBuildConfig)5