Package io.fabric8.api

Examples of io.fabric8.api.ProfileService


          public boolean apply(Container container) {
            return container != null && container.isRoot();
          }
        }));
    if (rootContainers.size() == 1 && fabric != null) {
      Container rootContainer = rootContainers.get(0);
      ContainersNode containersNode = fabric.getContainersNode();
      if (containersNode != null) {
        return containersNode.getContainerNode(rootContainer.getId());
      }
    }
    return null;
  }
View Full Code Here


          CreateJCloudsContainerOptions opts = args.withUser(args.getUser(), args.getPassword(), "admin").build();

          FabricPlugin.getLogger().debug("Compute Service: " + opts.getComputeService());

          // finally create the image
          final CreateJCloudsContainerMetadata metadata = provider.create(opts, new CreationStateListener() {
            @Override
            public void onStateChange(String message) {
              monitor.subTask(message);
            }
          });
View Full Code Here

    @Override
    protected Object doExecute() throws Exception {
       
        String latestVersion = null;

        ProfileService profileService = fabricService.adapt(ProfileService.class);
        List<String> versions = profileService.getVersions();
        if (versions.size() > 0) {
            latestVersion = versions.get(versions.size() - 1);
        }
       
        if (versionId == null) {
            IllegalStateAssertion.assertNotNull(latestVersion, "Cannot default the new version name as there are no versions available");
            VersionSequence sequence = new VersionSequence(latestVersion);
            versionId = sequence.next().getName();
        }

        // TODO we maybe want to choose the version which is less than the 'name' if it was specified
        // e.g. if you create a version 1.1 then it should use 1.0 if there is already a 2.0
       
        String sourceId = null;
        if (parentVersion == null) {
            sourceId = latestVersion;
        } else {
            IllegalStateAssertion.assertTrue(profileService.hasVersion(parentVersion), "Cannot find parent version: " + parentVersion);
            sourceId = parentVersion;
        }
       
        Version targetVersion;
        if (sourceId != null) {
            Map<String, String> attributes = description != null ? Collections.singletonMap(Version.DESCRIPTION, description) : null;
            targetVersion = profileService.createVersionFrom(sourceId, versionId, attributes);
            System.out.println("Created version: " + versionId + " as copy of: " + sourceId);
        } else {
            VersionBuilder builder = VersionBuilder.Factory.create(versionId);
            if (description != null) {
                builder.addAttribute(Version.DESCRIPTION, description);
            }
            targetVersion = profileService.createVersion(builder.getVersion());
            System.out.println("Create version: " + versionId);
        }
       
        if (defaultVersion == Boolean.TRUE) {
            fabricService.setDefaultVersionId(targetVersion.getId());
View Full Code Here

            Map<String, String> dockerProviderConfig = new HashMap<>();

            List<Profile> profileOverlays = new ArrayList<>();
            Version version = null;
            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);
                            }
                        }
View Full Code Here

        byte[] jsonData = null;
        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;
            }
        }
View Full Code Here

    @Override
    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);
                }
            }
View Full Code Here

        String cartridgeUrl = null;
        Set<String> profiles = options.getProfiles();
        String versionId = options.getVersion();
        Map<String, String> openshiftConfigOverlay = new HashMap<String, String>();
        if (profiles != null && versionId != null) {
            ProfileService profileService = fabricService.get().adapt(ProfileService.class);
            Version version = profileService.getVersion(versionId);
            if (version != null) {
                for (String profileId : profiles) {
                    Profile profile = version.getRequiredProfile(profileId);
                    if (profile != null) {
                        Profile overlay = profileService.getOverlayProfile(profile);
                        Map<String, String> openshiftConfig = overlay.getConfiguration(OpenShiftConstants.OPENSHIFT_PID);
                        if (openshiftConfig != null)  {
                            openshiftConfigOverlay.putAll(openshiftConfig);
                        }
                    }
View Full Code Here

        executorService.submit(new ReleaseTask(context, workItems));
    }

    @Override
    public void stop(TaskContext context) {
        ProfileService profileService = fabricService.get().adapt(ProfileService.class);
        Container current = fabricService.get().getCurrentContainer();
        Version version = current.getVersion();
        String profileId = context.getConfiguration().get(TEMPLATE_PROFILE_PROPERTY_NAME) + "-" + name;
        if (version.hasProfile(profileId)) {
          String versionId = version.getId();
          profileService.deleteProfile(fabricService.get(), versionId, profileId, true);
        }
    }
View Full Code Here

            if (doesContainerExist(fabricService, name)) {
                throw new IllegalArgumentException("A container with name " + name + " already exists.");
            }

            // get the profiles for the given version
            ProfileService profileService = fabricService.adapt(ProfileService.class);
            Version version = versionId != null ? profileService.getRequiredVersion(versionId) : fabricService.getRequiredDefaultVersion();
            List<Profile> profiles = version.getProfiles();

            // validate profiles exists before creating a new container
            Set<String> names = getProfileNames();
            for (String profile : names) {
View Full Code Here

          throw new IllegalArgumentException("Task context configuration: Missing required property: " + TEMPLATE_PROFILE_PROPERTY_NAME);
      }
    }

    private void manageProfile(TaskContext context) {
        ProfileService profileService = fabricService.get().adapt(ProfileService.class);
        Container current = fabricService.get().getCurrentContainer();
        ProfileData profileData = createProfileData(context);
        String profileId = context.getConfiguration().get(TEMPLATE_PROFILE_PROPERTY_NAME) + "-" + name;
        Version version = current.getVersion();
      String versionId = version.getId();

      // [TODO] Revisit lock in ProfileTemplateWorker
        try {
            if (lock.acquire(60, TimeUnit.SECONDS)) {
                if (profileData.isEmpty()) {
                    if (version.hasProfile(profileId)) {
                        profileService.deleteProfile(fabricService.get(), versionId, profileId, true);
                    }
                    return;
                }
               
                Profile managedProfile;
                if (version.hasProfile(profileId)) {
                    Profile profile = profileService.getRequiredProfile(versionId, profileId);
                    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
                    builder.setFileConfigurations(profileData.getFiles());
                    managedProfile = profileService.updateProfile(builder.getProfile());
                } else {
                    ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
                    builder.setFileConfigurations(profileData.getFiles());
                    managedProfile = profileService.createProfile(builder.getProfile());
                }
               
                current.addProfiles(managedProfile);
            } else {
                throw new TimeoutException("Timed out waiting for lock");
View Full Code Here

TOP

Related Classes of io.fabric8.api.ProfileService

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.