public String ssh(String ip, String command) { return ssh(ip, command, false, false); }
public String sshTTY(String ip, String command) { return ssh(ip, command, false, true); }
public void sshQuiet(String ip, String command) { ssh(ip, command + " || true"); }
private void runRemote() { logger.info(format("Stopping Agent %s", ip)); bash.ssh(ip, format("hazelcast-simulator-%s/bin/.kill-from-pid-file agent.pid", SIMULATOR_VERSION)); if (startHarakiriMonitorCommand != null) { logger.info(format("Starting HarakiriMonitor on %s", ip)); bash.ssh(ip, startHarakiriMonitorCommand); } } }
private void runRemote() { logger.info(format("Killing Java processes on %s", ip)); bash.killAllJavaProcesses(ip); logger.info(format("Starting Agent on %s", ip)); bash.ssh(ip, format("nohup hazelcast-simulator-%s/bin/agent %s%s%s > agent.out 2> agent.err < /dev/null &", SIMULATOR_VERSION, mandatoryParameters, optionalParameters, ec2Parameters)); bash.ssh(ip, format("hazelcast-simulator-%s/bin/.await-file-exists agent.pid", SIMULATOR_VERSION)); } }
@Override public void run() { if (!"outofthebox".equals(properties.getJdkFlavor())) { echo(INDENTATION + ip + " JAVA INSTALLATION STARTED..."); uploadJava(ip); echo(INDENTATION + ip + " JAVA INSTALLED"); } echo(INDENTATION + ip + " SIMULATOR INSTALLATION STARTED..."); uploadJARs(ip); echo(INDENTATION + ip + " SIMULATOR INSTALLED"); if (startHarakiriMonitorCommand != null) { bash.ssh(ip, startHarakiriMonitorCommand); echo(INDENTATION + ip + " HARAKIRI MONITOR STARTED"); } } }
@Override public void run() { LOGGER.info(format("Cleaning %s", agentData.getPublicAddress())); bash.ssh(agentData.getPublicAddress(), cleanCommand); } });
@Override public void run() { String ip = agentData.getPublicAddress(); String result; try { result = bash.ssh(ip, format("[[ -f hazelcast-simulator-%s/bin/agent ]] && echo SIM-OK || echo SIM-NOK", SIMULATOR_VERSION), true, false).trim(); } catch (CommandLineExitException e) { throw new CommandLineExitException(format( "Could not connect to %s. Please check your agents.txt file for invalid IP addresses.%n%s", ip, e.getCause().getMessage())); } if (result.endsWith("SIM-NOK")) { throw new CommandLineExitException(format( "Simulator is not installed correctly on %s. Please run provisioner --install to fix this.", ip)); } } }
private void uploadJava(String ip) { if ("outofthebox".equals(properties.getJdkFlavor())) { return; } bash.scpToRemote(ip, getJavaSupportScript(), "jdk-support.sh"); bash.scpToRemote(ip, getJavaInstallScript(), "install-java.sh"); bash.ssh(ip, "bash install-java.sh"); }
void sshConnectionCheck(SimulatorProperties simulatorProperties, Bash bash) { if (isLocal(simulatorProperties)) { throw new CommandLineExitException("SSH is not supported for local setups."); } ComponentRegistry componentRegistry = loadComponentRegister(agentFile, true); String userName = simulatorProperties.getUser(); for (AgentData agentData : componentRegistry.getAgents()) { String publicAddress = agentData.getPublicAddress(); echo("Connecting to %s@%s...", userName, publicAddress); bash.ssh(publicAddress, "echo ok 2>&1"); } echo("Connected successfully to all remote machines!"); }