public static ComponentRegistry loadComponentRegister(File agentsFile) { return loadComponentRegister(agentsFile, false); }
public Provisioner(SimulatorProperties properties, ComputeService computeService, Bash bash, int machineWarmupSeconds) { this.properties = properties; this.computeService = computeService; this.bash = bash; this.machineWarmupSeconds = machineWarmupSeconds; this.componentRegistry = loadComponentRegister(agentsFile, false); this.initScriptFile = getInitScriptFile(simulatorPath); }
void createSshCopyIdScript(SimulatorProperties simulatorProperties) { ComponentRegistry componentRegistry = loadComponentRegister(agentFile, true); String userName = simulatorProperties.getUser(); ensureExistingFile(SSH_COPY_ID_FILE); writeText("#!/bin/bash" + NEW_LINE + NEW_LINE, SSH_COPY_ID_FILE); for (AgentData agentData : componentRegistry.getAgents()) { String publicAddress = agentData.getPublicAddress(); appendText(format("ssh-copy-id -i ~/.ssh/id_rsa.pub %s@%s%n", userName, publicAddress), SSH_COPY_ID_FILE); } execute(format("chmod u+x %s", SSH_COPY_ID_FILE.getAbsoluteFile())); echo("Please execute './%s' to copy your public RSA key to all remote machines.", SSH_COPY_ID_FILE.getName()); }
static AwsProvisioner init(String[] args) { AwsProvisioner.logHeader(); AwsProvisionerCli cli = new AwsProvisionerCli(); initOptionsWithHelp(cli.parser, args); SimulatorProperties properties = loadSimulatorProperties(); ComponentRegistry componentRegistry = loadComponentRegister(new File(getUserDir(), AgentsFile.NAME), false); try { String awsCredentialsPath = properties.get("AWS_CREDENTIALS", "awscredentials.properties"); File credentialsFile = new File(awsCredentialsPath); AWSCredentials credentials = new PropertiesCredentials(credentialsFile); AmazonEC2 ec2 = new AmazonEC2Client(credentials); AmazonElasticLoadBalancingClient elb = new AmazonElasticLoadBalancingClient(credentials); return new AwsProvisioner(ec2, elb, componentRegistry, properties); } catch (Exception e) { throw new CommandLineExitException("Credentials file could not be loaded", e); } }
private ComponentRegistry newComponentRegistry(SimulatorProperties simulatorProperties) { ComponentRegistry componentRegistry; if (isLocal(simulatorProperties)) { componentRegistry = new ComponentRegistry(); componentRegistry.addAgent("localhost", "localhost"); } else { componentRegistry = loadComponentRegister(getAgentsFile()); } if (options.has(dedicatedMemberMachinesSpec)) { componentRegistry.assignDedicatedMemberMachines(options.valueOf(dedicatedMemberMachinesSpec)); } return componentRegistry; }
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!"); }