Package com.dtolabs.rundeck.core.common

Examples of com.dtolabs.rundeck.core.common.Framework


        super(name);
    }

    public void setUp() {
        super.setUp();
        final Framework frameworkInstance = getFrameworkInstance();
        final FrameworkProject frameworkProject = frameworkInstance.getFrameworkProjectMgr().createFrameworkProject(
            PROJ_NAME);
        File resourcesfile = new File(frameworkProject.getNodesResourceFilePath());
        //copy test nodes to resources file
        try {
            FileUtils.copyFileStreams(new File("src/test/resources/com/dtolabs/rundeck/core/common/test-nodes1.xml"),
View Full Code Here


        File workingdir = null;
        String scriptargs;
        String dirstring;

        //get project or framework property for script-exec args
        final Framework framework = executionContext.getFramework();
        //look for specific property
        scriptargs = framework.getProjectProperty(executionContext.getFrameworkProject(),
                                                  SCRIPT_COPY_DEFAULT_COMMAND_PROPERTY);


        if (null != node.getAttributes().get(SCRIPT_ATTRIBUTE)) {
            scriptargs = node.getAttributes().get(SCRIPT_ATTRIBUTE);
        }
        if (null == scriptargs) {
            throw new FileCopierException(
                "[script-copy file copier] no attribute " + SCRIPT_ATTRIBUTE + " was found on node: "
                + node
                    .getNodename() + ", and no " + SCRIPT_COPY_DEFAULT_COMMAND_PROPERTY
                + " property was configured for the project or framework.",
                StepFailureReason.ConfigurationFailure
            );
        }

        dirstring = framework.getProjectProperty(executionContext.getFrameworkProject(),
                                                 SCRIPT_COPY_DEFAULT_DIR_PROPERTY);
        if (null != node.getAttributes().get(DIR_ATTRIBUTE)) {
            dirstring = node.getAttributes().get(DIR_ATTRIBUTE);
        }
        if (null != dirstring && !"".equals(dirstring)) {
            workingdir = new File(dirstring);
        }

        final File srcFile =
                null != file ?
                        file :
                        BaseFileCopier.writeTempFile(executionContext, file, input, content);


        //create context data with node attributes
        Map<String, Map<String, String>> newDataContext;
        final Map<String, Map<String, String>> nodeContext =
                DataContextUtils.addContext("node", DataContextUtils.nodeData(node), executionContext.getDataContext());

        final HashMap<String, String> scptexec = new HashMap<String, String>(){{
            //set filename of source file
            put("filename", srcFile.getName());
            put("file", srcFile.getAbsolutePath());
            //add file, dir, destination to the file-copy data
        }};
        if (null != workingdir) {
            //set up the data context to include the working dir
            scptexec.put("dir", workingdir.getAbsolutePath());
        }

        newDataContext = DataContextUtils.addContext("file-copy", scptexec, nodeContext);

        //expand remote filepath if we are copying a script
        String copiedFilepath;
        if (null == remotePath) {
            copiedFilepath = framework.getProjectProperty(executionContext.getFrameworkProject(),
                    SCRIPT_COPY_DEFAULT_REMOTE_FILEPATH_PROPERTY);
            if (null != node.getAttributes().get(REMOTE_FILEPATH_ATTRIBUTE)) {
                copiedFilepath = node.getAttributes().get(REMOTE_FILEPATH_ATTRIBUTE);
            }
            if (null != copiedFilepath) {
                if (!(copiedFilepath.contains("${file-copy.filename}")
                        || copiedFilepath.contains("${file-copy.file}"))
                        && !copiedFilepath.endsWith("/")) {
                    copiedFilepath += "/";
                }
                copiedFilepath = DataContextUtils.replaceDataReferences(copiedFilepath, newDataContext);
            }
        } else {
            //we are copying to a specific destination
            copiedFilepath = remotePath;
        }

        //put file in a directory
        if (null != copiedFilepath && copiedFilepath.endsWith("/")) {
            copiedFilepath += srcFile.getName();
        }

        scptexec.put("destination", null != copiedFilepath ? copiedFilepath : "");

        newDataContext = DataContextUtils.addContext("file-copy", scptexec, nodeContext);

        final Process exec;

        String remoteShell = framework.getProjectProperty(executionContext.getFrameworkProject(),
                                                          SCRIPT_COPY_DEFAULT_REMOTE_SHELL);
        if (null != node.getAttributes().get(SHELL_ATTRIBUTE)) {
            remoteShell = node.getAttributes().get(SHELL_ATTRIBUTE);
        }
View Full Code Here

        File workingdir = null;
        String scriptargs;
        String dirstring;

        //get project or framework property for script-exec args
        final Framework framework = executionContext.getFramework();
        //look for specific property
        scriptargs = framework.getProjectProperty(executionContext.getFrameworkProject(),
                                                  SCRIPT_EXEC_DEFAULT_COMMAND_PROPERTY);


        if (null != node.getAttributes().get(SCRIPT_ATTRIBUTE)) {
            scriptargs = node.getAttributes().get(SCRIPT_ATTRIBUTE);
        }
        if (null == scriptargs) {
            return NodeExecutorResultImpl.createFailure(StepFailureReason.ConfigurationFailure,
                                                        "[script-exec node executor] no script-exec attribute "
                                                        + SCRIPT_ATTRIBUTE + " was found on node: "
                                                        + node
                                                            .getNodename() + ", and no "
                                                        + SCRIPT_EXEC_DEFAULT_COMMAND_PROPERTY
                                                        + " property was configured for the project or framework.",
                                                        node);
        }

        dirstring = framework.getProjectProperty(executionContext.getFrameworkProject(),
                                                 SCRIPT_EXEC_DEFAULT_DIR_PROPERTY);
        if (null != node.getAttributes().get(DIR_ATTRIBUTE)) {
            dirstring = node.getAttributes().get(DIR_ATTRIBUTE);
        }
        if (null != dirstring && !"".equals(dirstring)) {
            workingdir = new File(dirstring);
        }

        final Map<String, Map<String, String>> dataContext = executionContext.getDataContext();

        //add some more data context values to allow templatized script-exec
        final HashMap<String, String> scptexec = new HashMap<String, String>();
        scptexec.put("command", StringArrayUtil.asString(command, " "));
        if (null != workingdir) {
            scptexec.put("dir", workingdir.getAbsolutePath());
        }
        final Map<String, Map<String, String>> newDataContext = DataContextUtils.addContext("exec", scptexec,
                                                                                            dataContext);

        final Process exec;

        String remoteShell = framework.getProjectProperty(executionContext.getFrameworkProject(),
                                                          SCRIPT_EXEC_DEFAULT_REMOTE_SHELL);
        if (null != node.getAttributes().get(SHELL_ATTRIBUTE)) {
            remoteShell = node.getAttributes().get(SHELL_ATTRIBUTE);
        }
        try {
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.common.Framework

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.