Search in sources :

Example 26 with Session

use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.

the class J4pClientProvider method lookup.

@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    KubernetesClient client = this.clientInstance.get();
    Session session = this.sessionInstance.get();
    JolokiaClients jolokiaClients = new JolokiaClients(client);
    String serviceName = getServiceName(qualifiers);
    String podName = getPodName(qualifiers);
    String replicationControllerName = getReplicationControllerName(qualifiers);
    if (Strings.isNotBlank(serviceName)) {
        Service service = client.services().inNamespace(session.getNamespace()).withName(serviceName).get();
        if (service != null) {
            return jolokiaClients.clientForService(service);
        }
    }
    if (Strings.isNotBlank(podName)) {
        Pod pod = client.pods().inNamespace(session.getNamespace()).withName(serviceName).get();
        if (pod != null) {
            return jolokiaClients.clientForPod(pod);
        }
    }
    if (Strings.isNotBlank(replicationControllerName)) {
        ReplicationController replicationController = client.replicationControllers().inNamespace(session.getNamespace()).withName(replicationControllerName).get();
        if (replicationController != null) {
            return jolokiaClients.clientForReplicationController(replicationController);
        }
    }
    return null;
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) Service(io.fabric8.kubernetes.api.model.Service) JolokiaClients(io.fabric8.kubernetes.jolokia.JolokiaClients) Session(io.fabric8.arquillian.kubernetes.Session)

Example 27 with Session

use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.

the class PodResourceProvider method lookup.

@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    KubernetesClient client = this.clientInstance.get();
    Session session = sessionInstance.get();
    String name = getPodName(qualifiers);
    if (name != null) {
        return client.pods().inNamespace(session.getNamespace()).withName(name).get();
    }
    // Gets the first pod found that matches the labels.
    Map<String, String> labels = getLabels(qualifiers);
    PodList list = client.pods().inNamespace(session.getNamespace()).withLabels(labels).list();
    List<Pod> pods = notNullList(list.getItems());
    if (!pods.isEmpty()) {
        return pods.get(0);
    }
    return null;
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) PodList(io.fabric8.kubernetes.api.model.PodList) Pod(io.fabric8.kubernetes.api.model.Pod) Session(io.fabric8.arquillian.kubernetes.Session)

Example 28 with Session

use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.

the class ReplicationControllerListResourceProvider method lookup.

@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    KubernetesClient client = this.clientInstance.get();
    Session session = sessionInstance.get();
    Map<String, String> labels = getLabels(qualifiers);
    if (labels.isEmpty()) {
        return client.replicationControllers().inNamespace(session.getNamespace()).list();
    } else {
        return client.replicationControllers().inNamespace(session.getNamespace()).withLabels(labels).list();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Session(io.fabric8.arquillian.kubernetes.Session)

Example 29 with Session

use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.

the class ReplicationControllerResourceProvider method lookup.

@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    KubernetesClient client = this.clientInstance.get();
    Session session = sessionInstance.get();
    String name = getReplicationControllerName(qualifiers);
    return client.replicationControllers().inNamespace(session.getNamespace()).withName(name).get();
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Session(io.fabric8.arquillian.kubernetes.Session)

Example 30 with Session

use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.

the class ServiceResourceProvider method lookup.

@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    KubernetesClient client = this.clientInstance.get();
    Session session = sessionInstance.get();
    String name = getServiceName(qualifiers);
    return client.services().inNamespace(session.getNamespace()).withName(name).get();
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Session(io.fabric8.arquillian.kubernetes.Session)

Aggregations

IOException (java.io.IOException)14 Session (io.fabric8.arquillian.kubernetes.Session)8 FabricException (io.fabric8.api.FabricException)7 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)7 Test (org.junit.Test)6 Session (com.jcraft.jsch.Session)5 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)5 File (java.io.File)5 Logger (io.fabric8.arquillian.kubernetes.log.Logger)4 Pod (io.fabric8.kubernetes.api.model.Pod)4 Service (io.fabric8.kubernetes.api.model.Service)4 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)4 ArrayList (java.util.ArrayList)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 FabricAuthenticationException (io.fabric8.api.FabricAuthenticationException)3 Util.readAsString (io.fabric8.arquillian.utils.Util.readAsString)3 ZooKeeperGroup (io.fabric8.groups.internal.ZooKeeperGroup)3 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)3 MultiException (io.fabric8.utils.MultiException)3 HashMap (java.util.HashMap)3