Author: adriancole
Date: Fri Aug 17 17:07:07 2012
New Revision: 1374365
URL: http://svn.apache.org/viewvc?rev=1374365&view=rev
Log:
WHIRR-630: add property endpoint
Modified:
whirr/trunk/CHANGES.txt
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java
whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java
whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
whirr/trunk/src/site/xdoc/configuration-guide.xml
Modified: whirr/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Fri Aug 17 17:07:07 2012
@@ -113,6 +113,8 @@ Trunk (unreleased changes)
WHIRR-528. Add a retry loop around apt-get and yum commands to overcome
transient errors (Andrei Savu via adriancole)
+ WHIRR-630. Add endpoint and blobstore-endpoint configuration for private
clouds (adriancole)
+
BUG FIXES
WHIRR-612. CDH4 can be installed on Ubuntu now as well as CentOS. (abayer)
Modified:
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
---
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
(original)
+++
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
Fri Aug 17 17:07:07 2012
@@ -75,6 +75,8 @@ public class LaunchClusterCommandTest ex
"--cluster-name", "test-cluster",
"--instance-templates", "1 role1+role2,2 role3",
"--provider", "rackspace",
+ "--endpoint", "http://endpoint",
+ "--blobstore-endpoint", "http://blobstore-endpoint",
"--identity", "myusername", "--credential", "mypassword",
"--private-key-file", keys.get("private").getAbsolutePath(),
"--version", "version-string"
@@ -92,8 +94,10 @@ public class LaunchClusterCommandTest ex
));
expectedClusterSpec.setServiceName("test-service");
expectedClusterSpec.setProvider("rackspace");
+ expectedClusterSpec.setEndpoint("http://endpoint");
expectedClusterSpec.setIdentity("myusername");
expectedClusterSpec.setCredential("mypassword");
+ expectedClusterSpec.setBlobStoreEndpoint("http://blobstore-endpoint");
expectedClusterSpec.setClusterName("test-cluster");
expectedClusterSpec.setPrivateKey(keys.get("private"));
expectedClusterSpec.setPublicKey(keys.get("public"));
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java Fri Aug 17
17:07:07 2012
@@ -97,10 +97,14 @@ public class ClusterSpec {
PROVIDER(String.class, false, "The name of the cloud provider. " +
"E.g. aws-ec2, cloudservers-uk"),
+
+ ENDPOINT(String.class, false, "optionally specifies the url of the " +
+ "compute provider. For example, for openstack-nova, it is the " +
+ "keystone url, like: http://localhost:5000/v2.0/."),
- CREDENTIAL(String.class, false, "The cloud credential."),
-
IDENTITY(String.class, false, "The cloud identity."),
+
+ CREDENTIAL(String.class, false, "The cloud credential."),
PUBLIC_KEY_FILE(String.class, false, "The filename of the public " +
"key used to connect to instances."),
@@ -111,6 +115,8 @@ public class ClusterSpec {
BLOBSTORE_PROVIDER(String.class, false, "The blob store provider. " +
"E.g. aws-s3, cloudfiles-us, cloudfiles-uk"),
+ BLOBSTORE_ENDPOINT(String.class, false, "The blob store endpoint"),
+
BLOBSTORE_IDENTITY(String.class, false, "The blob store identity"),
BLOBSTORE_CREDENTIAL(String.class, false, "The blob store credential"),
@@ -212,6 +218,7 @@ public class ClusterSpec {
throws ConfigurationException, JSchException, IOException {
return withTemporaryKeys(new PropertiesConfiguration());
}
+
@VisibleForTesting
public static ClusterSpec withTemporaryKeys(Configuration conf)
throws ConfigurationException, JSchException, IOException {
@@ -253,11 +260,13 @@ public class ClusterSpec {
private int maxStartupRetries;
private String provider;
+ private String endpoint;
private String identity;
private String credential;
private String blobStoreProvider;
private String blobStoreIdentity;
+ private String blobStoreEndpoint;
private String blobStoreCredential;
private String blobStoreCacheContainer;
@@ -328,10 +337,12 @@ public class ClusterSpec {
setAutoHostnameSuffix(getString(Property.AUTO_HOSTNAME_SUFFIX));
setProvider(getString(Property.PROVIDER));
+ setEndpoint(getString(Property.ENDPOINT));
setIdentity(getString(Property.IDENTITY));
setCredential(getString(Property.CREDENTIAL));
setBlobStoreProvider(getString(Property.BLOBSTORE_PROVIDER));
+ setBlobStoreEndpoint(getString(Property.BLOBSTORE_ENDPOINT));
setBlobStoreIdentity(getString(Property.BLOBSTORE_IDENTITY));
setBlobStoreCredential(getString(Property.BLOBSTORE_CREDENTIAL));
setBlobStoreCacheContainer(getString(Property.BLOBSTORE_CACHE_CONTAINER));
@@ -530,6 +541,15 @@ public class ClusterSpec {
public boolean isStub() {
return "stub".equals(getProvider());
}
+
+ /**
+ * Optionally specifies the url of the compute provider. For example, for
+ * {@code openstack-nova}, it is the keystone url, like:
+ * {@code http://localhost:5000/v2.0/}.
+ */
+ public String getEndpoint() {
+ return endpoint;
+ }
public String getIdentity() {
return identity;
@@ -568,7 +588,16 @@ public class ClusterSpec {
}
return mappings.get(provider);
}
-
+
+ /**
+ * Optionally specifies the url of the blobstore provider. For example, for
+ * {@code swift-keystone}, it is the keystone url, like:
+ * {@code http://localhost:5000/v2.0/}.
+ */
+ public String getBlobStoreEndpoint() {
+ return blobStoreEndpoint;
+ }
+
public String getBlobStoreIdentity() {
if (blobStoreIdentity == null) {
return identity;
@@ -706,7 +735,11 @@ public class ClusterSpec {
setAutoHostnameSuffix(".static.cloud-ips.co.uk");
}
}
-
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
public void setIdentity(String identity) {
this.identity = identity;
}
@@ -719,6 +752,10 @@ public class ClusterSpec {
blobStoreProvider = provider;
}
+ public void setBlobStoreEndpoint(String endpoint) {
+ this.blobStoreEndpoint = endpoint;
+ }
+
public void setBlobStoreIdentity(String identity) {
blobStoreIdentity = identity;
}
@@ -949,9 +986,11 @@ public class ClusterSpec {
return Objects.equal(getInstanceTemplates(), that.getInstanceTemplates())
&& Objects.equal(getMaxStartupRetries(), that.getMaxStartupRetries())
&& Objects.equal(getProvider(), that.getProvider())
+ && Objects.equal(getEndpoint(), that.getEndpoint())
&& Objects.equal(getIdentity(), that.getIdentity())
&& Objects.equal(getCredential(), that.getCredential())
&& Objects.equal(getBlobStoreProvider(), that.getBlobStoreProvider())
+ && Objects.equal(getBlobStoreEndpoint(), that.getBlobStoreEndpoint())
&& Objects.equal(getBlobStoreIdentity(), that.getBlobStoreIdentity())
&& Objects.equal(getBlobStoreCredential(),
that.getBlobStoreCredential())
&& Objects.equal(getBlobStoreCacheContainer(),
that.getBlobStoreCacheContainer())
@@ -986,9 +1025,11 @@ public class ClusterSpec {
getInstanceTemplates(),
getMaxStartupRetries(),
getProvider(),
+ getEndpoint(),
getIdentity(),
getCredential(),
getBlobStoreProvider(),
+ getBlobStoreEndpoint(),
getBlobStoreIdentity(),
getBlobStoreCredential(),
getBlobStoreCacheContainer(),
@@ -1017,13 +1058,15 @@ public class ClusterSpec {
}
public String toString() {
- return Objects.toStringHelper(this)
+ return Objects.toStringHelper(this).omitNullValues()
.add("instanceTemplates", getInstanceTemplates())
.add("maxStartupRetries", getMaxStartupRetries())
.add("provider", getProvider())
+ .add("endpoint", getEndpoint())
.add("identity", getIdentity())
.add("credential", getCredential())
.add("blobStoreProvider", getBlobStoreProvider())
+ .add("blobStoreEndpoint", getBlobStoreEndpoint())
.add("blobStoreCredential", getBlobStoreCredential())
.add("blobStoreIdentity", getBlobStoreIdentity())
.add("blobStoreCacheContainer", getBlobStoreCacheContainer())
Modified:
whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
---
whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java
(original)
+++
whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java
Fri Aug 17 17:07:07 2012
@@ -80,13 +80,15 @@ public class BlobStoreContextBuilder {
@Override
public BlobStoreContext load(Key arg0) {
LOG.debug("creating new BlobStoreContext {}", arg0);
+ ContextBuilder builder = ContextBuilder.newBuilder(arg0.provider)
+ .credentials(arg0.identity,
arg0.credential)
+ .overrides(arg0.overrides)
+
.modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(),
+ new
EnterpriseConfigurationModule()));
+ if (arg0.endpoint != null)
+ builder.endpoint(arg0.endpoint);
BlobStoreContext context = new IgnoreCloseBlobStoreContext(
- ContextBuilder.newBuilder(arg0.provider)
- .credentials(arg0.identity, arg0.credential)
- .overrides(arg0.overrides)
- .modules(ImmutableSet.<Module>of(new
SLF4JLoggingModule(),
- new
EnterpriseConfigurationModule()))
- .buildView(BlobStoreContext.class));
+ builder.buildView(BlobStoreContext.class));
LOG.info("created new BlobStoreContext {}", context);
return context;
}
@@ -214,6 +216,7 @@ public class BlobStoreContextBuilder {
*/
private static class Key {
private final String provider;
+ private final String endpoint;
private final String identity;
private final String credential;
private final String key;
@@ -229,9 +232,13 @@ public class BlobStoreContextBuilder {
public Key(ClusterSpec spec) {
provider = spec.getBlobStoreProvider();
+ endpoint = spec.getBlobStoreEndpoint();
identity = spec.getBlobStoreIdentity();
credential = spec.getBlobStoreCredential();
- key = String.format("%s-%s-%s", provider, identity, credential);
+ key = Objects.toStringHelper("").omitNullValues()
+ .add("provider", provider)
+ .add("endpoint", endpoint)
+ .add("identity", identity).toString();
Configuration jcloudsConfig =
spec.getConfigurationForKeysWithPrefix("jclouds");
// jclouds configuration for providers are not prefixed with jclouds.
Modified:
whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java
Fri Aug 17 17:07:07 2012
@@ -91,12 +91,14 @@ public enum ComputeCache implements Func
@Override
public ComputeServiceContext load(Key arg0) {
LOG.debug("creating new ComputeServiceContext {}", arg0);
+ ContextBuilder builder = ContextBuilder.newBuilder(arg0.provider)
+ .credentials(arg0.identity,
arg0.credential)
+ .overrides(arg0.overrides)
+ .modules(arg0.modules);
+ if (arg0.endpoint != null)
+ builder.endpoint(arg0.endpoint);
ComputeServiceContext context = new IgnoreCloseComputeServiceContext(
- ContextBuilder.newBuilder(arg0.provider)
- .credentials(arg0.identity, arg0.credential)
- .overrides(arg0.overrides)
- .modules(arg0.modules)
- .buildView(ComputeServiceContext.class));
+ builder.buildView(ComputeServiceContext.class));
LOG.debug("created new ComputeServiceContext {}", context);
context.utils().eventBus().register(ComputeCache.this);
return context;
@@ -236,6 +238,7 @@ public enum ComputeCache implements Func
*/
private static class Key {
private String provider;
+ private String endpoint;
private String identity;
private String credential;
@@ -246,10 +249,14 @@ public enum ComputeCache implements Func
public Key(ClusterSpec spec) {
provider = spec.getProvider();
+ endpoint = spec.getEndpoint();
identity = spec.getIdentity();
credential = spec.getCredential();
- key = String.format("%s-%s-%s", provider, identity, credential);
+ key = Objects.toStringHelper("").omitNullValues()
+ .add("provider", provider)
+ .add("endpoint", endpoint)
+ .add("identity", identity).toString();
Configuration jcloudsConfig =
spec.getConfigurationForKeysWithPrefix("jclouds");
// jclouds configuration for providers are not prefixed with jclouds.
Modified: whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
(original)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java Fri
Aug 17 17:07:07 2012
@@ -68,6 +68,17 @@ public class ClusterSpecTest {
ClusterSpec spec = ClusterSpec.withNoDefaults(conf);
assertThat(spec.getRunUrlBase(), is("http://example.org"));
}
+
+
+ @Test
+ public void testEndpoint() throws ConfigurationException {
+ Configuration conf = new PropertiesConfiguration();
+ conf.setProperty(ClusterSpec.Property.ENDPOINT.getConfigName(),
"http://compute");
+ conf.setProperty(ClusterSpec.Property.BLOBSTORE_ENDPOINT.getConfigName(),
"http://blobstore");
+ ClusterSpec spec = ClusterSpec.withNoDefaults(conf);
+ assertThat(spec.getEndpoint(), is("http://compute"));
+ assertThat(spec.getBlobStoreEndpoint(), is("http://blobstore"));
+ }
@Test
public void testGetConfigurationForKeysWithPrefix()
Modified: whirr/trunk/src/site/xdoc/configuration-guide.xml
URL:
http://svn.apache.org/viewvc/whirr/trunk/src/site/xdoc/configuration-guide.xml?rev=1374365&r1=1374364&r2=1374365&view=diff
==============================================================================
--- whirr/trunk/src/site/xdoc/configuration-guide.xml (original)
+++ whirr/trunk/src/site/xdoc/configuration-guide.xml Fri Aug 17 17:07:07 2012
@@ -255,6 +255,16 @@ xsi:schemaLocation="http://maven.apache.
</tr>
<tr valign="top">
<td>
+ <tt>whirr.endpoint</tt>
+ </td>
+ <td>
+ <tt>--endpoint</tt>
+ </td>
+ <td>none</td>
+ <td>Specifies the url of the compute provider. For example, for
openstack-nova, it is the keystone url, like: http://localhost:5000/v2.0/. If
not specified, it is the default for the provider</td>
+ </tr>
+ <tr valign="top">
+ <td>
<tt>whirr.identity</tt>
</td>
<td>
@@ -325,6 +335,16 @@ xsi:schemaLocation="http://maven.apache.
</tr>
<tr valign="top">
<td>
+ <tt>whirr.blobstore-endpoint</tt>
+ </td>
+ <td>
+ <tt>--blobstore-endpoint</tt>
+ </td>
+ <td>none</td>
+ <td>Specifies the url of the blobstore provider. For example, for
swift-keystone, it is the keystone url, like: http://localhost:5000/v2.0/. If
not specified, it is the default for the provider</td>
+ </tr>
+ <tr valign="top">
+ <td>
<tt>whirr.blobstore-identity</tt>
</td>
<td>