use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class ContainerResolverSetAction method doExecute.
@Override
protected Object doExecute() throws Exception {
if (containerIds == null || containerIds.isEmpty()) {
if (all) {
containerIds = new ArrayList<String>();
for (Container container : fabricService.getContainers()) {
containerIds.add(container.getId());
}
} else {
System.out.println("No container has been specified. Assuming the current container.");
containerIds = Arrays.asList(fabricService.getCurrentContainer().getId());
}
} else {
if (all) {
throw new IllegalArgumentException("Can not use --all with a list of containers simultaneously.");
}
}
for (String containerId : containerIds) {
Container container = fabricService.getContainer(containerId);
container.setResolver(resolver);
if (resolver.equalsIgnoreCase("manualip")) {
if (manualIp != null && !manualIp.isEmpty()) {
setData(getCurator(), ZkPath.CONTAINER_MANUAL_IP.getPath(containerId), manualIp);
}
}
}
return null;
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class ZooKeeperGroupTest method putChildData.
private static void putChildData(ZooKeeperGroup<NodeState> group, String path, String container) throws Exception {
NodeState node = new NodeState("test", container);
ByteArrayOutputStream data = new ByteArrayOutputStream();
new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).writeValue(data, node);
ChildData<NodeState> child = new ChildData<>(path, new Stat(), data.toByteArray(), node);
group.currentData.put(path, child);
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class GitDataStoreImplTestSupport method createGitDataStore.
protected GitDataStoreImpl createGitDataStore() throws Exception {
RuntimeProperties runtimeProperties = createMockRuntimeProperties();
CreateEnsembleOptions ensembleOptions = CreateEnsembleOptions.builder().zookeeperPassword("admin").build();
recursiveDelete(runtimeProperties.getDataPath().toFile());
BootstrapConfiguration.DataStoreOptions options = new BootstrapConfiguration.DataStoreOptions("root", new File("target/test-container"), zkURL, ensembleOptions);
runtimeProperties.putRuntimeAttribute(DataStoreTemplate.class, new DataStoreBootstrapTemplate(options));
FabricGitServiceImpl fabricGitService = new FabricGitServiceImpl();
fabricGitService.bindRuntimeProperties(runtimeProperties);
fabricGitService.activate();
ComponentConfigurer componentConfigurer = new ComponentConfigurer();
componentConfigurer.activate(null);
ZkDataStoreImpl zkDataStore = new ZkDataStoreImpl() {
@Override
public String getDefaultVersion() {
return "1.0";
}
};
zkDataStore.bindCurator(curator);
zkDataStore.bindRuntimeProperties(runtimeProperties);
zkDataStore.activateComponent();
final GitDataStoreImpl gitDataStore = new GitDataStoreImpl();
gitDataStore.bindConfigurer(componentConfigurer);
gitDataStore.bindGitService(fabricGitService);
gitDataStore.bindRuntimeProperties(runtimeProperties);
gitDataStore.bindGitProxyService(new GitProxyRegistrationHandler());
gitDataStore.bindCurator(curator);
gitDataStore.bindDataStore(zkDataStore);
gitDataStore.activate(new HashMap<String, Object>());
return gitDataStore;
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class FabricFeaturesServiceImpl method getAllProfilesOverlay.
/**
* Creates an aggregation of all available {@link Profile}s.
*/
private Profile getAllProfilesOverlay() {
Container container = fabricService.get().getCurrentContainer();
ProfileService profileService = fabricService.get().adapt(ProfileService.class);
Version version = container.getVersion();
Profile versionProfile = getVersionProfile(version);
return Profiles.getEffectiveProfile(fabricService.get(), profileService.getOverlayProfile(versionProfile));
}
use of io.fabric8.api.Container in project fabric8 by jboss-fuse.
the class Containers method aliveAndSuccessfulContainers.
/**
* Returns all the current alive and successful containers for the given profile which have completed provisioning
*/
public static List<ContainerDTO> aliveAndSuccessfulContainers(Iterable<ContainerDTO> allContainers) {
List<ContainerDTO> answer = new ArrayList<>();
for (ContainerDTO container : allContainers) {
boolean alive = container.isAlive();
boolean provisioningPending = container.isProvisioningPending();
String provisionResult = container.getProvisionResult();
boolean aliveAndProvisionSuccess = alive && !provisioningPending && Container.PROVISION_SUCCESS.equals(provisionResult);
if (aliveAndProvisionSuccess) {
answer.add(container);
}
}
return answer;
}
Aggregations