Search in sources :

Example 76 with Version

use of io.fabric8.api.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 77 with Version

use of io.fabric8.api.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 78 with Version

use of io.fabric8.api.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)

Example 79 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricResource method versions.

/**
 * Returns the list of version ids
 */
@GET
@Path("versions")
public Map<String, String> versions() {
    FabricService fabricService = getFabricService();
    if (fabricService != null) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        List<String> versionIds = profileService.getVersions();
        return mapToLinks(versionIds, "/version/");
    } else {
        noFabricService();
    }
    return Collections.emptyMap();
}
Also used : ProfileService(io.fabric8.api.ProfileService) FabricService(io.fabric8.api.FabricService) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 80 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricWebRegistrationHandler method registerWebapp.

/**
 * Registers a webapp to the registry.
 */
private void registerWebapp(Container container, WebEvent webEvent) {
    String id = container.getId();
    String url = "${zk:" + id + "/http}" + webEvent.getContextPath();
    String bundleName = webEvent.getBundle().getSymbolicName();
    String bundleVersion = webEvent.getBundle().getVersion().toString();
    setJolokiaUrl(container, url, bundleName);
    Version version = container.getVersion();
    String versionId = version != null ? version.getId() : null;
    String json = "{\"id\":" + jsonEncodeString(id) + ",\"services\":[" + jsonEncodeString(url) + "]" + ",\"version\":" + JsonHelper.jsonEncodeString(versionId) + ",\"bundleName\":" + jsonEncodeString(bundleName) + ",\"bundleVersion\":" + jsonEncodeString(bundleVersion) + ",\"container\":" + jsonEncodeString(id) + "}";
    try {
        synchronized (webEvent.getBundle()) {
            setData(curator.get(), ZkPath.WEBAPPS_CONTAINER.getPath(bundleName, webEvent.getBundle().getVersion().toString(), id), json, CreateMode.EPHEMERAL);
        }
    } catch (Exception e) {
        LOGGER.error("Failed to register webapp {}.", webEvent.getContextPath(), e);
    }
}
Also used : Version(io.fabric8.api.Version) JsonHelper.jsonEncodeString(io.fabric8.internal.JsonHelper.jsonEncodeString) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 File (java.io.File)52 Test (org.junit.Test)46 IOException (java.io.IOException)41 ArrayList (java.util.ArrayList)36 Container (io.fabric8.api.Container)35 HashMap (java.util.HashMap)34 ProfileService (io.fabric8.api.ProfileService)27 Map (java.util.Map)25 Git (org.eclipse.jgit.api.Git)22 FabricService (io.fabric8.api.FabricService)21 Version (org.osgi.framework.Version)21 ProfileBuilder (io.fabric8.api.ProfileBuilder)18 GitVersion (io.fabric8.api.commands.GitVersion)18 PatchException (io.fabric8.patch.management.PatchException)15 HashSet (java.util.HashSet)15 TreeMap (java.util.TreeMap)14 LinkedList (java.util.LinkedList)13 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)12