Package io.fabric8.api

Examples of io.fabric8.api.Profile


    }

    public void updateDeployment(Git git, File baseDir, CredentialsProvider credentials) throws Exception {
        Set<String> bundles = new LinkedHashSet<String>();
        Set<Feature> features = new LinkedHashSet<Feature>();
        Profile overlayProfile = container.getOverlayProfile();
        Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
        bundles.addAll(effectiveProfile.getBundles());
        AgentUtils.addFeatures(features, fabricService, downloadManager, effectiveProfile);

        if (copyFilesIntoGit) {
            copyDeploymentsIntoGit(git, baseDir, bundles, features);
        } else {
View Full Code Here


            if (profileIds != null && versionId != null) {
                ProfileService profileService = service.adapt(ProfileService.class);
                version = profileService.getVersion(versionId);
                if (version != null) {
                    for (String profileId : profileIds) {
                        Profile profile = version.getRequiredProfile(profileId);
                        if (profile != null) {
                            Profile overlay = profileService.getOverlayProfile(profile);
                            profileOverlays.add(overlay);
                            Map<String, String> dockerConfig = overlay.getConfiguration(DockerConstants.DOCKER_PROVIDER_PID);
                            if (dockerConfig != null) {
                                configOverlay.putAll(dockerConfig);
                            }
                            if (ports == null || ports.size() == 0) {
                                ports = overlay.getConfiguration(Constants.PORTS_PID);
                            }
                        }
                    }
                    if (version.hasProfile(DockerConstants.DOCKER_PROVIDER_PROFILE_ID)) {
                        Profile profile = version.getRequiredProfile(DockerConstants.DOCKER_PROVIDER_PROFILE_ID);
                        if (profile != null) {
                            Profile overlay = profileService.getOverlayProfile(profile);
                            Map<String, String> dockerConfig = overlay.getConfiguration(DockerConstants.DOCKER_PROVIDER_PID);
                            if (dockerConfig != null) {
                                dockerProviderConfig.putAll(dockerConfig);
                            }
                        }
                    }
                }
            }
            if (ports == null || ports.size() == 0) {
                // lets find the defaults from the docker profile
                if (version == null) {
                    version = service.getRequiredDefaultVersion();
                }
                Profile dockerProfile = version.getRequiredProfile("docker");
                ports = dockerProfile.getConfiguration(Constants.PORTS_PID);
                if (ports == null || ports.size() == 0) {
                    LOG.warn("Could not a docker ports configuration for: " + Constants.PORTS_PID);
                    ports = new HashMap<String, String>();
                }
            }
View Full Code Here

                Container client = containerList.removeLast();

                LinkedList<Container> servers = new LinkedList<Container>(containerList);

                for (Container c : servers) {
                    Profile p = c.getVersion().getRequiredProfile("example-camel-cluster.server");
                    c.setProfiles(new Profile[]{p});
                }

                Provision.provisioningSuccess(servers, PROVISION_TIMEOUT);

                Profile p = client.getVersion().getRequiredProfile("example-camel-cluster.client");
                client.setProfiles(new Profile[]{p});

                Provision.provisioningSuccess(Arrays.asList(new Container[]{client}), PROVISION_TIMEOUT);

                System.out.println(executeCommand("fabric:container-list"));
View Full Code Here

    protected void onConfigurationChanged() {
        LOGGER.info("Configuration has changed; so checking the Fabric managed Java cartridges on OpenShift are up to date");
        Container[] containers = fabricService.get().getContainers();
        for (Container container : containers) {
            Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService.get(), container.getOverlayProfile());
            Map<String, String> openshiftConfiguration = effectiveProfile.getConfiguration(OpenShiftConstants.OPENSHIFT_PID);
            if (openshiftConfiguration != null) {
                DeploymentUpdater deployTask = null;
                try {
                    deployTask = createDeployTask(container, openshiftConfiguration);
                } catch (MalformedURLException e) {
View Full Code Here

        FabricService fabricService = this.fabricService.getOptional();

        // lets find the camel contexts to test in this container
        MBeanServer mbeanServerValue = mbeanServer;
        if (mbeanServerValue != null && fabricService != null) {
            Profile overlayProfile = fabricService.getCurrentContainer().getOverlayProfile();
            Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
            Set<String> configurationFileNames = effectiveProfile.getConfigurationFileNames();
            for (CamelContext camelContext : camelContexts.values()) {
                String camelContextID = camelContext.getName();
                // check we only add testing stuff to each context once
                if (camelContext instanceof ModelCamelContext) {
                    final ModelCamelContext modelCamelContext = (ModelCamelContext) camelContext;
                    List<RouteDefinition> routeDefinitions = modelCamelContext.getRouteDefinitions();
                    if (camelContextsConfigured.add(camelContextID)) {
                        NodeIdFactory nodeIdFactory = camelContext.getNodeIdFactory();

                        if (mockInputs || mockOutputs) {
                            for (RouteDefinition routeDefinition : routeDefinitions) {
                                String routeId = routeDefinition.idOrCreate(nodeIdFactory);
                                modelCamelContext.stopRoute(routeId);

                                final String routeKey = camelContextID + "." + routeId;
                                LOG.info("Mocking Camel route: " + routeKey);
                                routeDefinition.adviceWith(modelCamelContext, new AdviceWithRouteBuilder() {
                                    @Override
                                    public void configure() throws Exception {
                                        if (mockOutputs) {
                                            modelCamelContext.addRegisterEndpointCallback(strategy);
                                        }
                                    }
                                });
                                // the advised route is automatic restarted
                            }
                        }

                        String path = messageFolder;
                        if (Strings.isNotBlank(path)) {
                            path += "/";
                        }
                        path += camelContextID;

                        ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
                        try {
                            for (RouteDefinition routeDefinition : routeDefinitions) {
                                String routeId = routeDefinition.idOrCreate(nodeIdFactory);
                                String routePath = path + "/" + routeId + "/";
                                List<FromDefinition> inputs = routeDefinition.getInputs();
                                for (FromDefinition input : inputs) {
                                    Endpoint endpoint = input.getEndpoint();
                                    if (endpoint == null) {
                                        String uri = input.getUri();
                                        if (Strings.isNullOrBlank(uri)) {
                                            String ref = input.getRef();
                                            if (Strings.isNotBlank(ref)) {
                                                uri = "ref:" + ref;
                                            }
                                        }
                                        if (Strings.isNotBlank(uri)) {
                                            endpoint = camelContext.getEndpoint(uri);
                                        }
                                    }
                                    if (endpoint == null) {
                                        LOG.warn("Cannot find endpoint, uri or ref of input " + input + " on route " + routeId + " camelContext: " + camelContextID);
                                    } else {
                                        for (String configFile : configurationFileNames) {
                                            if (configFile.startsWith(routePath)) {
                                                LOG.info("Sending file: " + configFile + " to " + endpoint);
                                                byte[] data = effectiveProfile.getFileConfiguration(configFile);
                                                if (data != null) {
                                                    // lest send this message to this endpoint
                                                    producerTemplate.sendBody(endpoint, data);
                                                }
                                            }
View Full Code Here

        requirements.setFeatures(features);
        projectDeployer.deployProject(requirements);


        // now we should have a profile created
        Profile profile = assertProfileInFabric(expectedProfileId, versionId);
        assertBundleCount(profile, 1);
        assertEquals("parent ids", parentProfileIds, profile.getParentIds());
        assertFeatures(profile, features);

        String requirementsFileName = "dependencies/" + groupId + "/" + artifactId + "-requirements.json";
        byte[] jsonData = profile.getFileConfiguration(requirementsFileName);
        assertNotNull("should have found some JSON for: " + requirementsFileName, jsonData);
        String json = new String(jsonData);
        LOG.info("Got JSON: " + json);

        // lets replace the version, parent, features
        rootDependency.setVersion("1.0.1");
        projectDeployer.deployProject(requirements);
        profile = assertProfileInFabric(expectedProfileId, versionId);
        assertBundleCount(profile, 1);


        // now lets make a new version
        expectedProfileId = "cheese";
        versionId = "1.2";
        requirements.setVersion(versionId);
        requirements.setProfileId(expectedProfileId);

        parentProfileIds = Arrays.asList("default");
        features = Arrays.asList("camel", "war");
        requirements.setParentProfiles(parentProfileIds);
        requirements.setFeatures(features);
        projectDeployer.deployProject(requirements);

        profile = assertProfileInFabric(expectedProfileId, versionId);
        assertBundleCount(profile, 1);
        assertEquals("parent ids", parentProfileIds, profile.getParentIds());
        assertFeatures(profile, features);

        //assertProfileMetadata();
    }
View Full Code Here

        LOG.info("Profile " + profile + " now has bundles: " + bundles);
        assertEquals("Profile " + profile + " bundles are " + bundles, size, bundles.size());
    }

    protected Profile assertProfileInFabric(String profileId, String versionId) {
        Profile profile = profileService.getRequiredVersion(versionId).getRequiredProfile(profileId);
        assertNotNull("Should have a profile for " + versionId + " and " + profileId);
        return profile;
    }
View Full Code Here

        Set<String> profileIds = options.getProfiles();
        String versionId = options.getVersion();
        List<Profile> profiles = Profiles.getProfiles(fabricService, profileIds, versionId);
        for (Profile profile : profiles) {
            ProfileService profileService = fabricService.adapt(ProfileService.class);
            Profile overlay = profileService.getOverlayProfile(profile);
            jsonData = overlay.getFileConfiguration(controllerPath);
            if (jsonData != null) {
                break;
            }
        }
        Objects.notNull(jsonData, "No JSON file found for path " + controllerPath + " in profiles: " + profileIds + " version: " + versionId);
View Full Code Here

    public List<String> listWorkItemLocations() {
        List<String> items = Lists.newArrayList();
        try {
            ProfileService profileService = fabricService.adapt(ProfileService.class);
            String version = dataStore.getContainerVersion(name);
            Profile p = profileService.getRequiredProfile(version, profileId);
            for (String f : p.getFileConfigurations().keySet()) {
                if (f.startsWith(folderPath)) {
                    items.add(f);
                }
            }
        } catch (Exception e) {
View Full Code Here

    @Override
    public void run() {
       ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
       String versionId = dataStore.getContainerVersion(name);
       Profile profile = profileRegistry.getProfile(versionId, versionId);
       if (profile != null && !profile.getProfileHash().equals(lastModified)) {
           notifyListeners();
           lastModified = profile.getProfileHash();
       }
    }
View Full Code Here

TOP

Related Classes of io.fabric8.api.Profile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.