Search in sources :

Example 36 with Container

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;
}
Also used : Container(io.fabric8.api.Container)

Example 37 with Container

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);
}
Also used : NodeState(io.fabric8.groups.NodeState) Stat(org.apache.zookeeper.data.Stat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 38 with Container

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;
}
Also used : BootstrapConfiguration(io.fabric8.zookeeper.bootstrap.BootstrapConfiguration) ZkDataStoreImpl(io.fabric8.service.ZkDataStoreImpl) ComponentConfigurer(io.fabric8.service.ComponentConfigurer) DataStoreBootstrapTemplate(io.fabric8.zookeeper.bootstrap.DataStoreBootstrapTemplate) AbstractRuntimeProperties(io.fabric8.api.scr.AbstractRuntimeProperties)

Example 39 with Container

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));
}
Also used : Container(io.fabric8.api.Container) ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 40 with Container

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;
}
Also used : ArrayList(java.util.ArrayList) ContainerDTO(io.fabric8.api.jmx.ContainerDTO)

Aggregations

Container (io.fabric8.api.Container)139 Test (org.junit.Test)75 FabricService (io.fabric8.api.FabricService)56 ArrayList (java.util.ArrayList)39 Container (io.fabric8.kubernetes.api.model.Container)38 IOException (java.io.IOException)38 Profile (io.fabric8.api.Profile)37 HashMap (java.util.HashMap)34 Map (java.util.Map)30 FabricException (io.fabric8.api.FabricException)27 BundleContext (org.osgi.framework.BundleContext)24 Version (io.fabric8.api.Version)23 File (java.io.File)23 HashSet (java.util.HashSet)20 LinkedList (java.util.LinkedList)17 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)16 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)16 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)15 Pod (io.fabric8.kubernetes.api.model.Pod)12 List (java.util.List)12