Package io.fabric8.patch

Examples of io.fabric8.patch.Result


    @Override
    public Result execute(UIExecutionContext context) throws Exception {
        Kubernetes kubernetes = getKubernetes();

        String podIdText = podId.getValue();
        PodSchema podInfo = kubernetes.getPod(podIdText);
        if (podInfo == null) {
            System.out.println("No pod for id: " + podIdText);
        } else {
            executePod(podInfo, podIdText);
        }
View Full Code Here


public class KubernetesHelperTest {

  @Test
  public void testRemoveEmptyPods() throws Exception {
   
    PodSchema pod1 = new PodSchema();
    pod1.setId("test1");
   
    PodSchema pod2 = new PodSchema();
   
    PodListSchema podSchema = new PodListSchema();
    podSchema.getItems().add(pod1);
    podSchema.getItems().add(pod2);
   
View Full Code Here

    @Override
    public Result execute(UIExecutionContext uiExecutionContext) throws Exception {
        Kubernetes kubernetes = getKubernetes();

        ReplicationControllerListSchema replicationControllers = kubernetes.getReplicationControllers();
        printReplicationControllers(replicationControllers, System.out);
        return null;
    }
View Full Code Here

        // populate autocompletion options
        replicationControllerId.setCompleter(new UICompleter<String>() {
            @Override
            public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
                List<String> list = new ArrayList<String>();
                ReplicationControllerListSchema replicationControllers = getKubernetes().getReplicationControllers();
                if (replicationControllers != null) {
                    List<ReplicationControllerSchema> items = replicationControllers.getItems();
                    if (items != null) {
                        for (ReplicationControllerSchema item : items) {
                            String id = item.getId();
                            list.add(id);
                        }
View Full Code Here

    @Override
    public Result execute(UIExecutionContext context) throws Exception {
        Kubernetes kubernetes = getKubernetes();

        String idText = replicationControllerId.getValue();
        ReplicationControllerSchema replicationController = kubernetes.getReplicationController(idText);
        if (replicationController == null) {
            System.out.println("No replicationController for id: " + idText);
        } else {
            executeReplicationController(replicationController);
        }
View Full Code Here

        }
        String kuberneteMasterUrl = args[0];
        String podID = args[1];
        System.out.println("Looking up ReplicationController for pod ID: " + podID);
        KubernetesClient client = new KubernetesClient(kuberneteMasterUrl);
        ReplicationControllerSchema replicationController = client.getReplicationControllerForPod(podID);
        if (replicationController != null ){
            String id = replicationController.getId();
            System.out.println("Found replication controller: " + id);
        } else {
            System.out.println("Could not find replication controller!");
        }
    }
View Full Code Here

    }

    @Override
    public Result execute(UIExecutionContext uiExecutionContext) throws Exception {
        Kubernetes kubernetes = getKubernetes();
        ServiceListSchema services = kubernetes.getServices();
        printServices(services, System.out);
        return null;
    }
View Full Code Here

   
    public void refreshServices() {
        List<String> currentCache = new ArrayList<String>();
        currentCache.addAll(contextPathsCache);
        try {
            ServiceListSchema serviceListSchema = client.getServices();
            for (ServiceSchema schema : serviceListSchema.getItems()) {
                if (selectorMatch(schema.getSelector())) {
                    String contextPath = schema.getId();
                   
                    ServiceDTO dto = new ServiceDTO();
                    dto.setId(schema.getId());
View Full Code Here

* Parses the example JSON
*/
public class ParseServiceTest {
    @Test
    public void testParseFabric8MQService() throws Exception {
        ServiceSchema service = assertParseTestFile("fmq-service.json", ServiceSchema.class);
        Integer port = service.getPort();
        assertNotNull("port", port);
        IntOrString containerPort = service.getContainerPort();
        assertNotNull("containerPort", containerPort);

        String json = KubernetesHelper.toJson(service);
        System.out.println("Got JSON: " + json);
    }
View Full Code Here

            close(fos);
        }
    }

    void rollback(Patch patch, boolean force) throws PatchException {
        Result result = patch.getResult();
        if (result == null) {
            throw new PatchException("Patch " + patch.getId() + " is not installed");
        }
        Bundle[] allBundles = bundleContext.getBundles();
        List<BundleUpdate> badUpdates = new ArrayList<BundleUpdate>();
        for (BundleUpdate update : result.getUpdates()) {
            boolean found = false;
            Version v = Version.parseVersion(update.getNewVersion());
            for (Bundle bundle : allBundles) {
                if (stripSymbolicName(bundle.getSymbolicName()).equals(stripSymbolicName(update.getSymbolicName()))
                        && bundle.getVersion().equals(v)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                badUpdates.add(update);
            }
        }
        if (!badUpdates.isEmpty() && !force) {
            StringBuilder sb = new StringBuilder();
            sb.append("Unable to rollback patch ").append(patch.getId()).append(" because of the following missing bundles:\n");
            for (BundleUpdate up : badUpdates) {
                sb.append("\t").append(up.getSymbolicName()).append("/").append(up.getNewVersion()).append("\n");
            }
            throw new PatchException(sb.toString());
        }

        Map<Bundle, String> toUpdate = new HashMap<Bundle, String>();
        for (BundleUpdate update : result.getUpdates()) {
            Version v = Version.parseVersion(update.getNewVersion());
            for (Bundle bundle : allBundles) {
                if (stripSymbolicName(bundle.getSymbolicName()).equals(stripSymbolicName(update.getSymbolicName()))
                        && bundle.getVersion().equals(v)) {
                    toUpdate.put(bundle, update.getPreviousLocation());
                }
            }
        }
        try {
            applyChanges(toUpdate);
            writeFully(new File(System.getProperty("karaf.base"), "etc/startup.properties"), ((ResultImpl) result).getStartup());
            writeFully(new File(System.getProperty("karaf.base"), "etc/overrides.properties"), ((ResultImpl) result).getOverrides());
        } catch (Exception e) {
            throw new PatchException("Unable to rollback patch " + patch.getId() + ": " + e.getMessage(), e);
        }
        ((PatchImpl) patch).setResult(null);
        File file = new File(patchDir, result.getPatch().getId() + ".patch.result");
        file.delete();
    }
View Full Code Here

TOP

Related Classes of io.fabric8.patch.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.