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();
}
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;
}
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;
}
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();
}
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);
}
}
Aggregations