Search in sources :

Example 21 with Group

use of io.fabric8.openshift.api.model.Group in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method getContainerTestWithUser.

@Test
public void getContainerTestWithUser() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    // container name with user and image with tag
    ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compression("gzip").dockerFile("testFile").dockerFileDir("/demo").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("user/test:latest").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("user-test-artifact", containers.get(0).getName());
    assertEquals("docker.io/user/test:latest", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 22 with Group

use of io.fabric8.openshift.api.model.Group in project fabric8 by jboss-fuse.

the class MQCreateAction method createDTO.

private MQBrokerConfigDTO createDTO() {
    if (Strings.isNullOrBlank(username)) {
        username = ShellUtils.retrieveFabricUser(session);
    }
    if (Strings.isNullOrBlank(password)) {
        password = ShellUtils.retrieveFabricUserPassword(session);
    }
    MQBrokerConfigDTO dto = new MQBrokerConfigDTO();
    if (config != null) {
        dto.setConfigUrl(config);
    } else {
        if (nossl) {
            dto.setConfigUrl("broker.xml");
        } else {
            dto.setConfigUrl("ssl-broker.xml");
        }
    }
    dto.setData(data);
    if (ports != null && ports.length > 0) {
        for (String port : ports) {
            addConfig(port, dto.getPorts());
        }
    }
    dto.setGroup(group);
    dto.setJvmOpts(jvmOpts);
    dto.setBrokerName(name);
    dto.setProfile(profile);
    dto.setClientProfile(clientProfile);
    dto.setClientParentProfile(clientParentProfile);
    dto.setNetworks(networks);
    dto.setNetworksPassword(networksPassword);
    dto.setNetworksUserName(networksUserName);
    dto.setParentProfile(parentProfile);
    dto.setProperties(properties);
    if (version == null) {
        version = fabricService.getDefaultVersionId();
    }
    dto.setVersion(version);
    dto.setMinimumInstances(minimumInstances);
    dto.setReplicas(replicas);
    dto.setSsl(!nossl);
    dto.setKind(kind);
    return dto;
}
Also used : MQBrokerConfigDTO(io.fabric8.api.jmx.MQBrokerConfigDTO)

Example 23 with Group

use of io.fabric8.openshift.api.model.Group in project fabric8 by jboss-fuse.

the class GitMasterListener method updateMasterUrl.

/**
 * Updates the git master url, if needed.
 */
private void updateMasterUrl(Group<GitNode> group) {
    GitNode master = group.master();
    String masterUrl = master != null ? master.getUrl() : null;
    try {
        if (masterUrl != null) {
            GitService gitservice = gitService.get();
            String substitutedUrl = getSubstitutedData(curator.get(), masterUrl);
            if (!Strings.isNotBlank(substitutedUrl)) {
                LOGGER.warn("Could not render git master URL {}.", masterUrl);
            }
            // Catch any possible issue indicating that the URL is invalid.
            if (!FabricValidations.isURIValid(substitutedUrl)) {
                LOGGER.warn("Not changing master Git URL to \"" + substitutedUrl + "\". There may be pending ZK connection shutdown.");
            } else {
                gitservice.notifyRemoteChanged(substitutedUrl);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Failed to point origin to the new master.", e);
    }
}
Also used : GitService(io.fabric8.git.GitService) GitNode(io.fabric8.git.GitNode) IOException(java.io.IOException)

Example 24 with Group

use of io.fabric8.openshift.api.model.Group in project fabric8 by jboss-fuse.

the class GitHttpServerRegistrationHandler method activate.

@Activate
void activate(Map<String, ?> configuration) throws Exception {
    RuntimeProperties sysprops = runtimeProperties.get();
    realm = getConfiguredRealm(sysprops, configuration);
    roles = getConfiguredRoles(sysprops, configuration);
    dataPath = sysprops.getDataPath();
    activateComponent();
    group = new ZooKeeperGroup<GitNode>(curator.get(), ZkPath.GIT.getPath(), GitNode.class, new NamedThreadFactory("zkgroup-git-httpreg"));
    // if anything went wrong in a previous deactivation we still have to clean up the registry
    zkCleanUp(group);
    group.add(this);
    group.update(createState());
    group.start();
}
Also used : NamedThreadFactory(io.fabric8.utils.NamedThreadFactory) GitNode(io.fabric8.git.GitNode) RuntimeProperties(io.fabric8.api.RuntimeProperties) Activate(org.apache.felix.scr.annotations.Activate)

Example 25 with Group

use of io.fabric8.openshift.api.model.Group in project fabric8 by jboss-fuse.

the class GitHttpServerRegistrationHandler method createState.

private GitNode createState() {
    RuntimeProperties sysprops = runtimeProperties.get();
    String runtimeIdentity = sysprops.getRuntimeIdentity();
    GitNode state = new GitNode("fabric-repo", runtimeIdentity);
    if (group != null && group.isMaster()) {
        String externalGitUrl = readExternalGitUrl();
        if (externalGitUrl != null) {
            state.setUrl(externalGitUrl);
        } else {
            String fabricRepoUrl = "${zk:" + runtimeIdentity + "/http}/git/fabric/";
            state.setUrl(fabricRepoUrl);
        }
    }
    return state;
}
Also used : GitNode(io.fabric8.git.GitNode) RuntimeProperties(io.fabric8.api.RuntimeProperties)

Aggregations

Test (org.junit.Test)18 CuratorFramework (org.apache.curator.framework.CuratorFramework)12 ZooKeeperGroup (io.fabric8.groups.internal.ZooKeeperGroup)9 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)8 RetryNTimes (org.apache.curator.retry.RetryNTimes)8 NodeState (io.fabric8.groups.NodeState)7 NIOServerCnxnFactory (org.apache.zookeeper.server.NIOServerCnxnFactory)6 File (java.io.File)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Profile (io.fabric8.api.Profile)4 GitNode (io.fabric8.git.GitNode)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 RuntimeProperties (io.fabric8.api.RuntimeProperties)3 MQBrokerConfigDTO (io.fabric8.api.jmx.MQBrokerConfigDTO)3 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)3 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)3 TcpGateway (io.fabric8.gateway.handlers.tcp.TcpGateway)2 Group (io.fabric8.groups.Group)2