Search in sources :

Example 11 with DefaultOpenShiftClient

use of io.fabric8.openshift.client.DefaultOpenShiftClient in project jointware by isdream.

the class OpenshiftAPIExample method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DefaultOpenShiftClient client = createClient();
    client.pods();
    client.extensions().deployments();
    client.replicationControllers();
    client.secrets();
    MixedOperation<Deployment, DeploymentList, DoneableDeployment, ScalableResource<Deployment, DoneableDeployment>> deployment = client.extensions().deployments();
    System.out.println(deployment.list().getItems());
}
Also used : DoneableDeployment(io.fabric8.kubernetes.api.model.extensions.DoneableDeployment) ScalableResource(io.fabric8.kubernetes.client.dsl.ScalableResource) DeploymentList(io.fabric8.kubernetes.api.model.extensions.DeploymentList) Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) DoneableDeployment(io.fabric8.kubernetes.api.model.extensions.DoneableDeployment) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient)

Example 12 with DefaultOpenShiftClient

use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8-maven-plugin by fabric8io.

the class OpenshiftBuildServiceTest method testSuccessfulBuild.

@Test
public void testSuccessfulBuild() throws Exception {
    int nTries = 0;
    boolean bTestComplete = false;
    do {
        try {
            nTries++;
            BuildService.BuildServiceConfig config = defaultConfig.build();
            WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, false, false);
            OpenShiftMockServer mockServer = collector.getMockServer();
            DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
            LOG.info("Current write timeout is : {}", client.getHttpClient().writeTimeoutMillis());
            LOG.info("Current read timeout is : {}", client.getHttpClient().readTimeoutMillis());
            LOG.info("Retry on failure : {}", client.getHttpClient().retryOnConnectionFailure());
            OpenshiftBuildService service = new OpenshiftBuildService(client, logger, dockerServiceHub, config);
            service.build(image);
            // we should Foadd a better way to assert that a certain call has been made
            assertTrue(mockServer.getRequestCount() > 8);
            collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
            collector.assertEventsNotRecorded("patch-build-config");
            bTestComplete = true;
        } catch (Fabric8ServiceException exception) {
            Throwable rootCause = getRootCause(exception);
            logger.warn("A problem encountered while running test {}, retrying..", exception.getMessage());
            // Let's wait for a while, and then retry again
            if (rootCause != null && rootCause instanceof IOException) {
                continue;
            }
        }
    } while (nTries < MAX_TIMEOUT_RETRIES && !bTestComplete);
}
Also used : OpenShiftMockServer(io.fabric8.openshift.client.server.mock.OpenShiftMockServer) Fabric8ServiceException(io.fabric8.maven.core.service.Fabric8ServiceException) BuildService(io.fabric8.maven.core.service.BuildService) IOException(java.io.IOException) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) Test(org.junit.Test)

Example 13 with DefaultOpenShiftClient

use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8 by fabric8io.

the class TriggerBuild method main.

public static void main(String... args) {
    if (args.length < 1) {
        System.out.println("Usage: buildConfigName namespace secret type");
        return;
    }
    String name = args[0];
    String namespace = "default";
    if (args.length > 1) {
        namespace = args[1];
    }
    OpenShiftClient client = new DefaultOpenShiftClient();
    try {
        client.buildConfigs().inNamespace(namespace).withName(name).trigger(new WebHookTrigger(true, null));
    } catch (Exception e) {
        System.out.println("FAILED: " + e);
        e.printStackTrace();
    }
}
Also used : WebHookTrigger(io.fabric8.openshift.api.model.WebHookTrigger) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient)

Example 14 with DefaultOpenShiftClient

use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8 by fabric8io.

the class WatchBuilds method main.

public static void main(String... args) {
    String namespace = null;
    if (args.length > 0) {
        namespace = args[0];
    }
    String consoleLink = Links.getFabric8ConsoleLink();
    OpenShiftClient client = new DefaultOpenShiftClient();
    BuildListener buildListener = new BuildListener() {

        @Override
        public void onBuildFinished(BuildFinishedEvent event) {
            System.out.println("Build: " + event.getUid() + " for config: " + event.getConfigName() + " finished. Status: " + event.getStatus() + " link: " + event.getBuildLink());
        }
    };
    BuildWatcher watcher = new BuildWatcher(client, buildListener, namespace, consoleLink);
    long pollTime = 3000;
    watcher.schedule(pollTime);
    watcher.join();
}
Also used : BuildListener(io.fabric8.kubernetes.api.builds.BuildListener) BuildWatcher(io.fabric8.kubernetes.api.builds.BuildWatcher) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) BuildFinishedEvent(io.fabric8.kubernetes.api.builds.BuildFinishedEvent) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient)

Example 15 with DefaultOpenShiftClient

use of io.fabric8.openshift.client.DefaultOpenShiftClient in project fabric8 by jboss-fuse.

the class WatchBuilds method main.

public static void main(String... args) {
    String namespace = null;
    if (args.length > 0) {
        namespace = args[0];
    }
    String consoleLink = Links.getFabric8ConsoleLink();
    OpenShiftClient client = new DefaultOpenShiftClient();
    BuildListener buildListener = new BuildListener() {

        @Override
        public void onBuildFinished(BuildFinishedEvent event) {
            System.out.println("Build: " + event.getUid() + " for config: " + event.getConfigName() + " finished. Status: " + event.getStatus() + " link: " + event.getBuildLink());
        }
    };
    BuildWatcher watcher = new BuildWatcher(client, buildListener, namespace, consoleLink);
    long pollTime = 3000;
    watcher.schedule(pollTime);
    watcher.join();
}
Also used : BuildListener(io.fabric8.kubernetes.api.builds.BuildListener) BuildWatcher(io.fabric8.kubernetes.api.builds.BuildWatcher) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) BuildFinishedEvent(io.fabric8.kubernetes.api.builds.BuildFinishedEvent) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient)

Aggregations

DefaultOpenShiftClient (io.fabric8.openshift.client.DefaultOpenShiftClient)12 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)6 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 BuildFinishedEvent (io.fabric8.kubernetes.api.builds.BuildFinishedEvent)2 BuildListener (io.fabric8.kubernetes.api.builds.BuildListener)2 BuildWatcher (io.fabric8.kubernetes.api.builds.BuildWatcher)2 Config (io.fabric8.kubernetes.client.Config)2 ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)2 Build (io.fabric8.openshift.api.model.Build)2 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)2 WebHookTrigger (io.fabric8.openshift.api.model.WebHookTrigger)2 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)1 DeploymentList (io.fabric8.kubernetes.api.model.extensions.DeploymentList)1 DoneableDeployment (io.fabric8.kubernetes.api.model.extensions.DoneableDeployment)1 ScalableResource (io.fabric8.kubernetes.client.dsl.ScalableResource)1 BuildService (io.fabric8.maven.core.service.BuildService)1 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)1 OpenShiftConfig (io.fabric8.openshift.client.OpenShiftConfig)1 OpenShiftMockServer (io.fabric8.openshift.client.server.mock.OpenShiftMockServer)1 IOException (java.io.IOException)1