/** * Returns all the current alive or pending profiles for the given profile */ public static List<Container> aliveOrPendingContainersForProfile(String profile, FabricService fabricService) { Container[] allContainers = fabricService.getContainers(); return aliveOrPendingContainersForProfile(profile, allContainers); }
private boolean containerExists(String containerName) { Container[] containers = fabricService.getContainers(); for (Container c : containers) { if (containerName.equals(c.getId())) { return true; } } return false; } }
public static Container getContainer(FabricService fabricService, String name) { Container[] containers = fabricService.getContainers(); for (Container container : containers) { if (container.getId().equals(name)) { return container; } } throw new IllegalArgumentException("Container " + name + " does not exist."); }
/** * Returns all the current alive and successful containers for the given profile which have completed provisioning */ public static List<Container> aliveAndSuccessfulContainersForProfile(String profile, FabricService fabricService) { Container[] allContainers = fabricService.getContainers(); return aliveAndSuccessfulContainersForProfile(profile, allContainers); }
/** * Returns all the current alive or pending profiles for the given profile */ public static List<Container> aliveOrPendingContainersForProfile(String version, String profile, FabricService fabricService) { Container[] allContainers = fabricService.getContainers(); return aliveOrPendingContainersForProfile(version, profile, allContainers); }
public static Container getContainer(FabricService fabricService, String name) { Container[] containers = fabricService.getContainers(); for (Container container : containers) { if (container.getId().equals(name)) { return container; } } throw new IllegalArgumentException("Container " + name + " does not exist."); }
public static boolean doesContainerExist(FabricService fabricService, String name) { Container[] containers = fabricService.getContainers(); for (Container container : containers) { if (container.getId().equals(name)) { return true; } } return false; }
public static Container getContainerIfExists(FabricService fabricService, String name) { Container[] containers = fabricService.getContainers(); for (Container container : containers) { if (container.getId().equals(name)) { return container; } } return null; }
public static boolean doesContainerExist(FabricService fabricService, String name) { Container[] containers = fabricService.getContainers(); for (Container container : containers) { if (container.getId().equals(name)) { return true; } } return false; }
/** * Returns all the current alive and successful containers for the given profile which have completed provisioning */ public static List<Container> aliveAndSuccessfulContainersForProfile(String version, String profile, FabricService fabricService) { Container[] allContainers = fabricService.getContainers(); return aliveAndSuccessfulContainersForProfile(version, profile, allContainers); }
public static Container getContainerIfExists(FabricService fabricService, String name) { Container[] containers = fabricService.getContainers(); for (Container container : containers) { if (container.getId().equals(name)) { return container; } } return null; }
/** * Returns a list of all available containers matching simple pattern where {@code *} matches any substring * and {@code ?} matches single character. */ protected List<String> matchedAvailableContainers(String pattern) { LinkedList<String> result = new LinkedList<String>(); for (Container c: this.fabricService.getContainers()) { String name = c.getId(); if (this.matches(pattern, name)) result.add(name); } return result; }
public Container[] getChildren() { List<Container> children = new ArrayList<Container>(); for (Container container : fabricService.getContainers()) { if (container.getParent() != null && getId().equals(container.getParent().getId())) { children.add(container); } } return children.toArray(new Container[children.size()]); }
/** * Returns the list of container IDs */ @GET @Path("containers") public Map<String, String> containers() { FabricService fabricService = getFabricService(); if (fabricService != null) { return mapToLinks(Containers.containerIds(fabricService.getContainers()), "/container/"); } else { noFabricService(); } return Collections.emptyMap(); }
/** * Returns the list of container IDs */ @GET @Path("containers") public Map<String, String> containers() { FabricService fabricService = getFabricService(); if (fabricService != null) { return mapToLinks(Containers.containerIds(fabricService.getContainers()), "/container/"); } else { noFabricService(); } return Collections.emptyMap(); }
@Override protected Object doExecute() throws Exception { Container[] containers = fabricService.getContainers(); List<String> versions = profileService.getVersions(); printVersions(containers, versions, fabricService.getDefaultVersionId(), System.out); return null; }
@Override public int complete(String buffer, int cursor, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); for (Container container : getFabricService().getContainers()) { if (apply(container)) { delegate.getStrings().add(container.getId()); } } return delegate.complete(buffer, cursor, candidates); }
@Override public int complete(String buffer, int cursor, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); for (Container container : getFabricService().getContainers()) { if (apply(container)) { delegate.getStrings().add(container.getId()); } } return delegate.complete(buffer, cursor, candidates); }
@Test public void testLocalFabricCluster() throws Exception { CommandSupport.executeCommand("fabric:create --force --clean -n"); FabricService fabricService = ServiceLocator.getRequiredService(FabricService.class); Container[] containers = fabricService.getContainers(); Assert.assertNotNull("Containers not null", containers); // Test that a provided default password exists ConfigurationAdmin configurationAdmin = ServiceLocator.getRequiredService(ConfigurationAdmin.class); org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration(io.fabric8.api.Constants.ZOOKEEPER_CLIENT_PID); Dictionary<String, Object> dictionary = configuration.getProperties(); Assert.assertEquals("Expected provided zookeeper password", PasswordEncoder.encode(ADMIN_PASSWORD), dictionary.get("zookeeper.password")); } }
@Test public void testLocalFabricCluster() throws Exception { CommandSupport.executeCommand("fabric:create --clean -n"); FabricService fabricService = ServiceLocator.getRequiredService(FabricService.class); Container[] containers = fabricService.getContainers(); Assert.assertNotNull("Containers not null", containers); //Test that a provided by command line password exists ConfigurationAdmin configurationAdmin = ServiceLocator.getRequiredService(ConfigurationAdmin.class); org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration(io.fabric8.api.Constants.ZOOKEEPER_CLIENT_PID); Dictionary<String, Object> dictionary = configuration.getProperties(); Assert.assertEquals("Expected provided zookeeper password", PasswordEncoder.encode(ADMIN_PASSWORD), dictionary.get("zookeeper.password")); } }