Search in sources :

Example 21 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method setProfileAttribute.

@Override
public void setProfileAttribute(String versionId, String profileId, String attributeId, String value) {
    Profile profile = profileService.getRequiredProfile(versionId, profileId);
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
    builder.addAttribute(attributeId, value);
    profileService.updateProfile(builder.getProfile());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 22 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method deleteConfigurationFile.

@Override
public void deleteConfigurationFile(String versionId, String profileId, String fileName) {
    Profile profile = profileService.getRequiredProfile(versionId, profileId);
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
    builder.deleteFileConfiguration(fileName);
    profileService.updateProfile(builder.getProfile());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 23 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method createProfile.

@Override
public Map<String, Object> createProfile(String versionId, String profileId, List<String> parents) {
    ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId).addParents(parents);
    Profile profile = profileService.createProfile(builder.getProfile());
    return getProfile(versionId, profile.getId());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 24 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method createContainers.

@Override
public Map<String, String> createContainers(Map<String, Object> options) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Creating containers from JSON data: " + options);
    }
    String providerType = (String) options.get("providerType");
    if (providerType == null) {
        throw new RuntimeException("No providerType provided");
    }
    CreateContainerBasicOptions.Builder builder = null;
    ContainerProvider provider = fabricService.getValidProviders().get(providerType);
    if (provider == null) {
        throw new RuntimeException("Can't find valid provider of type: " + providerType);
    }
    Class<?> clazz = provider.getOptionsType();
    try {
        builder = (CreateContainerBasicOptions.Builder) clazz.getMethod("builder").invoke(null);
    } catch (Exception e) {
        LOG.warn("Failed to find builder type", e);
    }
    if (builder == null) {
        throw new RuntimeException("Unknown provider type : " + providerType);
    }
    ObjectMapper mapper = getObjectMapper();
    builder = mapper.convertValue(options, builder.getClass());
    builder.zookeeperPassword(fabricService.getZookeeperPassword());
    builder.zookeeperUrl(fabricService.getZookeeperUrl());
    Object profileObject = options.get("profiles");
    if (profileObject != null) {
        List profiles = mapper.convertValue(profileObject, List.class);
        builder.profiles(profiles);
    }
    if (builder.getProxyUri() == null) {
        builder.proxyUri(fabricService.getMavenRepoURI());
    }
    CreateContainerOptions build = builder.build();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Created container options: " + build + " with profiles " + build.getProfiles());
    }
    CreateContainerMetadata<?>[] metadatas = fabricService.createContainers(build);
    Map<String, String> rc = new LinkedHashMap<String, String>();
    for (CreateContainerMetadata<?> metadata : metadatas) {
        if (!metadata.isSuccess()) {
            LOG.error("Failed to create container {}: ", metadata.getContainerName(), metadata.getFailure());
            rc.put(metadata.getContainerName(), metadata.getFailure().getMessage());
        }
    }
    return rc;
}
Also used : ContainerProvider(io.fabric8.api.ContainerProvider) CreateContainerMetadata(io.fabric8.api.CreateContainerMetadata) CreateContainerOptions(io.fabric8.api.CreateContainerOptions) MalformedObjectNameException(javax.management.MalformedObjectNameException) FabricException(io.fabric8.api.FabricException) MalformedURLException(java.net.MalformedURLException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) ArrayList(java.util.ArrayList) CreateContainerBasicOptions(io.fabric8.api.CreateContainerBasicOptions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 25 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8 by jboss-fuse.

the class ContainerCreateCloud method doExecute.

@Override
protected Object doExecute() throws Exception {
    // validate input before creating containers
    preCreateContainer(name);
    FabricValidations.validateProfileNames(profiles);
    if (isEnsembleServer && newUserPassword == null) {
        newUserPassword = zookeeperPassword != null ? zookeeperPassword : fabricService.getZookeeperPassword();
    }
    CreateJCloudsContainerOptions.Builder builder = CreateJCloudsContainerOptions.builder().name(name).bindAddress(bindAddress).resolver(resolver).manualIp(manualIp).ensembleServer(isEnsembleServer).credential(credential).group(group).hardwareId(hardwareId).identity(identity).osFamily(osFamily).osVersion(osVersion).imageId(imageId).instanceType(instanceType).locationId(locationId).number(number).nodeOptions(CloudUtils.parseProviderOptions(options)).owner(owner).adminAccess(!disableAdminAccess).publicKeyFile(publicKeyFile).contextName(contextName).providerName(providerName).apiName(apiName).user(user).password(password).proxyUri(proxyUri != null ? proxyUri : fabricService.getMavenRepoURI()).zookeeperUrl(fabricService.getZookeeperUrl()).zookeeperPassword(isEnsembleServer && zookeeperPassword != null ? zookeeperPassword : fabricService.getZookeeperPassword()).jvmOpts(jvmOpts).environmentalVariable(environmentalVariables).version(version).withUser(newUser, newUserPassword, newUserRole).profiles(getProfileNames()).dataStoreProperties(getDataStoreProperties()).uploadDistribution(!distributionUploadDisable);
    if (path != null && !path.isEmpty()) {
        builder.path(path);
    }
    CreateContainerMetadata[] metadatas = fabricService.createContainers(builder.build(), new PrintStreamCreationStateListener(System.out));
    if (isEnsembleServer && metadatas != null && metadatas.length > 0 && metadatas[0].isSuccess()) {
        ShellUtils.storeZookeeperPassword(session, metadatas[0].getCreateOptions().getZookeeperPassword());
    }
    // display containers
    displayContainers(metadatas);
    return null;
}
Also used : PrintStreamCreationStateListener(io.fabric8.internal.PrintStreamCreationStateListener) CreateContainerMetadata(io.fabric8.api.CreateContainerMetadata) CreateJCloudsContainerOptions(io.fabric8.service.jclouds.CreateJCloudsContainerOptions)

Aggregations

Test (org.junit.Test)60 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Profile (io.fabric8.api.Profile)33 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)27 FabricService (io.fabric8.api.FabricService)24 InputStream (java.io.InputStream)21 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 HashMap (java.util.HashMap)19 Map (java.util.Map)19 Logger (org.slf4j.Logger)19 CommandSupport (io.fabric8.itests.support.CommandSupport)18 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)17 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)16 IOException (java.io.IOException)16 Action (org.apache.felix.gogo.commands.Action)16 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)16