Package com.dtolabs.rundeck.core.common

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


    }

    public void testRemoteDirForNode() throws Exception {
        final BaseFileCopier baseFileCopier = new BaseFileCopier();
        NodeEntryImpl node = new NodeEntryImpl();
        node.setOsFamily("unix");

        assertEquals("/tmp/", baseFileCopier.getRemoteDirForNode(node));

        node.setOsFamily("windows");

        assertEquals("C:\\WINDOWS\\TEMP\\", baseFileCopier.getRemoteDirForNode(node));
    }
View Full Code Here


        assertEquals("C:\\WINDOWS\\TEMP\\", baseFileCopier.getRemoteDirForNode(node));
    }

    public void testGenerateFilepathUnix() throws Exception{
        NodeEntryImpl node = new NodeEntryImpl("node1");
        node.setOsFamily("unix");
        assertMatches("/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
    }
View Full Code Here

        NodeEntryImpl node = new NodeEntryImpl("node1");
        node.setOsFamily("unix");
        assertMatches("/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
    }
    public void testGenerateFilepathFileExtension() throws Exception{
        NodeEntryImpl node = new NodeEntryImpl("node1");
        node.setOsFamily("unix");
        assertMatches("/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("/tmp/\\d+-node1-blah.sh.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh","ext"));
        assertMatches("/tmp/\\d+-node1-blah.sh.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh",".ext"));
        assertMatches("/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh",null));
    }
View Full Code Here

        assertMatches("/tmp/\\d+-node1-blah.sh.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh","ext"));
        assertMatches("/tmp/\\d+-node1-blah.sh.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh",".ext"));
        assertMatches("/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh",null));
    }
    public void testGenerateFilepathFileExtensionWindows() throws Exception{
        NodeEntryImpl node = new NodeEntryImpl("node1");
        node.setOsFamily("windows");
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.sh.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh","ext"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.bat.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat","ext"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh",null));
View Full Code Here

        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.bat.ext", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat","ext"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh",null));
    }

    public void testGenerateFilepathWindows() throws Exception {
        NodeEntryImpl node = new NodeEntryImpl("node1");
        node.setOsFamily("windows");
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
    }
View Full Code Here

    public void testGetProviderForNode() throws Exception {
        final FileCopierService service = FileCopierService.getInstanceForFramework(getFrameworkInstance());
        {
            //default for local node should be local provider
            final NodeEntryImpl test1 = new NodeEntryImpl("test1");
            final FileCopier provider = service.getProviderForNodeAndProject(test1, PROJ_NAME);
            assertNotNull(provider);
            assertTrue(provider instanceof LocalFileCopier);
        }
        {
            //default for non-local node should be jsch-scp provider
            final NodeEntryImpl test1 = new NodeEntryImpl("testnode2");
            final FileCopier provider = service.getProviderForNodeAndProject(test1, PROJ_NAME);
            assertNotNull(provider);
            assertTrue(provider instanceof JschScpFileCopier);
        }

        //specify override attributes for node to change file copier provider

        {
            //default for local node should be local provider
            final NodeEntryImpl test1 = new NodeEntryImpl("test1");
            //set attribute
            test1.setAttributes(new HashMap<String, String>());
            test1.getAttributes().put(FileCopierService.LOCAL_NODE_SERVICE_SPECIFIER_ATTRIBUTE, "jsch-scp");

            final FileCopier provider = service.getProviderForNodeAndProject(test1, PROJ_NAME);
            assertNotNull(provider);
            assertTrue(provider instanceof JschScpFileCopier);
        }
        {
            //default for non-local node should be jsch-scp provider
            final NodeEntryImpl test1 = new NodeEntryImpl("testnode2");
            test1.setAttributes(new HashMap<String, String>());
            test1.getAttributes().put(FileCopierService.REMOTE_NODE_SERVICE_SPECIFIER_ATTRIBUTE, "local");

            final FileCopier provider = service.getProviderForNodeAndProject(test1, PROJ_NAME);

            assertNotNull(provider);
            assertTrue(provider instanceof LocalFileCopier);
View Full Code Here

        node.setOsFamily("windows");
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("C:\\\\WINDOWS\\\\TEMP\\\\\\d+-node1-blah.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
    }
    public void testGenerateFilepathTargetDir() throws Exception {
        NodeEntryImpl node = new NodeEntryImpl("node1");
        node.setOsFamily("windows");
        node.setAttribute(BaseFileCopier.FILE_COPY_DESTINATION_DIR, "c:\\my\\tmp");
        assertMatches("c:\\\\my\\\\tmp\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("c:\\\\my\\\\tmp\\\\\\d+-node1-blah.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
        node.setAttribute(BaseFileCopier.FILE_COPY_DESTINATION_DIR, "c:\\my\\tmp\\");
        assertMatches("c:\\\\my\\\\tmp\\\\\\d+-node1-blah.sh.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("c:\\\\my\\\\tmp\\\\\\d+-node1-blah.bat", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));

        node.setOsFamily("unix");
        node.setAttribute(BaseFileCopier.FILE_COPY_DESTINATION_DIR, "/my/tmp");
        assertMatches("/my/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("/my/tmp/\\d+-node1-blah.bat.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
        node.setAttribute(BaseFileCopier.FILE_COPY_DESTINATION_DIR, "/my/tmp/");
        assertMatches("/my/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("/my/tmp/\\d+-node1-blah.bat.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
    }
View Full Code Here

        node.setAttribute(BaseFileCopier.FILE_COPY_DESTINATION_DIR, "/my/tmp/");
        assertMatches("/my/tmp/\\d+-node1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("/my/tmp/\\d+-node1-blah.bat.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.bat"));
    }
    public void testGenerateFilepathBadChars() throws Exception{
        NodeEntryImpl node = new NodeEntryImpl("node name1");
        node.setOsFamily("unix");
        assertMatches("/tmp/\\d+-node_name1-blah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah.sh"));
        assertMatches("/tmp/\\d+-node_name1-blah_flah.sh", BaseFileCopier.generateRemoteFilepathForNode(node,
                "blah flah.sh"));
        assertMatches("/tmp/\\d+-node_name1-blah___flah.sh", BaseFileCopier.generateRemoteFilepathForNode(node, "blah///flah.sh"));
    }
View Full Code Here

    @Override
    public INodeSet getNodes() throws ResourceModelSourceException {
        NodeSetImpl iNodeEntries = new NodeSetImpl();
        for(int i=0;i<count;i++){
            NodeEntryImpl nodeEntry = new NodeEntryImpl();
            nodeEntry.setNodename((prefix != null ? prefix : "node") + "-" + i  + (suffix != null ? suffix : ""));
            nodeEntry.setHostname((prefix != null ? prefix : "") + "host" + (suffix != null ? suffix : ""));
            nodeEntry.setUsername((prefix != null ? prefix : "") + "user" + (suffix != null ? suffix : ""));
            nodeEntry.setAttribute("node-executor", "stub");
            nodeEntry.setAttribute("file-copier", "stub");
            if(null!=tags){
                nodeEntry.setTags(new HashSet(Arrays.asList(tags.split("\\s*,\\s*"))));
            }

            iNodeEntries.putNode(nodeEntry);
        }
        return iNodeEntries;
View Full Code Here

    }

    public void testNodeData() throws Exception {
        {
            final NodeEntryImpl nodeentry = new NodeEntryImpl("testhost", "test1");
            final Map<String, String> stringMap = DataContextUtils.nodeData(nodeentry);
            assertNotNull(stringMap);
            assertEquals("wrong size: " + stringMap, 9, stringMap.size());
            assertEquals("test1", stringMap.get("name"));
            assertEquals("testhost", stringMap.get("hostname"));
            assertEquals("", stringMap.get("os-name"));
            assertEquals("", stringMap.get("os-family"));
            assertEquals("", stringMap.get("os-arch"));
            assertEquals("", stringMap.get("os-version"));
            assertEquals("", stringMap.get("tags"));
            assertEquals("", stringMap.get("username"));
            assertEquals("", stringMap.get("description"));
        }
        {
            final NodeEntryImpl nodeentry = new NodeEntryImpl("testhost", "test1");
            nodeentry.setDescription("testdesc");
            nodeentry.setUsername("username");
            nodeentry.setOsArch("osarch");
            nodeentry.setOsFamily("osfamily");
            nodeentry.setOsName("osname");
            nodeentry.setOsVersion("osversion");
            nodeentry.setTags(new HashSet());

            final Map<String, String> stringMap = DataContextUtils.nodeData(nodeentry);
            assertNotNull(stringMap);
            assertEquals(9, stringMap.size());
            assertEquals("test1", stringMap.get("name"));
            assertEquals("testhost", stringMap.get("hostname"));
            assertEquals("osname", stringMap.get("os-name"));
            assertEquals("osfamily", stringMap.get("os-family"));
            assertEquals("osarch", stringMap.get("os-arch"));
            assertEquals("osversion", stringMap.get("os-version"));
            assertEquals("", stringMap.get("tags"));
            assertEquals("username", stringMap.get("username"));
            assertEquals("testdesc", stringMap.get("description"));
        }
        {
            final NodeEntryImpl nodeentry = new NodeEntryImpl("testhost", "test1");
            final HashSet tags = new HashSet();
            tags.add("tag1");
            nodeentry.setTags(tags);

            final Map<String, String> stringMap = DataContextUtils.nodeData(nodeentry);
            assertNotNull(stringMap);
            assertEquals(9, stringMap.size());
            assertEquals("test1", stringMap.get("name"));
            assertEquals("testhost", stringMap.get("hostname"));
            assertEquals("tag1", stringMap.get("tags"));
        }
        {
            final NodeEntryImpl nodeentry = new NodeEntryImpl("testhost", "test1");
            final TreeSet tags = new TreeSet();
            tags.add("tag1");
            tags.add("tag2");
            tags.add("xyz");
            nodeentry.setTags(tags);

            final Map<String, String> stringMap = DataContextUtils.nodeData(nodeentry);
            assertNotNull(stringMap);
            assertEquals(9, stringMap.size());
            assertEquals("test1", stringMap.get("name"));
View Full Code Here

TOP

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

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.