Search in sources :

Example 6 with BundleUtils

use of io.fabric8.utils.BundleUtils in project fabric8 by jboss-fuse.

the class ResolverTest method testResolverInheritanceOnChild.

@Test
public void testResolverInheritanceOnChild() throws Exception {
    System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning -g localip -r manualip --manual-ip localhost -b localhost"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    BundleContext moduleContext = ServiceLocator.getSystemContext();
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
        Set<Container> containers = ContainerBuilder.create(1, 1).withName("basic.cntG").withProfiles("default").assertProvisioningResult().build(fabricService);
        try {
            Container cntG = containers.iterator().next();
            Assert.assertEquals("manualip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntG.getId())));
            Assert.assertEquals("manualip", fabricService.getCurrentContainer().getResolver());
            // We stop the config admin bridge, since the next step is going to hung the container if we do propagate the change to config admin.
            // new BundleUtils(bundleContext).findAndStopBundle("io.fabric8.fabric-configadmin");
            // We want to make sure that the child points to the parent, so we change the parent resolvers and assert.
            System.out.println(CommandSupport.executeCommand("fabric:container-resolver-set --container root localip"));
            Assert.assertEquals("localip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntG.getId())));
        } finally {
            ContainerBuilder.destroy(fabricService, containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 7 with BundleUtils

use of io.fabric8.utils.BundleUtils in project fabric8 by jboss-fuse.

the class JoinAction method installBundles.

public void installBundles() throws BundleException {
    BundleUtils bundleUtils = new BundleUtils(bundleContext);
    Bundle bundleFabricCommands = bundleUtils.findBundle("io.fabric8.fabric-commands");
    if (bundleFabricCommands == null) {
        bundleFabricCommands = bundleUtils.installBundle("mvn:io.fabric8/fabric-commands/" + FabricConstants.FABRIC_VERSION);
    }
    bundleFabricCommands.start();
    Bundle bundleFabricAgent = bundleUtils.findBundle("io.fabric8.fabric-agent");
    if (nonManaged && bundleFabricAgent == null) {
    // do nothing
    } else if (nonManaged && bundleFabricAgent != null) {
        bundleFabricAgent.stop();
    } else if (bundleFabricAgent == null) {
        bundleFabricAgent = bundleUtils.installBundle("mvn:io.fabric8/fabric-agent/" + FabricConstants.FABRIC_VERSION);
        bundleFabricAgent.start();
    } else {
        bundleFabricAgent.start();
    }
}
Also used : Bundle(org.osgi.framework.Bundle) BundleUtils(io.fabric8.utils.BundleUtils)

Aggregations

BundleUtils (io.fabric8.utils.BundleUtils)6 Bundle (org.osgi.framework.Bundle)4 Container (io.fabric8.api.Container)1 FabricService (io.fabric8.api.FabricService)1 RuntimeProperties (io.fabric8.api.RuntimeProperties)1 SystemProperties (io.fabric8.api.SystemProperties)1 ZkPath (io.fabric8.zookeeper.ZkPath)1 BootstrapConfiguration (io.fabric8.zookeeper.bootstrap.BootstrapConfiguration)1 Path (java.nio.file.Path)1 Hashtable (java.util.Hashtable)1 StandardMBean (javax.management.StandardMBean)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 Activate (org.apache.felix.scr.annotations.Activate)1 Properties (org.apache.felix.utils.properties.Properties)1 Test (org.junit.Test)1 BundleContext (org.osgi.framework.BundleContext)1 BundleException (org.osgi.framework.BundleException)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1