use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class WhirrCommandSupport method getClusterSpec.
/**
* Returns the {@link ClusterSpec}
*
* @return
* @throws Exception
*/
protected ClusterSpec getClusterSpec() throws Exception {
ClusterSpec clusterSpec = null;
if (pid != null || fileName != null) {
PropertiesConfiguration properties = getConfiguration(pid, fileName);
clusterSpec = new ClusterSpec(properties);
} else {
clusterSpec = new ClusterSpec();
}
if (name != null) {
clusterSpec.setContextName(name);
}
if (provider != null) {
clusterSpec.setProvider(provider);
}
if (endpoint != null) {
clusterSpec.setEndpoint(endpoint);
}
if (templates != null) {
clusterSpec.setInstanceTemplates(getTemplate(templates, imageId, hardwareId));
}
if (privateKey != null) {
clusterSpec.setPrivateKey(privateKey);
}
if (clusterName != null) {
clusterSpec.setClusterName(clusterName);
}
return clusterSpec;
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class CassandraClusterActionHandler method beforeBootstrap.
@Override
protected void beforeBootstrap(ClusterActionEvent event) throws IOException {
ClusterSpec clusterSpec = event.getClusterSpec();
Configuration conf = clusterSpec.getConfiguration();
addStatement(event, call("retry_helpers"));
addStatement(event, call("install_tarball"));
addStatement(event, call("install_service"));
addStatement(event, call(getInstallFunction(conf, "java", "install_openjdk")));
Configuration config = clusterSpec.getConfiguration();
String tarball = prepareRemoteFileUrl(event, config.getString(BIN_TARBALL, null));
String major = config.getString(MAJOR_VERSION, null);
if (tarball != null && major != null) {
addStatement(event, call("install_cassandra", major, tarball));
} else {
addStatement(event, call("install_cassandra"));
}
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class BaseServiceDryRunTest method testBootstrapAndConfigure.
/**
* Tests that a simple cluster is correctly loaded and executed.
*/
@Test
public void testBootstrapAndConfigure() throws Exception {
ClusterSpec cookbookWithDefaultRecipe = newClusterSpecForProperties(ImmutableMap.of("whirr.instance-templates", "1 " + Joiner.on("+").join(getInstanceRoles())));
DryRun dryRun = launchWithClusterSpec(cookbookWithDefaultRecipe);
assertScriptPredicateOnPhase(dryRun, "bootstrap", bootstrapPredicate());
assertScriptPredicateOnPhase(dryRun, "configure", configurePredicate());
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class UtilsTest method testPrintAccess.
@Test
public void testPrintAccess() {
final Instance instance = mock(Instance.class);
when(instance.getPublicIp()).thenReturn("test-public-ip");
when(instance.getRoles()).thenReturn(ImmutableSet.of("test-role"));
Cluster cluster = mock(Cluster.class);
when(cluster.getInstances()).thenReturn(ImmutableSet.<Cluster.Instance>of(instance));
ClusterSpec spec = mock(ClusterSpec.class);
when(spec.getClusterUser()).thenReturn("test-identity");
when(spec.getPrivateKeyFile()).thenReturn(new File("/test/key/path"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
Utils.printSSHConnectionDetails(ps, spec, cluster, 20);
assertEquals("The ssh command did not match", EXPECTED_SSH_COMMAND, new String(baos.toByteArray()));
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class DestroyInstance method doExecute.
@Override
protected Object doExecute() throws Exception {
DestroyInstanceCommand command = new DestroyInstanceCommand(clusterControllerFactory);
ClusterSpec clusterSpec = getClusterSpec();
if (clusterSpec != null) {
command.run(System.in, System.out, System.err, clusterSpec, instance);
}
return null;
}
Aggregations