Examples of BundleManagerProvider


Examples of org.rhq.core.pluginapi.bundle.BundleManagerProvider

        ASConnection connection = new ASConnection(
            ASConnectionParams.createFrom(new ServerPluginConfiguration(request.getReferencedConfiguration())));

        ProcessExecutionResults results;
        BundleManagerProvider bmp = request.getBundleManagerProvider();
        BundleResourceDeployment rd = request.getResourceDeployment();

        Result<Boolean> stop = stopIfNeeded(connection, control,
            request.getResourceDeployment().getBundleDeployment().getConfiguration(), bmp, rd);
        if (stop.failed()) {
View Full Code Here

Examples of org.rhq.core.pluginapi.bundle.BundleManagerProvider

                BundleAntProject project = executeDeploymentPhase(recipeFile, antProps, buildListeners, installPhase,
                    new PluginContainerHandoverTarget(request));
                executeDeploymentPhase(recipeFile, antProps, buildListeners, DeploymentPhase.START, null);

                // Send the diffs to the Server so it can store them as an entry in the deployment history.
                BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
                DeployDifferences diffs = project.getDeployDifferences();

                String msg = "Added files=" + diffs.getAddedFiles().size() + "; Deleted files="
                    + diffs.getDeletedFiles().size() + " (see attached details for more information)";
                String fullDetails = formatDiff(diffs);
                bundleManagerProvider.auditDeployment(resourceDeployment, "Deployment Differences", project.getName(),
                    DEPLOY_STEP, null, msg, fullDetails);
            } catch (Throwable t) {
                if (LOG.isDebugEnabled()) {
                    try {
                        LOG.debug(new String(StreamUtil.slurp(new FileInputStream(logFile))));
View Full Code Here

Examples of org.rhq.core.pluginapi.bundle.BundleManagerProvider

        BundlePurgeResult result = new BundlePurgeResult();
        try {
            BundleResourceDeployment deploymentToPurge = request.getLiveResourceDeployment();
            File deployDir = request.getAbsoluteDestinationDirectory();
            String deployDirAbsolutePath = deployDir.getAbsolutePath();
            BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();

            boolean manageAllDeployDir = true;
            boolean errorPurgingDeployDirContent = false;
            File metadataDirectoryToPurge = null;

            // If the receipe copied file(s) outside of the deployment directory (external, raw files), they will still exist.
            // Let's get the metadata information that tells us if such files exist, and if so, remove them.
            // Since we are iterating over the manage files anyway, let's also remove the files/subdirs under the deploy directory too.
            DeploymentsMetadata metadata = new DeploymentsMetadata(deployDir);
            if (metadata.isManaged()) {
                metadataDirectoryToPurge = metadata.getMetadataDirectory();

                //as of RHQ 4.9.0, we only only support "full" and "filesAndDirectories" destination compliance modes
                //which we used to describe by boolean "manageRootDir"... Let's not use the deprecated API's but not
                // change the code too much...
                manageAllDeployDir = metadata.getCurrentDeploymentProperties().getDestinationCompliance() == DestinationComplianceMode.full;

                int totalExternalFiles = 0;
                ArrayList<String> externalDeleteSuccesses = new ArrayList<String>(0);
                ArrayList<String> externalDeleteFailures = new ArrayList<String>(0);
                FileHashcodeMap deployDirFileHashcodes = metadata.getCurrentDeploymentFileHashcodes();
                for (String filePath : deployDirFileHashcodes.keySet()) {
                    File file = new File(filePath);
                    if (file.isAbsolute()) {
                        totalExternalFiles++;
                        if (file.exists()) {
                            if (file.delete()) {
                                externalDeleteSuccesses.add(filePath);
                            } else {
                                externalDeleteFailures.add(filePath);
                            }
                        } else {
                            externalDeleteSuccesses.add(filePath); // someone already deleted it, consider it removed successfully
                        }
                    } else {
                        // a relative path means it is inside the deploy dir (i.e. its relative to deployDir).
                        // note that we only remove child directories and files that are direct children of the deploy dir itself;
                        // we do not purge the deploy dir itself, in case we are not managing the full deploy dir.
                        String parentDir = file.getParent();
                        if (parentDir == null) {
                            // this file is directly in the deploy dir
                            file = new File(deployDir, filePath);
                            file.delete();
                        } else {
                            // this file is under some subdirectory under the deploy dir - purge the subdirectory completely
                            file = new File(deployDir, parentDir);
                            FileUtil.purge(file, true);
                        }
                        if (file.exists()) {
                            errorPurgingDeployDirContent = true;
                        }
                    }
                }
                if (totalExternalFiles > 0) {
                    if (!externalDeleteSuccesses.isEmpty()) {
                        StringBuilder deleteSuccessesDetails = new StringBuilder();
                        for (String path : externalDeleteSuccesses) {
                            deleteSuccessesDetails.append(path).append("\n");
                        }
                        bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge", "External files were purged",
                            AUDIT_MESSAGE, SUCCESS, "[" + externalDeleteSuccesses.size() + "] of ["
                                + totalExternalFiles
                                + "] external files were purged. See attached details for the list",
                            deleteSuccessesDetails.toString());
                    }
                    if (!externalDeleteFailures.isEmpty()) {
                        StringBuilder deleteFailuresDetails = new StringBuilder();
                        for (String path : externalDeleteFailures) {
                            deleteFailuresDetails.append(path).append("\n");
                        }
                        bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                            "External files failed to be purged", AUDIT_MESSAGE, FAILURE,
                            "[" + externalDeleteFailures.size() + "] of [" + totalExternalFiles
                                + "] external files failed to be purged. See attached details for the list",
                            deleteFailuresDetails.toString());
                    }
                }
            }

            // if we are managing the full deploy dir, completely purge the deployment directory.
            // otherwise, just report that we deleted what we were responsible for.
            if (manageAllDeployDir) {
                FileUtil.purge(deployDir, true);
                if (!deployDir.exists()) {
                    bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                        "The destination directory has been purged", AUDIT_MESSAGE, SUCCESS, "Directory purged: "
                            + deployDirAbsolutePath, null);
                } else {
                    bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                        "The destination directory failed to be purged", AUDIT_MESSAGE, FAILURE,
                        "The directory that failed to be purged: " + deployDirAbsolutePath, null);
                }
            } else {
                if (!errorPurgingDeployDirContent) {
                    bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                        "The managed bundle content was removed from the destination directory; "
                            + "other unmanaged content may still remain", AUDIT_MESSAGE, SUCCESS, "Deploy Directory: "
                            + deployDirAbsolutePath, null);
                } else {
                    bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                        "Not all managed bundle content was able to be removed from the destination directory. "
                            + "That managed content along with other unmanaged content still remain", AUDIT_MESSAGE,
                        FAILURE, "Deploy Directory: " + deployDirAbsolutePath, null);
                }

                // make sure we remove the metadata directory, too - since it may still have sensitive files that were backed up
                if (metadataDirectoryToPurge != null) {
                    FileUtil.purge(metadataDirectoryToPurge, true);
                    if (metadataDirectoryToPurge.exists()) {
                        bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                            "Failed to purge the metadata directory from the destination directory. "
                                + "It may still contain backed up files from previous bundle deployments.",
                            AUDIT_MESSAGE, FAILURE,
                            "Metadata Directory: " + metadataDirectoryToPurge.getAbsolutePath(), null);
                    }
View Full Code Here

Examples of org.rhq.core.pluginapi.bundle.BundleManagerProvider

        }

        @Override
        public boolean handoverContent(HandoverInfo handoverInfo) {
            BundleResourceDeployment resourceDeployment = request.getResourceDeployment();
            BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();

            BundleHandoverContext.Builder contextBuilder = new BundleHandoverContext.Builder();
            contextBuilder.setRevert(handoverInfo.isRevert());

            BundleHandoverRequest.Builder handoverRequestBuilder = new BundleHandoverRequest.Builder();
            handoverRequestBuilder.setContent(handoverInfo.getContent()) //
                .setFilename(handoverInfo.getFilename()) //
                .setAction(handoverInfo.getAction()).setParams(handoverInfo.getParams())//
                .setContext(contextBuilder.create());

            BundleHandoverRequest bundleHandoverRequest = handoverRequestBuilder.createBundleHandoverRequest();
            BundleHandoverResponse handoverResponse = bundleManagerProvider.handoverContent(
                resourceDeployment.getResource(), bundleHandoverRequest);

            boolean success = handoverResponse.isSuccess();
            try {

                StringWriter attachmentStringWriter = new StringWriter();
                PrintWriter attachmentPrintWriter = new PrintWriter(attachmentStringWriter, true);
                attachmentPrintWriter.println(bundleHandoverRequest);

                if (success) {
                    bundleManagerProvider.auditDeployment(resourceDeployment, "Handover",
                        "Successful content handover to bundle target resource", AUDIT_MESSAGE, SUCCESS,
                        handoverResponse.getMessage(), attachmentStringWriter.toString());
                } else {
                    String handoverFailure = getHandoverFailure(handoverResponse);
                    Throwable handoverResponseThrowable = handoverResponse.getThrowable();
                    if (handoverResponseThrowable != null) {
                        attachmentPrintWriter.println();
                        attachmentPrintWriter.println(ThrowableUtil.getAllMessages(handoverResponseThrowable));
                    }

                    bundleManagerProvider.auditDeployment(resourceDeployment, "Handover", handoverFailure,
                        AUDIT_MESSAGE, FAILURE, handoverResponse.getMessage(), attachmentStringWriter.toString());
                }
            } catch (Exception e) {
                LOG.warn("Unexpected failure while auditing deployment", e);
            }
View Full Code Here

Examples of org.rhq.core.pluginapi.bundle.BundleManagerProvider

        try {
            BundleResourceDeployment resourceDeployment = request.getResourceDeployment();
            BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();
            BundleVersion bundleVersion = bundleDeployment.getBundleVersion();
            BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();

            // before processing the recipe, wipe the dest dir if we need to perform a clean deployment
            if (request.isCleanDeployment()) {
                File deployDir = request.getAbsoluteDestinationDirectory();
                if (deployDir.exists()) {
                    bundleManagerProvider.auditDeployment(resourceDeployment, "Cleaning Deployment", deployDir
                        .getAbsolutePath(), null, null, "The existing deployment found at ["
                        + deployDir.getAbsolutePath() + "] will be removed.", null);
                    FileUtils.purge(deployDir, true);
                }
            }

            // process the recipe
            String recipe = bundleVersion.getRecipe();
            RecipeParser parser = new RecipeParser();
            ProcessingRecipeContext recipeContext = new ProcessingRecipeContext(recipe, request
                .getPackageVersionFiles(), this.resourceContext.getSystemInformation(), request
                .getBundleFilesLocation().getAbsolutePath(), resourceDeployment, bundleManagerProvider);

            bundleManagerProvider.auditDeployment(resourceDeployment, "Configurtion Variable Replacement",
                bundleDeployment.getName(), null, null, "setting replacement variable values using ["
                    + bundleDeployment.getConfiguration().toString(true) + "]", null);
            recipeContext.setReplacementVariableValues(bundleDeployment.getConfiguration());
            recipeContext.addReplacementVariableValue(DEPLOY_DIR, request.getAbsoluteDestinationDirectory()
                .getAbsolutePath());
            recipeContext.addReplacementVariableValue(DEPLOY_ID, Integer.toString(bundleDeployment.getId()));
            recipeContext.addReplacementVariableValue(DEPLOY_NAME, bundleDeployment.getName());

            parser.setReplaceReplacementVariables(true);

            bundleManagerProvider.auditDeployment(resourceDeployment, "Parse Recipe", bundleDeployment.getName(), null,
                null, "Parsing Recipe using context [" + recipeContext + "]", null);
            parser.parseRecipe(recipeContext);
        } catch (Throwable t) {
            log.error("Failed to deploy bundle [" + request + "]", t);
            result.setErrorMessage(t);
View Full Code Here

Examples of org.rhq.core.pluginapi.bundle.BundleManagerProvider

        BundlePurgeResult result = new BundlePurgeResult();
        try {
            BundleResourceDeployment deploymentToPurge = request.getLiveResourceDeployment();
            File deployDir = request.getAbsoluteDestinationDirectory();
            String deployDirAbsolutePath = deployDir.getAbsolutePath();
            BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();

            // completely purge the deployment directory.
            // TODO: if the receipe copied a file outside of the deployment directory, it will still exist. How do we remove those?
            FileUtil.purge(deployDir, true);

            if (!deployDir.exists()) {
                bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                    "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
                    "Directory purged: " + deployDirAbsolutePath, null);
            } else {
                bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
                    "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
                    "The directory that failed to be purged: " + deployDirAbsolutePath, null);
            }
        } catch (Throwable t) {
            log.error("Failed to purge bundle [" + request + "]", t);
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.