Search in sources :

Example 6 with CreateSshContainerOptions

use of io.fabric8.service.ssh.CreateSshContainerOptions in project fabric8 by jboss-fuse.

the class SshAutoScaler method createContainers.

@Override
public void createContainers(AutoScaleRequest request) throws Exception {
    int count = request.getDelta();
    String profile = request.getProfile();
    String version = request.getVersion();
    FabricService fabricService = request.getFabricService();
    Container[] containers = fabricService.getContainers();
    FabricRequirements requirements = request.getFabricRequirements();
    List<? extends HostConfiguration> hostConfigurations = requirements.getSshHosts();
    HostProfileCounter hostProfileCounter = new HostProfileCounter();
    AutoScalers.createHostToProfileScaleMap(hostProfileCounter, hostConfigurations, containers);
    for (int i = 0; i < count; i++) {
        CreateSshContainerOptions.Builder builder = null;
        NameValidator nameValidator = Containers.createNameValidator(containers);
        String name = Containers.createAutoScaleContainerName(containers, profile, containerProvider.getScheme(), nameValidator);
        if (fabricService != null) {
            builder = createAutoScaleOptions(request, fabricService, hostProfileCounter);
        }
        if (builder != null) {
            final CreateSshContainerOptions.Builder configuredBuilder = builder.number(1).version(version).profiles(profile);
            CreateSshContainerOptions options = configuredBuilder.name(name).build();
            LOG.info("Creating container name " + name + " version " + version + " profile " + profile + " " + count + " container(s)");
            fabricService.createContainers(options);
        }
    }
}
Also used : Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) NameValidator(io.fabric8.api.NameValidator) FabricRequirements(io.fabric8.api.FabricRequirements) HostProfileCounter(io.fabric8.internal.autoscale.HostProfileCounter)

Aggregations

Session (com.jcraft.jsch.Session)5 FabricException (io.fabric8.api.FabricException)5 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)3 IOException (java.io.IOException)2 JSch (com.jcraft.jsch.JSch)1 Container (io.fabric8.api.Container)1 FabricRequirements (io.fabric8.api.FabricRequirements)1 FabricService (io.fabric8.api.FabricService)1 NameValidator (io.fabric8.api.NameValidator)1 HostProfileCounter (io.fabric8.internal.autoscale.HostProfileCounter)1 Properties (org.apache.felix.scr.annotations.Properties)1