Package org.rhq.core.system

Examples of org.rhq.core.system.ProcessExecutionResults


            failure.setErrorMessage("Start script does not exists");
            return failure;
        }
        ProcessExecution scriptExe = getProcessExecution(binDir);
        SystemInfo systemInfo = getResourceContext().getSystemInformation();
        ProcessExecutionResults results = systemInfo.executeProcess(scriptExe);
        if (results.getError() == null) {
            return new OperationResult("Successfully started Cassandra daemon");
        } else {
            OperationResult failure = new OperationResult("Failed to start Cassandra daemon");
            failure.setErrorMessage(ThrowableUtil.getAllMessages(results.getError()));
            return failure;
        }
    }
View Full Code Here


        boolean exists = false;
        ProcessExecution pe = new ProcessExecution("/bin/rpm");
        pe.setCaptureOutput(true);
        pe.setCheckExecutableExists(true);
        pe.setArguments(Arrays.asList("-qa", packageName));
        ProcessExecutionResults pr = sysinfo.executeProcess(pe);
        if (pr!=null && pr.getExitCode()!=null && pr.getExitCode() == 0) {
            String output = pr.getCapturedOutput();
            exists = output.contains(packageName);
        }
        return exists;
    }
View Full Code Here

            String command = "/usr/bin/koan";
            String virtName = configuration.getSimpleValue("name", "Guest " + System.currentTimeMillis());
            String profile = configuration.getSimpleValue("profile", "profile");
            String server = configuration.getSimpleValue("server", "localhost");
            String[] argsString = { "--virt", "--server", server, "--profile", profile, "--virt-name", virtName };
            ProcessExecutionResults pr = this.execute(command, argsString);
            if (pr.getExitCode() > 0) {
                log.error("Error executing command: " + this.buildCommandString(command, argsString));
                res.setErrorMessage(pr.getCapturedOutput());
            } else {
                res.setSimpleResult(pr.getCapturedOutput());
            }

        }

        return res;
View Full Code Here

        }
        ProcessExecution pe = new ProcessExecution(process);
        pe.setCaptureOutput(true);
        pe.setCheckExecutableExists(true);
        pe.setArguments(Arrays.asList(args));
        ProcessExecutionResults pr = resourceContext.getSystemInformation().executeProcess(pe);
        log.debug("Result " + pr.getExitCode());
        return pr;
    }
View Full Code Here

        if (!errors.isEmpty()) {
            setErrorMessage(operationResult, errors);
            return operationResult;
        }

        ProcessExecutionResults results = ServerControl
            .onServer(context.getPluginConfiguration(), getMode(), context.getSystemInformation())
            .lifecycle().startServer();
        logExecutionResults(results);

        if (results.getError() != null) {
            operationResult.setErrorMessage(results.getError().getMessage());
        } else if (results.getExitCode() != null && results.getExitCode() != 0) {
            operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n"
                + results.getCapturedOutput());
        } else {
            // Try to connect to the server - ping once per second, timing out after 20s.
            boolean up = waitForServerToStart();
            if (up) {
                operationResult.setSimpleResult("Success");
View Full Code Here

        ServerControl.Cli cli = ServerControl
            .onServer(context.getPluginConfiguration(), getMode(), context.getSystemInformation())
            .waitingFor(waitTime * 1000)
            .killingOnTimeout(Boolean.parseBoolean(parameters.getSimpleValue("killOnTimeout", "false"))).cli();

        ProcessExecutionResults results;
        String commands = parameters.getSimpleValue("commands");
        if (commands != null) {
            results = cli.executeCliCommand(commands);
        } else {
            File script = new File(parameters.getSimpleValue("file"));
            if (!script.isAbsolute()) {
                script = new File(serverPluginConfig.getHomeDir(), script.getPath()).getAbsoluteFile();
            }

            results = cli.executeCliScript(script);
        }

        logExecutionResults(results);
        result.setSimpleResult(results.getCapturedOutput());

        if (results.getError() != null) {
            result.setErrorMessage(results.getError().getMessage());
            return result;
        }
        if (results.getExitCode() == null) {
            result.setErrorMessage("jboss-cli execution timed out");
            return result;
        }
        if (results.getExitCode() != 0) {
            result.setErrorMessage("jboss-cli execution failed with error code " + results.getExitCode());
            return result;
        }

        if (Boolean.parseBoolean(parameters.getSimpleValue("triggerAvailability", null))) {
            context.getAvailabilityContext().requestAvailabilityCheck();
View Full Code Here

        File scriptFile = null;
        try {
            scriptFile = File.createTempFile(handoverRequest.getFilename(), ".tmp", context.getTemporaryDirectory());
            FileUtil.writeFile(handoverRequest.getContent(), scriptFile);

            ProcessExecutionResults results = ServerControl //
                .onServer( //
                        getServerPluginConfiguration().getPluginConfig(), //
                        getMode(), //
                    context.getSystemInformation() //
                ) //
                .waitingFor(waitTime) //
                .killingOnTimeout(killOnTimeout) //
                .cli() //
                .executeCliScript(scriptFile.getAbsoluteFile());

            logExecutionResults(results);

            Throwable error = results.getError();
            if (error != null) {
                return BundleHandoverResponse.failure(EXECUTION, error.getMessage(), error);
            }
            Integer exitCode = results.getExitCode();
            if (exitCode == null) {
                return BundleHandoverResponse.failure(EXECUTION, "Timeout waiting for completion of the CLI process");
            }
            if (exitCode != 0) {
                return BundleHandoverResponse.failure(EXECUTION, "CLI process exit code is " + exitCode);
View Full Code Here

            LOG.debug("getSKMRequests failed: " + res.getFailureDescription());
        }
    }

    protected String collectPatches() {
        ProcessExecutionResults results = ServerControl.onServer(context.getPluginConfiguration(), getMode(),
                context.getSystemInformation())
            .cli().disconnected(true).executeCliCommand("patch info");

        if (results.getError() != null) {
            LOG.info("Failed to determine the list of installed patches on " + context.getResourceDetails() +
                ". The execution of JBoss CLI failed.", results.getError());

            return null;
        } else if (results.getExitCode() == null) {
            LOG.info("Failed to determine the list of installed patches on " + context.getResourceDetails() +
                ". The execution of JBoss CLI timed out.");

            return null;
        } else if (results.getExitCode() != 0) {
            LOG.info("Failed to determine the list of installed patches on " + context.getResourceDetails() +
                ". The execution of JBoss CLI exited with code " + results.getExitCode() + ".");

            return null;
        } else {
            String json = results.getCapturedOutput();

            ObjectMapper mapper = new ObjectMapper();

            Result result;
            try {
View Full Code Here

            PropertySimple descriptionProp = pluginConfig.getSimple(PLUGINCONFIG_FIXED_DESC);
            if (descriptionProp != null && descriptionProp.getStringValue() != null) {
                description = descriptionProp.getStringValue();
            } else {
                String args = pluginConfig.getSimpleValue(PLUGINCONFIG_DESC_ARGS, null);
                ProcessExecutionResults results = executeExecutable(context.getSystemInformation(), pluginConfig, args,
                    5000L, true, getConfiguredEscapeCharacter(pluginConfig));
                if (results != null) {
                    if (results.getError() != null) {
                        LOG.warn("Failed to execute cli executable to get description. Cause: "
                            + ThrowableUtil.getAllMessages(results.getError()));
                    } else if (results.getCapturedOutput() != null) {
                        String regex = pluginConfig.getSimpleValue(PLUGINCONFIG_DESC_REGEX, null);
                        String output = results.getCapturedOutput();
                        if (output != null) {
                            output = output.trim();
                        }
                        if (regex == null) {
                            description = output;
View Full Code Here

            PropertySimple versionProp = pluginConfig.getSimple(PLUGINCONFIG_FIXED_VERSION);
            if (versionProp != null && versionProp.getStringValue() != null) {
                version = versionProp.getStringValue();
            } else {
                String args = pluginConfig.getSimpleValue(PLUGINCONFIG_VERSION_ARGS, null);
                ProcessExecutionResults results = executeExecutable(context.getSystemInformation(), pluginConfig, args,
                    5000L, true, getConfiguredEscapeCharacter(pluginConfig));
                if (results != null) {
                    if (results.getError() != null) {
                        LOG.warn("Failed to execute cli executable to get version. Cause: "
                            + ThrowableUtil.getAllMessages(results.getError()));
                    } else if (results.getCapturedOutput() != null) {
                        String regex = pluginConfig.getSimpleValue(PLUGINCONFIG_VERSION_REGEX, null);
                        String output = results.getCapturedOutput();
                        if (output != null) {
                            output = output.trim();
                        }
                        if (regex == null) {
                            version = output;
View Full Code Here

TOP

Related Classes of org.rhq.core.system.ProcessExecutionResults

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.