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); } } }