use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class AgentUtils method getProfileArtifacts.
/**
* Returns the location and parser map (i.e. the location and the parsed maven coordinates and artifact locations) of each bundle and feature
*/
public static Map<String, Parser> getProfileArtifacts(FabricService fabricService, Profile profile, Iterable<String> bundles, Iterable<Feature> features, Callback<String> nonMavenLocationCallback) {
Set<String> locations = new HashSet<>();
for (Feature feature : features) {
List<BundleInfo> bundleList = feature.getBundles();
if (bundleList == null) {
LOGGER.warn("No bundles for feature " + feature);
} else {
for (BundleInfo bundle : bundleList) {
locations.add(bundle.getLocation());
}
}
}
for (String bundle : bundles) {
locations.add(bundle);
}
Map<String, Parser> artifacts = new HashMap<>();
for (String location : locations) {
try {
if (location.contains("$")) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
Profile overlay = profileService.getOverlayProfile(profile);
location = VersionPropertyPointerResolver.replaceVersions(fabricService, overlay.getConfigurations(), location);
}
if (location.startsWith("mvn:") || location.contains(":mvn:")) {
Parser parser = Parser.parsePathWithSchemePrefix(location);
artifacts.put(location, parser);
} else {
if (nonMavenLocationCallback != null) {
nonMavenLocationCallback.call(location);
}
}
} catch (MalformedURLException e) {
LOGGER.error("Failed to parse bundle URL: " + location + ". " + e, e);
}
}
return artifacts;
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class AgentUtils method expandFeature.
public static Set<Feature> expandFeature(Feature feature, Map<String, Repository> repositories) {
Set<Feature> features = new HashSet<>();
for (Dependency f : feature.getDependencies()) {
Feature loaded = FeatureUtils.search(f.getName(), repositories.values());
features.addAll(expandFeature(loaded, repositories));
}
features.add(feature);
return features;
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class FeatureUtils method search.
public static Feature search(String name, String version, Collection<Repository> repositories) {
VersionRange range = new VersionRange(version, false, true);
Feature bestFeature = null;
Version bestVersion = null;
for (Repository repo : repositories) {
Feature[] features;
try {
features = repo.getFeatures();
} catch (Exception e) {
// This should not happen as the repository has been loaded already
throw new IllegalStateException(e);
}
for (Feature feature : features) {
if (name.equals(feature.getName())) {
Version v = new Version(VersionCleaner.clean(feature.getVersion()));
if (range.contains(v)) {
if (bestVersion == null || bestVersion.compareTo(v) < 0) {
bestFeature = feature;
bestVersion = v;
}
}
}
}
}
return bestFeature;
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class DeploymentAgentTest method testResolveOptionalImports.
@Test
@SuppressWarnings("unchecked")
public void testResolveOptionalImports() throws Exception {
CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning");
CommandSupport.executeCommand("fabric:profile-create --parent default test-profile");
CommandSupport.executeCommand("fabric:profile-edit --pid io.fabric8.agent/resolve.optional.imports=true test-profile");
CommandSupport.executeCommand("fabric:profile-edit --feature spring-struts test-profile");
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
Set<Container> containers = ContainerBuilder.create().withName("smoke_cnt_b").withProfiles("test-profile").assertProvisioningResult().build(fabricService);
try {
String command = "fabric:container-connect -u admin -p admin " + containers.iterator().next().getId() + " osgi:list -t 0 -s | grep org.apache.servicemix.bundles.struts";
String result = CommandSupport.executeCommand(command);
assertTrue("Result contains struts, but was: " + result, result.contains("org.apache.servicemix.bundles.struts"));
} finally {
ContainerBuilder.stop(fabricService, containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class JoinTest method testJoin.
@Test
public void testJoin() throws Exception {
System.err.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
AdminService adminService = ServiceLocator.awaitService(AdminService.class);
String version = System.getProperty("fabric.version");
System.err.println(CommandSupport.executeCommand("admin:create -o '-server -Xmx1536M -Dcom.sun.management.jmxremote -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dpatching.disabled=true -Djava.security.egd=file:/dev/./urandom' --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric-git --feature fabric-agent --feature fabric-boot-commands smoke_child_d"));
try {
System.err.println(CommandSupport.executeCommand("admin:start smoke_child_d"));
ProvisionSupport.instanceStarted(Arrays.asList("smoke_child_d"), ProvisionSupport.PROVISION_TIMEOUT);
System.err.println(CommandSupport.executeCommand("admin:list"));
String joinCommand = "fabric:join -f --zookeeper-password " + fabricService.getZookeeperPassword() + " " + fabricService.getZookeeperUrl();
String response = "";
for (int i = 0; i < 10 && !response.contains("true"); i++) {
response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("smoke_child_d").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
Thread.sleep(1000);
}
System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("smoke_child_d").getSshPort() + " localhost " + joinCommand));
ProvisionSupport.containersExist(Arrays.asList("smoke_child_d"), ProvisionSupport.PROVISION_TIMEOUT);
Container childD = fabricService.getContainer("smoke_child_d");
System.err.println(CommandSupport.executeCommand("fabric:container-list"));
ProvisionSupport.containerStatus(Arrays.asList(childD), "success", ProvisionSupport.PROVISION_TIMEOUT);
System.err.println(CommandSupport.executeCommand("fabric:container-list"));
} finally {
System.err.println(CommandSupport.executeCommand("admin:stop smoke_child_d"));
}
} finally {
fabricProxy.close();
}
}
Aggregations