Search in sources :

Example 11 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class BaseServiceDryRunTest method newClusterSpecForProperties.

protected ClusterSpec newClusterSpecForProperties(Map<String, String> properties) throws ConfigurationException, JSchException, IOException {
    Configuration config = new PropertiesConfiguration();
    config.setProperty("whirr.provider", "stub");
    config.setProperty("whirr.cluster-name", "stub-test");
    config.setProperty("whirr.state-store", "memory");
    for (Entry<String, String> entry : properties.entrySet()) config.setProperty(entry.getKey(), entry.getValue());
    // we don't want to create files
    return new ClusterSpec(config) {

        @Override
        protected void checkAndSetKeyPair() {
            setPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
            setPublicKey("ssh-rsa AAAAB3NzaC1yc2EA");
        }
    };
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ClusterSpec(org.apache.whirr.ClusterSpec) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 12 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class TemplateUtilsTest method testProcessTemplate.

@Test
public void testProcessTemplate() throws Exception {
    Credentials credentials = new Credentials("dummy", "dummy");
    Cluster.Instance instance = new Cluster.Instance(credentials, Sets.newHashSet("foo"), "127.0.0.1", "127.0.0.1", "id-0", null);
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(new PropertiesConfiguration("whirr-core-test.properties"));
    Cluster cluster = new Cluster(Sets.newHashSet(instance));
    VelocityEngine ve = TemplateUtils.newVelocityEngine();
    String result = TemplateUtils.processTemplate(ve, "template-test.txt.vm", clusterSpec, cluster);
    Assert.assertEquals("instance ip: 127.0.0.1", result);
}
Also used : VelocityEngine(org.apache.velocity.app.VelocityEngine) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Credentials(org.jclouds.domain.Credentials) Test(org.junit.Test)

Example 13 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class DestroyCluster method doExecute.

@Override
protected Object doExecute() throws Exception {
    validateInput();
    DestroyClusterCommand command = new DestroyClusterCommand(clusterControllerFactory);
    ClusterSpec clusterSpec = getClusterSpec();
    if (clusterSpec != null) {
        command.run(System.in, System.out, System.err, clusterSpec);
    }
    return null;
}
Also used : DestroyClusterCommand(org.apache.whirr.cli.command.DestroyClusterCommand) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 14 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class LaunchCluster method doExecute.

@Override
protected Object doExecute() throws Exception {
    validateInput();
    LaunchClusterCommand command = new LaunchClusterCommand(clusterControllerFactory);
    ClusterSpec clusterSpec = getClusterSpec();
    if (clusterSpec != null) {
        command.run(System.in, System.out, System.err, clusterSpec);
    }
    return null;
}
Also used : ClusterSpec(org.apache.whirr.ClusterSpec) LaunchClusterCommand(org.apache.whirr.cli.command.LaunchClusterCommand)

Example 15 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class GangliaMetadClusterActionHandler method afterConfigure.

@Override
protected void afterConfigure(ClusterActionEvent event) {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
    String hosts = Joiner.on(',').join(getHosts(cluster.getInstancesMatching(role(GANGLIA_METAD_ROLE))));
    LOG.info("Meta host: {}. You should be able to connect on http://{}/ganglia", hosts, hosts);
}
Also used : Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Aggregations

ClusterSpec (org.apache.whirr.ClusterSpec)98 Configuration (org.apache.commons.configuration.Configuration)39 Cluster (org.apache.whirr.Cluster)35 Test (org.junit.Test)34 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)16 Instance (org.apache.whirr.Cluster.Instance)14 ClusterController (org.apache.whirr.ClusterController)10 InetAddress (java.net.InetAddress)9 DryRun (org.apache.whirr.service.DryRunModule.DryRun)9 OptionSet (joptsimple.OptionSet)8 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)8 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)8 IOException (java.io.IOException)7 ComputeService (org.jclouds.compute.ComputeService)7 File (java.io.File)6 ClusterControllerFactory (org.apache.whirr.ClusterControllerFactory)6 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)6 Set (java.util.Set)5 Stack (java.util.Stack)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5