Examples of BundleDeployment


Examples of org.rhq.core.domain.bundle.BundleDeployment

        return resourceDeployment;
    }

    @Override
    public BundleDeploymentStatus determineBundleDeploymentStatus(int bundleDeploymentId) {
        BundleDeployment deployment = entityManager.find(BundleDeployment.class, bundleDeploymentId);

        if (deployment.getStatus().isTerminal()) {
            return deployment.getStatus();
        }

        List<BundleResourceDeployment> deployments = deployment.getResourceDeployments();
        boolean someInProgress = false;
        boolean someSuccess = false;
        boolean someFailure = false;
        for (BundleResourceDeployment rd : deployments) {
            switch (rd.getStatus()) {
            case SUCCESS:
                someSuccess = true;
                break;
            case FAILURE:
                someFailure = true;
                break;
            case IN_PROGRESS:
                someInProgress = true;
                break;
            }
        }
        if (someInProgress) {
            deployment.setStatus(BundleDeploymentStatus.IN_PROGRESS);
        } else if (someSuccess) {
            deployment.setStatus(someFailure ? BundleDeploymentStatus.MIXED : BundleDeploymentStatus.SUCCESS);
        } else {
            deployment.setStatus(BundleDeploymentStatus.FAILURE);
        }

        return deployment.getStatus();
    }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        // those bundle deployments for destinations not viewable by the user. In essence we wanted two authz tokens,
        // one for bundle and one for resource group, but we can only supply one.
        if (!(result.isEmpty() || authorizationManager.isInventoryManager(subject))) {

            for (Iterator<BundleDeployment> i = result.iterator(); i.hasNext();) {
                BundleDeployment bd = i.next();
                int groupId = bd.getDestination().getGroup().getId();
                if (!authorizationManager.canViewGroup(subject, groupId)) {
                    i.remove();
                }
            }
        }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        repoManager.deleteRepo(subjectManager.getOverlord(), bundleRepo.getId());
    }

    @Override
    public void deleteBundleDeployment(Subject subject, int bundleDeploymentId) throws Exception {
        BundleDeployment doomed = this.entityManager.find(BundleDeployment.class, bundleDeploymentId);
        if (null == doomed) {
            return;
        }

        checkDeployBundleAuthz(subject, doomed.getBundleVersion().getBundle().getId(), doomed.getDestination()
            .getGroup().getId());

        // only allow deployments to be deleted if they are not started or finished
        if (BundleDeploymentStatus.PENDING == doomed.getStatus()
            || BundleDeploymentStatus.SUCCESS == doomed.getStatus()
            || BundleDeploymentStatus.FAILURE == doomed.getStatus()
            || BundleDeploymentStatus.MIXED == doomed.getStatus()) {
            // change the pointer like in the linked list (ie. when removing B from A -> B -> C, it should result
            // in following situation: A -> C)
            Query q = entityManager.createNamedQuery(BundleDeployment.QUERY_UPDATE_FOR_DEPLOYMENT_REMOVE);
            q.setParameter("bundleId", doomed.getId());
            q.executeUpdate();
            entityManager.flush();

            entityManager.remove(doomed);
        } else {
            throw new IllegalArgumentException("Can not delete deployment with status [" + doomed.getStatus() + "]");
        }
    }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    @RequiredPermission(Permission.MANAGE_BUNDLE)
    public void updateBundleDeploymentTags(Subject subject, int bundleDeploymentId, Set<Tag> tags) {

        Set<Tag> definedTags = addTags(subject, tags);
        BundleDeployment bundleDeployment = entityManager.find(BundleDeployment.class, bundleDeploymentId);

        Set<Tag> previousTags = new HashSet<Tag>(bundleDeployment.getTags());
        previousTags.removeAll(definedTags);
        for (Tag tag : previousTags) {
            tag.removeBundleDeployment(bundleDeployment);
        }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    public BundleScheduleResponse schedule(final BundleScheduleRequest request) {
        final BundleScheduleResponse response = new BundleScheduleResponse();

        try {
            final BundleResourceDeployment resourceDeployment = request.getBundleResourceDeployment();
            final BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();

            // find the resource that will handle the bundle processing
            BundleType bundleType = bundleDeployment.getBundleVersion().getBundle().getBundleType();
            ResourceType resourceType = bundleType.getResourceType();
            Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType);
            if (resources.isEmpty()) {
                throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
            }
            final int bundleHandlerResourceId = resources.iterator().next().getId();
            final ResourceContainer resourceContainer = inventoryManager.getResourceContainer(bundleHandlerResourceId);
            if (null == resourceContainer.getResourceContext()) {
                throw new Exception("No bundle plugin resource available to handle deployment for bundle type ["
                    + bundleType
                    + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
            }

            auditDeployment(resourceDeployment, AUDIT_DEPLOYMENT_SCHEDULED, bundleDeployment.getName(),
                "Scheduled deployment time: " + request.getRequestedDeployTimeAsString());

            Runnable deployerRunnable = new Runnable() {
                @Override
                public void run() {
                    try {
                        // pull down the bundle files that the plugin will need in order to process the bundle
                        File pluginTmpDir = resourceContainer.getResourceContext().getTemporaryDirectory();
                        File bundleFilesDir = new File(pluginTmpDir, "bundle-versions/"
                            + bundleDeployment.getBundleVersion().getId());
                        bundleFilesDir.mkdirs();

                        // clean up any old downloads we may have retrieved before. This helps clean out
                        // our temp directory so we don't unnecessarily fill up our file system with obsolete files
                        removeOldDownloadedBundleFiles(bundleFilesDir);

                        // now download the bundle files we need for the current deployment
                        Map<PackageVersion, File> downloadedFiles = downloadBundleFiles(resourceDeployment,
                            bundleFilesDir);

                        // deploy the bundle utilizing the bundle facet object
                        String deploymentMessage = "Deployment [" + bundleDeployment + "] to ["
                            + resourceDeployment.getResource() + "]";
                        auditDeployment(resourceDeployment, AUDIT_DEPLOYMENT_STARTED, bundleDeployment.getName(),
                            deploymentMessage);

                        BundleDeployRequest deployRequest = new BundleDeployRequest();
                        deployRequest.setBundleManagerProvider(BundleManager.this);
                        deployRequest.setResourceDeployment(resourceDeployment);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    public BundlePurgeResponse purge(BundlePurgeRequest request) {
        final BundlePurgeResponse response = new BundlePurgeResponse();

        try {
            final BundleResourceDeployment resourceDeployment = request.getLiveBundleResourceDeployment();
            final BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();

            // find the resource that will purge the bundle
            BundleType bundleType = bundleDeployment.getBundleVersion().getBundle().getBundleType();
            ResourceType resourceType = bundleType.getResourceType();
            Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType);
            if (resources.isEmpty()) {
                throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
            }
            final int bundleHandlerResourceId = resources.iterator().next().getId();
            final ResourceContainer resourceContainer = inventoryManager.getResourceContainer(bundleHandlerResourceId);
            if (null == resourceContainer.getResourceContext()) {
                throw new Exception("No bundle plugin resource available to handle purge for bundle type ["
                    + bundleType
                    + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
            }

            // purge the bundle utilizing the bundle facet object
            String deploymentMessage = "Deployment [" + bundleDeployment + "] to be purged via ["
                + resourceDeployment.getResource() + "]";
            auditDeployment(resourceDeployment, AUDIT_PURGE_STARTED, bundleDeployment.getName(), deploymentMessage);

            org.rhq.core.pluginapi.bundle.BundlePurgeRequest purgeRequest = new org.rhq.core.pluginapi.bundle.BundlePurgeRequest();
            purgeRequest.setBundleManagerProvider(this);
            purgeRequest.setLiveResourceDeployment(resourceDeployment);

            File absoluteDestDir = getAbsoluteDestinationDir(request.getLiveBundleResourceDeployment());
            if (absoluteDestDir != null) {
                purgeRequest.setDestinationTarget(absoluteDestDir.toURI());
            } else {
                String connectionString = getConnectionString(request.getLiveBundleResourceDeployment());
                if (connectionString != null) {
                    purgeRequest.setDestinationTarget(URI.create(connectionString));
                }

                purgeRequest.setReferencedConfiguration(
                    createReferencedConfigurationFromResource(request.getLiveBundleResourceDeployment()));
            }

            // get the bundle facet object that will process the bundle and call it to start the purge
            int facetMethodTimeout =
                30 * 60 * 1000; // 30 minutes should be enough time for the bundle plugin to purge everything
            BundleFacet bundlePluginComponent = getBundleFacet(bundleHandlerResourceId, facetMethodTimeout);
            BundlePurgeResult result = bundlePluginComponent.purgeBundle(purgeRequest);
            if (result.isSuccess()) {
                auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), deploymentMessage);
            } else {
                response.setErrorMessage(result.getErrorMessage());
                auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), null,
                    Status.FAILURE, "Failed: " + deploymentMessage, result.getErrorMessage());
            }
        } catch (Throwable t) {
            LOG.error("Failed to purge bundle: " + request, t);
            response.setErrorMessage(t);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

     * @throws Exception
     */
    private Map<PackageVersion, File> downloadBundleFiles(BundleResourceDeployment resourceDeployment, File downloadDir)
        throws Exception {

        BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();
        BundleVersion bundleVersion = bundleDeployment.getBundleVersion();

        Map<PackageVersion, File> packageVersionFiles = new HashMap<PackageVersion, File>();
        List<PackageVersion> packageVersions = getAllBundleVersionPackageVersions(bundleVersion);
        for (PackageVersion packageVersion : packageVersions) {
            File packageFile = new File(downloadDir, packageVersion.getFileName());
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        BundleType bundleType = new BundleType("bundleTypeName", im.bundleHandlerType);
        Bundle bundle = new Bundle("bundleName", bundleType, null, null);
        BundleVersion bundleVersion = new BundleVersion("bundleVersionName", "1.0", bundle, "");
        BundleDestination destination = new BundleDestination(bundle, "destName", null,
            MockInventoryManager.BUNDLE_CONFIG_NAME_FS, getPath("/tmp/dest")); // ABSOLUTE PATH
        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverFS);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        // No matter what the CONTEXT_VALUE_FS is (i.e. the default context value in the plugin descriptor),
        // if the user specifies an absolute path for the destination, that will be used explicitly. So here in this test,
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        BundleType bundleType = new BundleType("bundleTypeName", im.bundleHandlerType);
        Bundle bundle = new Bundle("bundleName", bundleType, null, null);
        BundleVersion bundleVersion = new BundleVersion("bundleVersionName", "1.0", bundle, "");
        BundleDestination destination = new BundleDestination(bundle, "destName", null,
            MockInventoryManager.BUNDLE_CONFIG_NAME_FS, "relative/path"); // RELATIVE PATH
        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverFS);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        // in the real world, the context value for fileSystem contexts will probably always be "/" but
        // to test that we are really using this context value, our tests set it to something other than "/".
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        BundleType bundleType = new BundleType("bundleTypeName", im.bundleHandlerType);
        Bundle bundle = new Bundle("bundleName", bundleType, null, null);
        BundleVersion bundleVersion = new BundleVersion("bundleVersionName", "1.0", bundle, "");
        BundleDestination destination = new BundleDestination(bundle, "destName", null,
            MockInventoryManager.BUNDLE_CONFIG_NAME_PC, "relative/path/pc");
        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverPC);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        mockBundleManager.absolutePathToAssert = BUNDLE_CONFIG_LOCATION_PC + "/relative/path/pc";
        BundleScheduleResponse response = mockBundleManager.schedule(request);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.