public static ComponentRegistry loadComponentRegister(File agentsFile) { return loadComponentRegister(agentsFile, false); }
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); } }
ProvisionerCli(String[] args) { this.options = initOptionsWithHelp(parser, args); SimulatorProperties properties = loadSimulatorProperties(); ComputeService computeService = isCloudProvider(properties) ? new ComputeServiceBuilder(properties).build() : null; Bash bash = new Bash(properties); this.tags = loadTags(options, tagsSpec); this.provisioner = new Provisioner(properties, computeService, bash); }
CoordinatorCli(String[] args) { this.options = initOptionsWithHelp(parser, args); this.simulatorProperties = loadSimulatorProperties(); this.componentRegistry = newComponentRegistry(simulatorProperties); if (options.has(downloadSpec) || options.has(cleanSpec)) { this.downloader = new CoordinatorDownloader(componentRegistry, simulatorProperties); } else { this.coordinatorParameters = loadCoordinatorParameters(); this.coordinator = new Coordinator(componentRegistry, coordinatorParameters); this.testSuite = loadTestSuite(); if (testSuite == null) { int coordinatorPort = simulatorProperties.getCoordinatorPort(); if (coordinatorPort == 0) { throw new CommandLineExitException("Can't run without a testSuite, and not have a coordinator port enabled." + "Please add COORDINATOR_PORT=5000 to your simulator.properties or run with a testsuite."); } } else { this.workerParametersMap = loadWorkerParameters(); this.deploymentPlan = newDeploymentPlan(); this.runMonolith = new CoordinatorRunMonolith(coordinator, coordinatorParameters); } } }
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()); }
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!"); }