Examples of SSHLauncher


Examples of hudson.plugins.sshslaves.SSHLauncher

    public DockerComputerLauncher(DockerTemplate template, ContainerInspectResponse containerInspectResponse) {
        super(makeLauncher(template, containerInspectResponse));
    }

    private static ComputerLauncher makeLauncher(DockerTemplate template, ContainerInspectResponse containerInspectResponse) {
        SSHLauncher sshLauncher = getSSHLauncher(containerInspectResponse, template);
        return new RetryingComputerLauncher(sshLauncher);
    }
View Full Code Here

Examples of hudson.plugins.sshslaves.SSHLauncher

            LOGGER.log(Level.INFO, "Creating slave SSH launcher for " + host + ":" + port);

            StandardUsernameCredentials credentials = SSHLauncher.lookupSystemCredentials(template.credentialsId);

            return new SSHLauncher(host, port, credentials,  template.jvmOptions , template.javaPath, template.prefixStartSlaveCmd, template.suffixStartSlaveCmd, 60);

        } catch(NullPointerException ex) {
            throw new RuntimeException("No mapped port 22 in host for SSL. Config=" + detail);
        } catch (MalformedURLException e) {
            throw new RuntimeException("Malformed URL for host " + template);
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

                    }
                }
            }
        } else if (node.getType().equals("SSH")) {
            // this code is used if DAS and instance are running on different machine
            SSHLauncher sshL = getSSHL(habitat);
            sshL.init(node, logger);
            SFTPClient sftpClient = sshL.getSFTPClient();

            boolean noFileFound = true;

            String loggingDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

        // method is used from logviewer back end code logfilter.
        // for Instance it's going through this loop. This will use ssh utility to get file from instance machine(remote machine) and
        // store in domains/domain1/logs/<instance name> which is used to get LogFile object.
        // Right now user needs to go through this URL to setup and configure ssh http://wikis.sun.com/display/GlassFish/3.1SSHSetup
        SSHLauncher sshL = getSSHL(habitat);
        String sNode = targetServer.getNodeRef();
        Nodes nodes = domain.getNodes();
        Node node = nodes.getNode(sNode);

        if (node.getType().equals("SSH")) {

            sshL.init(node, logger);

            SFTPClient sftpClient = sshL.getSFTPClient();

            File logFileDirectoryOnServer = makingDirectory(domainRoot + File.separator + "logs"
                    + File.separator + instanceName);

            boolean noFileFound = true;
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

        // method is used from collect-log-files command
        // for Instance it's going through this loop. This will use ssh utility to get file from instance machine(remote machine) and
        // store in  tempDirectoryOnServer which is used to create zip file.
        // Right now user needs to go through this URL to setup and configure ssh http://wikis.sun.com/display/GlassFish/3.1SSHSetup
        SSHLauncher sshL = getSSHL(habitat);
        String sNode = targetServer.getNodeRef();
        Nodes nodes = domain.getNodes();
        Node node = nodes.getNode(sNode);

        if (node.getType().equals("SSH")) {
            sshL.init(node, logger);

            Vector allInstanceLogFileName = getInstanceLogFileNames(habitat, targetServer, domain, logger, instanceName, instanceLogFileDirectory);

            boolean noFileFound = true;
            String sourceDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);
            SFTPClient sftpClient = sshL.getSFTPClient();

            try {
                Vector instanceLogFileNames = sftpClient.ls(sourceDir);

                for (int i = 0; i < instanceLogFileNames.size(); i++) {
                    SFTPv3DirectoryEntry file = (SFTPv3DirectoryEntry) instanceLogFileNames.get(i);
                    String fileName = file.filename;
                    // code to remove . and .. file which is return from sftpclient ls method
                    if (!file.attributes.isDirectory() && !fileName.equals(".") && !fileName.equals("..")
                            && fileName.contains(".log") && !fileName.contains(".log.")) {
                        noFileFound = false;
                        break;
                    }
                }
            } catch (Exception e) {
                // if directory doesn't present or missing on remote machine. It happens due to bug 16451
                noFileFound = true;
            }

            if (noFileFound) {
                // this loop is used when user has changed value for server.log but not restarted the server.
                sourceDir = getLoggingDirectoryForNodeWhenNoFilesFound(instanceLogFileDirectory, node, sNode, instanceName);
            }

            String[] remoteFileNames = new String[allInstanceLogFileName.size()];
            for (int i = 0; i < allInstanceLogFileName.size(); i++) {
                remoteFileNames[i] = sourceDir + File.separator + allInstanceLogFileName.get(i);
            }

            sftpClient.close();

            SCPClient scpClient = sshL.getSCPClient();
            scpClient.get(remoteFileNames, tempDirectoryOnServer);
        } else if (node.getType().equals("DCOM")) {

            Vector instanceLogFileNames = getInstanceLogFileNames(habitat, targetServer, domain, logger, instanceName, instanceLogFileDirectory);
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

                    logger.warning(Strings.get("GetPasswordFailure", f.getName()));
                    continue;
                }

                if (expandedPassword != null) {
                    SSHLauncher sshL = new SSHLauncher();
                    if (host != null) {
                        sshpassword = expandedPassword;
                        sshL.init(getRemoteUser(), host, getRemotePort(), sshpassword, null, null, logger);
                        connStatus = sshL.checkPasswordAuth();
                        if (!connStatus) {
                            logger.warning(Strings.get("PasswordAuthFailure", f.getName()));
                        }
                    }
                    else {
                        sshkeypassphrase = expandedPassword;
                        if (verifyConn) {
                            sshL.init(getRemoteUser(), hosts[0], getRemotePort(), sshpassword, getSshKeyFile(), sshkeypassphrase, logger);
                            connStatus = sshL.checkConnection();
                            if (!connStatus) {
                                logger.warning(Strings.get("PasswordAuthFailure", f.getName()));
                            }
                        }
                    }
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

    private WindowsRemoteFile wrf;

    public void execute(AdminCommandContext context) {
        report = context.getActionReport();
        logger = context.getLogger();
        SSHLauncher launcher;
        int dasPort;
        String dasHost;

        if (env.isDas()) {
            if (kill) {
                errorMessage = killInstance(context);
            } else {
                errorMessage = callInstance();
            }
        }  else {
            errorMessage = Strings.get("stop.instance.notDas",
                    env.getRuntimeType().toString());
        }

        if(errorMessage == null && !kill) {
            errorMessage = pollForDeath();
        }

        if (errorMessage != null) {
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(errorMessage);
            return;
        }

        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        report.setMessage(Strings.get("stop.instance.success",
                    instanceName));

        if (kill) {
            // If we killed then stop-local-instance already waited for death
            return;
        }

        // we think the instance is down but it might not be completely down so do further checking
        // get the node name and then the node
        // if localhost check if files exists
        // else if SSH check if file exists  on remote system
        // else can't check anything else.
        String nodeName = instance.getNodeRef();
        Node node = nodes.getNode(nodeName);
        String nodeHost = node.getNodeHost();
        InstanceDirUtils insDU = new InstanceDirUtils(node, serverContext);
        // this should be replaced with method from Node config bean.
        dasPort = helper.getAdminPort(SystemPropertyConstants.DAS_SERVER_NAME);
        dasHost = System.getProperty(SystemPropertyConstants.HOST_NAME_PROPERTY);
        if (node.isLocal()){
            try {
                pidFile = new File (insDU.getLocalInstanceDir(instance.getName()) , "config/pid");
            } catch (java.io.IOException eio){
                // could not get the file name so can't see if it still exists.  Need to exit
                return;
            }
            if (pidFile.exists()){
                    //server still not down completely, do we poll?
                errorMessage = pollForRealDeath("local");
            }

        } else if (node.getType().equals("SSH")) {
            try {
                pidFile = new File (insDU.getLocalInstanceDir(instance.getName()) , "config/pid");
            } catch (java.io.IOException eio){
                // could not get the file name so can't see if it still exists.  Need to exit
                return;
            }
            //use SFTPClient to see if file exists.
            launcher = habitat.getService(SSHLauncher.class);
            launcher.init(node, logger);
            try {
                ftpClient = launcher.getSFTPClient();
                if (ftpClient.exists(pidFile.toString())){
                    // server still not down, do we poll?
                    errorMessage = pollForRealDeath("SSH");
                }
            } catch (IOException ex) {
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

    private WindowsRemoteFile wrf;

    public void execute(AdminCommandContext context) {
        report = context.getActionReport();
        logger = context.getLogger();
        SSHLauncher launcher;
        int dasPort;
        String dasHost;

        if (env.isDas()) {
            if (kill) {
                errorMessage = killInstance(context);
            } else {
                errorMessage = callInstance();
            }
        }  else {
            errorMessage = Strings.get("stop.instance.notDas",
                    env.getRuntimeType().toString());
        }

        if(errorMessage == null && !kill) {
            errorMessage = pollForDeath();
        }

        if (errorMessage != null) {
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(errorMessage);
            return;
        }

        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        report.setMessage(Strings.get("stop.instance.success",
                    instanceName));

        if (kill) {
            // If we killed then stop-local-instance already waited for death
            return;
        }

        // we think the instance is down but it might not be completely down so do further checking
        // get the node name and then the node
        // if localhost check if files exists
        // else if SSH check if file exists  on remote system
        // else can't check anything else.
        String nodeName = instance.getNodeRef();
        Node node = nodes.getNode(nodeName);
        String nodeHost = node.getNodeHost();
        InstanceDirUtils insDU = new InstanceDirUtils(node, serverContext);
        // this should be replaced with method from Node config bean.
        dasPort = helper.getAdminPort(SystemPropertyConstants.DAS_SERVER_NAME);
        dasHost = System.getProperty(SystemPropertyConstants.HOST_NAME_PROPERTY);
        if (node.isLocal()){
            try {
                pidFile = new File (insDU.getLocalInstanceDir(instance.getName()) , "config/pid");
            } catch (java.io.IOException eio){
                // could not get the file name so can't see if it still exists.  Need to exit
                return;
            }
            if (pidFile.exists()){
                    //server still not down completely, do we poll?
                errorMessage = pollForRealDeath("local");
            }

        } else if (node.getType().equals("SSH")) {
            // create the absolute path to the pid file on the remote host.
            String nodeDir = node.getNodeDirAbsolute();
            File nodeDirFile = (nodeDir != null ?
                 new File(nodeDir) :
                  insDU.defaultLocalNodeDirFile());
            String nodeConfigDir = node.getName()+File.separator + instance.getName()+File.separator+"config";
            File insDirFile= new File(nodeDirFile, nodeConfigDir);
            //use SFTPClient to see if file exists.
            launcher = habitat.getComponent(SSHLauncher.class);
            launcher.init(node, logger);
            try {
                // should look for the parent to make sure we have the correct path first
                ftpClient = launcher.getSFTPClient();
                if (ftpClient.exists(insDirFile.toString())){
                    // check if file is there
                    pidFile = new File (insDirFile , "pid");
                    if (ftpClient.exists(pidFile.toString())){
                        // server still not down, do we poll?
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

     */
    @Override
    protected int executeCommand()
            throws CommandException {

        SSHLauncher sshL = habitat.getService(SSHLauncher.class);

        String previousPassword = null;
        boolean status = false;
        for (String node : hosts) {
            sshL.init(getRemoteUser(), node, getRemotePort(), sshpassword, sshkeyfile, sshkeypassphrase, logger);
            if (generatekey || promptPass) {
                //prompt for password iff required
                if (sshkeyfile != null || SSHUtil.getExistingKeyFile() != null) {
                    if (sshL.checkConnection()) {
                        logger.info(Strings.get("SSHAlreadySetup", getRemoteUser(), node));
                        continue;
                    }
                }
                if (previousPassword != null) {
                    status = sshL.checkPasswordAuth();
                }
                if (!status) {
                    sshpassword = getSSHPassword(node);
                    previousPassword = sshpassword;
                }
            }

            try {
                sshL.setupKey(node, sshpublickeyfile, generatekey, sshpassword);
            }
            catch (IOException ce) {
                //logger.fine("SSH key setup failed: " + ce.getMessage());
                throw new CommandException(Strings.get("KeySetupFailed", ce.getMessage()));
            }
            catch (Exception e) {
                //handle KeyStoreException
                if (logger.isLoggable(Level.FINER)) {
                    logger.log(Level.FINER, "Keystore error: ", e);
                }
            }

            if (!sshL.checkConnection()) {
                throw new CommandException(Strings.get("ConnFailed"));
            }
        }
        return SUCCESS;
    }
View Full Code Here

Examples of org.glassfish.cluster.ssh.launcher.SSHLauncher

                    logger.warning(Strings.get("GetPasswordFailure", f.getName()));
                    continue;
                }

                if (expandedPassword != null) {
                    SSHLauncher sshL = new SSHLauncher();
                    if (host != null) {
                        sshpassword = expandedPassword;
                        sshL.init(getRemoteUser(), host, getRemotePort(), sshpassword, null, null, logger);
                        connStatus = sshL.checkPasswordAuth();
                        if (!connStatus) {
                            logger.warning(Strings.get("PasswordAuthFailure", f.getName()));
                        }
                    }
                    else {
                        sshkeypassphrase = expandedPassword;
                        if (verifyConn) {
                            sshL.init(getRemoteUser(), hosts[0], getRemotePort(), sshpassword, getSshKeyFile(), sshkeypassphrase, logger);
                            connStatus = sshL.checkConnection();
                            if (!connStatus) {
                                logger.warning(Strings.get("PasswordAuthFailure", f.getName()));
                            }
                        }
                    }
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.