static void ensureIsCloudProviderSetup(SimulatorProperties properties, String action) { if (!isCloudProvider(properties)) { throw new CommandLineExitException(format("Cannot execute '%s' in local or static setup", action)); } }
public static boolean isEC2(SimulatorProperties properties) { return isEC2(properties.getCloudProvider()); }
public static boolean isGCE(SimulatorProperties properties) { return isGCE(properties.getCloudProvider()); }
copyResourceFile(workDir, "test.properties", "testSuite"); if (isLocal(cloudProvider)) { return; if (isEC2(cloudProvider)) { appendText(format( "%n# These files contain your AWS access key ID and secret access key (change if needed)%n#%s=%s%n#%s=%s%n", "%n# Machine specification used for AWS (change if needed)%n#MACHINE_SPEC=%s%n", simulatorProperties.get("MACHINE_SPEC")), simulatorPropertiesFile); } else if (isGCE(cloudProvider)) { String currentUser = execute("whoami").trim(); if (isStatic(cloudProvider)) { copyResourceFile(workDir, "prepare", "prepareScriptStatic"); } else {
static void ensureIsRemoteSetup(SimulatorProperties properties, String action) { if (isLocal(properties)) { throw new CommandLineExitException(format("Cannot execute '%s' in local setup", action)); } }
private StartAgentTask(Logger logger, Bash bash, SimulatorProperties properties, AgentData agentData, int agentPort) { this.logger = logger; this.bash = bash; this.runMode = CloudProviderUtils.runMode(properties); this.ip = agentData.getPublicAddress(); this.mandatoryParameters = format("--addressIndex %d --publicAddress %s --port %s", agentData.getAddressIndex(), ip, agentPort); this.optionalParameters = format(" --threadPoolSize %d --workerLastSeenTimeoutSeconds %d", properties.getAgentThreadPoolSize(), properties.getWorkerLastSeenTimeoutSeconds()); if (isEC2(properties)) { this.ec2Parameters = format(" --cloudProvider %s --cloudIdentity %s --cloudCredential %s", properties.getCloudProvider(), properties.getCloudIdentity(), properties.getCloudCredential()); } else { this.ec2Parameters = ""; } }
private StopAgentTask(Logger logger, Bash bash, SimulatorProperties properties, AgentData agentData, String startHarakiriMonitorCommand) { this.logger = logger; this.bash = bash; this.runMode = CloudProviderUtils.runMode(properties); this.ip = agentData.getPublicAddress(); this.startHarakiriMonitorCommand = startHarakiriMonitorCommand; }
public static boolean isStatic(SimulatorProperties properties) { return isStatic(properties.getCloudProvider()); }
public static boolean isLocal(SimulatorProperties properties) { return isLocal(properties.getCloudProvider()); }
public void run() { if (runMode(simulatorProperties) == RunMode.Embedded) { return; } String ipString = ""; if (runMode(simulatorProperties) == RunMode.Remote) { ipString = join(publicIps, ","); } String vendor = simulatorProperties.get("VENDOR"); String installFile = getConfigurationFile("install-" + vendor + ".sh").getPath(); for (String versionSpec : versionSpecs) { LOGGER.info("Installing '" + vendor + "' version '" + versionSpec + "' on Agents using " + installFile); new BashCommand(installFile) .addParams(sessionId, versionSpec, ipString) .addEnvironment(simulatorProperties.asMap()) .execute(); LOGGER.info("Successfully installed '" + vendor + "'"); } } }
ComputeService build() { ensurePublicPrivateKeyExist(PUBLIC_KEY, PRIVATE_KEY); if (isStatic(properties)) { return null; } String cloudProvider = properties.getCloudProvider(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(format("Using %s: %s", PROPERTY_CLOUD_PROVIDER, cloudProvider)); } ContextBuilder contextBuilder = newContextBuilder(cloudProvider); return contextBuilder.overrides(newOverrideProperties(properties)) .credentials(properties.getCloudIdentity(), properties.getCloudCredential()) .modules(getModules()) .buildView(ComputeServiceContext.class) .getComputeService(); }
public void run() { if (isLocal(simulatorProperties)) { cleanLocal(); } else { cleanRemote(); } }
TemplateBuilder(ComputeService compute, SimulatorProperties simulatorProperties) { this.compute = compute; this.simulatorProperties = simulatorProperties; this.isEC2 = isEC2(simulatorProperties); populatePortRangeMap(); }
public static void checkInstallation(Bash bash, SimulatorProperties properties, ComponentRegistry registry) { if (runMode(properties) != RunMode.Remote) { return; } ThreadSpawner spawner = new ThreadSpawner("checkInstallation", true); for (AgentData agentData : registry.getAgents()) { spawner.spawn(new CheckAgentInstallationTask(agentData, bash)); } spawner.awaitCompletion(); }
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); }
public void run() { if (isLocal(simulatorProperties)) { downloadLocal(); } else { downloadRemote(); } }
public static boolean isHarakiriMonitorEnabled(SimulatorProperties properties) { return (isEC2(properties) && "true".equalsIgnoreCase(properties.get("HARAKIRI_MONITOR_ENABLED"))); }
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 start() { if (!isEC2(cloudProvider)) { LOGGER.info("No Harakiri monitor is active: only on AWS-EC2 unused machines will be terminated."); return; } LOGGER.info(format("Harakiri monitor is active and will wait %d seconds to kill this instance", waitSeconds)); sleepSeconds(waitSeconds); LOGGER.info("Trying to commit Harakiri once!"); try { LOGGER.info("Harakiri command: " + command); execute(command); } catch (Exception e) { throw new CommandLineExitException("Failed to execute Harakiri", e); } }