Search in sources :

Example 51 with io.fabric8.kubernetes.api.model

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

the class VerifyFeatureResolutionMojo method verifyResolution.

private void verifyResolution(DownloadManager manager, Map<String, Feature> allFeatures, String feature, Hashtable<String, String> properties) throws MojoExecutionException {
    try {
        properties.put("feature.totest", feature);
        FakeSystemBundle systemBundle = getSystemBundleResource(getMetadata(properties, "metadata#"));
        FakeServiceReference profileHandlerSR = new FakeServiceReference(URLStreamHandlerService.class.getName(), "(url.handler.protocol=profile2)");
        systemBundle.setServiceReferences(URLStreamHandlerService.class.getName(), null, new ServiceReference[] { profileHandlerSR });
        systemBundle.setService(profileHandlerSR, new Object());
        Agent agent = new Agent(null, systemBundle, manager);
        agent.setOptions(EnumSet.of(io.fabric8.agent.service.Constants.Option.Simulate, io.fabric8.agent.service.Constants.Option.Silent));
        try {
            agent.provision(allFeatures, getPrefixedProperties(properties, "feature."), getPrefixedProperties(properties, "bundle."), getPrefixedProperties(properties, "req."), getPrefixedProperties(properties, "override."), getPrefixedProperties(properties, "optional."), getMetadata(properties, "metadata#"));
        } catch (Exception e) {
            Set<String> resources = new TreeSet<>(manager.getProviders().keySet());
            throw new MojoExecutionException("Feature resolution failed for " + feature + "\nMessage: " + e.toString() + "\nResources: " + toString(resources), e);
        }
    } catch (MojoExecutionException e) {
        throw e;
    } catch (Exception e) {
        throw new MojoExecutionException("Error verifying feature " + feature + "\nMessage: " + e.getMessage(), e);
    }
}
Also used : Agent(io.fabric8.agent.service.Agent) EnumSet(java.util.EnumSet) Set(java.util.Set) TreeSet(java.util.TreeSet) URLStreamHandlerService(org.osgi.service.url.URLStreamHandlerService) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) MultiException(io.fabric8.common.util.MultiException)

Example 52 with io.fabric8.kubernetes.api.model

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

the class DeployToProfileMojoTest method before.

// Fixtures setup
@Before
public void before() {
    mojo.fabricServer = mock(Server.class);
    project = new MavenProject();
    project.setGroupId("io.fabric8");
    project.setArtifactId("artifact");
    project.setVersion(FABRIC_VERSION);
    mojo.project = project;
    deployResults = new DeployResults();
    deployResults.setProfileId("profileId");
    deployResults.setVersionId("versionId");
}
Also used : DeployResults(io.fabric8.deployer.dto.DeployResults) Server(org.apache.maven.settings.Server) MavenProject(org.apache.maven.project.MavenProject) Before(org.junit.Before)

Example 53 with io.fabric8.kubernetes.api.model

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

the class ProfileEditAction method editProfile.

private void editProfile(Profile profile) throws Exception {
    boolean editInLine = false;
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
    if (delete || remove) {
        editInLine = true;
    }
    if (features != null && features.length > 0) {
        editInLine = true;
        handleFeatures(builder, features, profile);
    }
    if (repositories != null && repositories.length > 0) {
        editInLine = true;
        handleFeatureRepositories(builder, repositories, profile);
    }
    if (libs != null && libs.length > 0) {
        editInLine = true;
        handleLibraries(builder, libs, profile, "lib", LIB_PREFIX);
    }
    if (endorsed != null && endorsed.length > 0) {
        editInLine = true;
        handleLibraries(builder, endorsed, profile, "endorsed lib", ENDORSED_PREFIX);
    }
    if (extension != null && extension.length > 0) {
        editInLine = true;
        handleLibraries(builder, extension, profile, "extension lib", EXT_PREFIX);
    }
    if (bundles != null && bundles.length > 0) {
        editInLine = true;
        handleBundles(builder, bundles, profile);
    }
    if (fabs != null && fabs.length > 0) {
        editInLine = true;
        handleFabs(builder, fabs, profile);
    }
    if (overrides != null && overrides.length > 0) {
        editInLine = true;
        handleOverrides(builder, overrides, profile);
    }
    if (pidProperties != null && pidProperties.length > 0) {
        editInLine = handlePid(builder, pidProperties, profile);
    }
    if (systemProperties != null && systemProperties.length > 0) {
        editInLine = true;
        handleSystemProperties(builder, systemProperties, profile);
    }
    if (configProperties != null && configProperties.length > 0) {
        editInLine = true;
        handleConfigProperties(builder, configProperties, profile);
    }
    if (resource != null && delete) {
        editInLine = true;
        builder.deleteFileConfiguration(resource);
    }
    profileService.updateProfile(builder.getProfile());
    if (!editInLine) {
        resource = resource != null ? resource : "io.fabric8.agent.properties";
        // then open the resource in the editor.
        if (pidProperties != null && pidProperties.length == 1) {
            resource = pidProperties[0] + ".properties";
        }
        openInEditor(profile, resource);
    }
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder)

Example 54 with io.fabric8.kubernetes.api.model

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

the class FabricGitSummaryAction method performContainerAction.

@Override
protected void performContainerAction(String queuePath, String containerName) throws Exception {
    JMXRequest containerRequest = new JMXRequest().withObjectName("io.fabric8:type=Fabric").withMethod("gitVersions");
    requests.put(containerName, containerRequest);
    String command = map(containerRequest);
    curator.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(queuePath, PublicStringSerializer.serialize(command));
}
Also used : JMXRequest(io.fabric8.api.commands.JMXRequest)

Example 55 with io.fabric8.kubernetes.api.model

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

the class FabricGitSummaryAction method beforeEachContainer.

@Override
protected void beforeEachContainer(Collection<String> names) throws Exception {
    // first, we need summary from fabric-git-server (to have something to compare local git repositories to)
    master = fabricService.getGitMaster();
    if (master == null) {
        System.out.println("Can't find container which is current git master");
        return;
    }
    System.out.println("Git master is: " + master);
    // ask master about the status first
    String queuePath = ZkPath.COMMANDS_REQUESTS_QUEUE.getPath(master);
    masterRequest = new JMXRequest().withObjectName("io.fabric8:type=GitServer").withMethod("gitVersions");
    String command = map(masterRequest);
    curator.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(queuePath, PublicStringSerializer.serialize(command));
}
Also used : JMXRequest(io.fabric8.api.commands.JMXRequest)

Aggregations

Test (org.junit.Test)29 FabricService (io.fabric8.api.FabricService)26 File (java.io.File)22 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)18 InputStream (java.io.InputStream)16 Logger (org.slf4j.Logger)16 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)15 CommandSupport (io.fabric8.itests.support.CommandSupport)15 Deployment (org.jboss.arquillian.container.test.api.Deployment)15 StartLevelAware (org.jboss.arquillian.osgi.StartLevelAware)15 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)15 Asset (org.jboss.shrinkwrap.api.asset.Asset)15 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)15 ServiceTracker (org.osgi.util.tracker.ServiceTracker)15 IOException (java.io.IOException)14 Action (org.apache.felix.gogo.commands.Action)14 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)14 MavenResolver (io.fabric8.maven.MavenResolver)11 Container (io.fabric8.api.Container)10 BundleContext (org.osgi.framework.BundleContext)9