Search in sources :

Example 71 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class ProfileDownloader method downloadVersion.

/**
 * Downloads the bundles, features and FABs for all the profiles in this version
 */
public void downloadVersion(Version version) throws Exception {
    List<Profile> profiles = version.getProfiles();
    Profile[] prfarray = profiles.toArray(new Profile[profiles.size()]);
    if (listener != null) {
        listener.beforeDownloadProfiles(prfarray);
    }
    for (Profile profile : profiles) {
        try {
            downloadProfile(profile);
        } catch (Exception e) {
            if (listener != null) {
                listener.onError(profile, e);
            }
            if (!stopOnFailure) {
                String id = profile.getId();
                errors.put(id, e);
                LOG.error("Failed to download profile " + id + " due " + e.getMessage(), e);
            } else {
                throw e;
            }
        }
    }
    if (listener != null) {
        listener.afterDownloadProfiles(prfarray);
    }
}
Also used : Profile(io.fabric8.api.Profile)

Example 72 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class WatchAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    if (start && stop) {
        System.err.println("Please use only one of --start and --stop options!");
        return null;
    }
    if (interval > 0) {
        System.out.println("Setting watch interval to " + interval + " ms");
        watcher.setInterval(interval);
    }
    if (stop) {
        System.out.println("Stopping watch");
        watcher.stop();
    }
    watcher.setUpload(upload);
    if (urls != null) {
        if (remove) {
            for (String url : urls) {
                watcher.remove(url);
            }
        } else {
            for (String url : urls) {
                watcher.add(url);
            }
        }
    }
    if (start) {
        System.out.println("Starting watch");
        watcher.start();
    }
    if (list) {
        // list the watched bundles.
        TablePrinter printer = new TablePrinter();
        printer.columns("url", "profile", "version", "bundle");
        for (String url : watcher.getWatchURLs()) {
            Map<ProfileVersionKey, Map<String, Parser>> profileArtifacts = watcher.getProfileArtifacts();
            if (profileArtifacts.size() > 0) {
                Set<Map.Entry<ProfileVersionKey, Map<String, Parser>>> entries = profileArtifacts.entrySet();
                for (Map.Entry<ProfileVersionKey, Map<String, Parser>> entry : entries) {
                    ProfileVersionKey key = entry.getKey();
                    Map<String, Parser> artifactMap = entry.getValue();
                    Set<Map.Entry<String, Parser>> artifactMapEntries = artifactMap.entrySet();
                    for (Map.Entry<String, Parser> artifactMapEntry : artifactMapEntries) {
                        String location = artifactMapEntry.getKey();
                        Parser parser = artifactMapEntry.getValue();
                        if (isSnapshot(parser) || watcher.wildCardMatch(location, url)) {
                            printer.row(url, key.getProfileId(), key.getVersion(), location);
                        }
                    }
                }
            } else {
                printer.row(url, "", "", "");
            }
        }
        printer.print();
    } else {
        List<String> urls = watcher.getWatchURLs();
        if (urls != null && urls.size() > 0) {
            System.out.println("Watched URLs: ");
            for (String url : watcher.getWatchURLs()) {
                System.out.println(url);
            }
        } else {
            System.out.println("No watched URLs");
        }
    }
    return null;
}
Also used : ProfileVersionKey(io.fabric8.agent.commands.support.ProfileVersionKey) Parser(io.fabric8.maven.util.Parser) TablePrinter(io.fabric8.utils.TablePrinter) Map(java.util.Map)

Example 73 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class BootstrapConfiguration method configureInternal.

void configureInternal(Map<String, ?> conf) throws Exception {
    configuration = configurer.configure(conf, this);
    if (Strings.isNullOrBlank(runtimeId)) {
        throw new IllegalArgumentException("Runtime id must not be null or empty.");
    }
    if (Strings.isNullOrBlank(localResolver)) {
        localResolver = globalResolver;
    }
    String decodedZookeeperPassword = null;
    Properties userProps = new Properties();
    try {
        userProps.load(new File(confDir, "users.properties"));
    } catch (IOException e) {
        LOGGER.warn("Failed to load users from etc/users.properties. No users will be imported.", e);
    }
    if (Strings.isNotBlank(zookeeperPassword)) {
        decodedZookeeperPassword = PasswordEncoder.decode(zookeeperPassword);
    } else if (userProps.containsKey(DEFAULT_ADMIN_USER)) {
        String passwordAndRole = userProps.getProperty(DEFAULT_ADMIN_USER).trim();
        decodedZookeeperPassword = passwordAndRole.substring(0, passwordAndRole.indexOf(ROLE_DELIMITER));
    } else {
        decodedZookeeperPassword = PasswordEncoder.encode(CreateEnsembleOptions.generatePassword());
    }
    // do not trigger io.fabric8.zookeeper update if restart is pending (fabric:join)
    if (!Boolean.getBoolean("karaf.restart") && zookeeperUrl != null && zookeeperPassword != null) {
        Configuration zkConfugiration = configAdmin.get().getConfiguration(Constants.ZOOKEEPER_CLIENT_PID);
        if (zkConfugiration.getProperties() == null) {
            Hashtable<String, Object> zkProperties = new Hashtable<>();
            zkProperties.put("zookeeper.url", zookeeperUrl);
            zkProperties.put("zookeeper.password", PasswordEncoder.encode(decodedZookeeperPassword));
            zkConfugiration.update(zkProperties);
        }
    }
    if (userProps.isEmpty()) {
        userProps.put(DEFAULT_ADMIN_USER, decodedZookeeperPassword + ROLE_DELIMITER + DEFAULT_ADMIN_ROLE);
    }
    String minimumPort = (String) configuration.get("minimum.port");
    if (!Strings.isNullOrBlank(minimumPort)) {
        this.minport = Integer.valueOf(minimumPort);
    }
    String maximumPort = (String) configuration.get("maximum.port");
    if (!Strings.isNullOrBlank(maximumPort)) {
        this.maxport = Integer.valueOf(maximumPort);
    }
    options = CreateEnsembleOptions.builder().bindAddress(bindAddress).agentEnabled(agentAutoStart).ensembleStart(ensembleAutoStart).zookeeperPassword(decodedZookeeperPassword).zooKeeperServerPort(zookeeperServerPort).zooKeeperServerConnectionPort(zookeeperServerConnectionPort).autoImportEnabled(profilesAutoImport).importPath(profilesAutoImportPath).resolver(localResolver).globalResolver(globalResolver).users(userProps).minimumPort(minport).maximumPort(maxport).profiles(profiles).version(version).build();
}
Also used : Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable) IOException(java.io.IOException) RuntimeProperties(io.fabric8.api.RuntimeProperties) Properties(org.apache.felix.utils.properties.Properties) File(java.io.File)

Example 74 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricDTO method createContainerDTO.

public static ContainerDTO createContainerDTO(Container container, String baseApiLink) {
    ContainerDTO answer = new ContainerDTO();
    String containerId = container.getId();
    answer.setId(containerId);
    answer.setType(container.getType());
    answer.setChildren(Containers.containerIds(container.getChildren()));
    List<String> profileIds = Profiles.profileIds(container.getProfiles());
    String profileLinkPrefix = baseApiLink + "/version/" + Profiles.versionId(container.getVersion()) + "/profile/";
    answer.setProfiles(Links.mapIdsToLinks(profileIds, profileLinkPrefix));
    answer.setVersion(Profiles.versionId(container.getVersion()));
    answer.setParent(Containers.containerId(container.getParent()));
    answer.setIp(container.getIp());
    answer.setLocalIp(container.getLocalIp());
    answer.setManualIp(container.getManualIp());
    answer.setPublicIp(container.getPublicIp());
    answer.setLocalHostName(container.getLocalHostname());
    answer.setPublicHostName(container.getPublicHostname());
    answer.setResolver(container.getResolver());
    answer.setMaximumPort(container.getMaximumPort());
    answer.setMinimumPort(container.getMinimumPort());
    answer.setGeoLocation(container.getGeoLocation());
    answer.setLocation(container.getLocation());
    answer.setProcessId(container.getProcessId());
    answer.setDebugPort(container.getDebugPort());
    answer.setHttpUrl(container.getHttpUrl());
    answer.setJmxUrl(container.getJmxUrl());
    answer.setJolokiaUrl(container.getJolokiaUrl());
    answer.setSshUrl(container.getSshUrl());
    answer.setProvisionException(container.getProvisionException());
    answer.setProvisionResult(container.getProvisionResult());
    answer.setProvisionStatus(container.getProvisionStatus());
    answer.setProvisionList(container.getProvisionList());
    answer.setJmxDomains(container.getJmxDomains());
    answer.setAlive(container.isAlive());
    answer.setAliveAndOK(container.isAliveAndOK());
    answer.setEnsembleServer(container.isEnsembleServer());
    answer.setManaged(container.isManaged());
    answer.setProvisioningComplete(container.isProvisioningComplete());
    answer.setProvisioningPending(container.isProvisioningPending());
    answer.setRoot(container.isRoot());
    answer.setStartLink(baseApiLink + "/container/" + containerId + "/start");
    return answer;
}
Also used : ContainerDTO(io.fabric8.api.jmx.ContainerDTO)

Example 75 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricResource method version.

/**
 * Accesses a version resource
 */
@Path("version/{versionId}")
public VersionResource version(@PathParam("versionId") String versionId) {
    FabricService fabricService = getFabricService();
    if (fabricService != null && Strings.isNotBlank(versionId)) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        Version version = profileService.getRequiredVersion(versionId);
        if (version != null) {
            return new VersionResource(this, version);
        } else {
            LOG.warn("No version found for: {}", version);
        }
    }
    return null;
}
Also used : ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) FabricService(io.fabric8.api.FabricService) Path(javax.ws.rs.Path)

Aggregations

Test (org.junit.jupiter.api.Test)143 Map (java.util.Map)106 IOException (java.io.IOException)76 Version (io.fabric8.api.Version)74 ArrayList (java.util.ArrayList)73 HashMap (java.util.HashMap)71 Profile (io.fabric8.api.Profile)70 File (java.io.File)69 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)62 Vertx (io.vertx.core.Vertx)58 Test (org.junit.Test)58 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)57 Pod (io.fabric8.kubernetes.api.model.Pod)56 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)56 Checkpoint (io.vertx.junit5.Checkpoint)54 VertxExtension (io.vertx.junit5.VertxExtension)54 VertxTestContext (io.vertx.junit5.VertxTestContext)54 List (java.util.List)54 Collections (java.util.Collections)53 BeforeAll (org.junit.jupiter.api.BeforeAll)53