/** ssh client is initialized through this call. */ protected ExecResponse doCall() { try { ssh.put(initFile, init.render(OsFamily.UNIX)); } catch (SshException e) { // If there's a problem with the sftp configuration, we can try via ssh exec if (logger.isTraceEnabled()) logger.warn( e, "<< (%s) problem using sftp [%s], attempting via sshexec", ssh.toString(), e.getMessage()); else logger.warn( "<< (%s) problem using sftp [%s], attempting via sshexec", ssh.toString(), e.getMessage()); ssh.disconnect(); ssh.connect(); ssh.exec("rm " + initFile); ssh.exec( Statements.appendFile( initFile, Splitter.on('\n').split(init.render(OsFamily.UNIX)), AppendFile.MARKER + "_" + init.getInstanceName()) .render(OsFamily.UNIX)); } ssh.exec("chmod 755 " + initFile); setupLinkToInitFile(); runAction("init"); init.getInitStatement() .accept( new AdminAccessVisitor() { @Override public void visit(AdminAccess input) { refreshSshIfNewAdminCredentialsConfigured(input); } }); return runAction("start"); }
private static Statement asFileStatement(String path, Configuration configuration) { return Statements.appendFile(path, asYamlLines(configuration.subset(ES_PREFIX))); }