You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by as...@apache.org on 2012/01/16 23:05:12 UTC
svn commit: r1232191 - in /whirr/trunk: ./
core/src/main/java/org/apache/whirr/
core/src/main/java/org/apache/whirr/service/jclouds/
core/src/main/java/org/apache/whirr/util/
core/src/test/java/org/apache/whirr/
core/src/test/java/org/apache/whirr/serv...
Author: asavu
Date: Mon Jan 16 22:05:12 2012
New Revision: 1232191
URL: http://svn.apache.org/viewvc?rev=1232191&view=rev
Log:
WHIRR-475. Rename login-user to bootstrap-user to avoid confusions (asavu)
Added:
whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/BindBootstrapCredentialsPatchForEC2.java
whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrProperties.java
whirr/trunk/core/src/test/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrPropertiesTest.java
Removed:
whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/BindLoginCredentialsPatchForEC2.java
whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TakeLoginCredentialsFromWhirrProperties.java
whirr/trunk/core/src/test/java/org/apache/whirr/service/jclouds/TakeLoginCredentialsFromWhirrPropertiesTest.java
Modified:
whirr/trunk/CHANGES.txt
whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.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=1232191&r1=1232190&r2=1232191&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Mon Jan 16 22:05:12 2012
@@ -19,6 +19,8 @@ Trunk (unreleased changes)
WHIRR-407. Upgrade Cassandra to 1.0.6 (Nathan Milford and Andrei Savu)
+ WHIRR-475. Rename login-user to bootstrap-user to avoid confusions (asavu)
+
BUG FIXES
WHIRR-367. Wrong groupId for zookeeper (Joe Crobak via asavu)
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=1232191&r1=1232190&r2=1232191&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 Mon Jan 16 22:05:12 2012
@@ -68,7 +68,7 @@ public class ClusterSpec {
SERVICE_NAME(String.class, false, "(optional) The name of the " +
"service to use. E.g. hadoop."),
- LOGIN_USER(String.class, false, "Override the default login user "+
+ BOOTSTRAP_USER(String.class, false, "Override the default login user "+
"used to bootstrap whirr. E.g. ubuntu or myuser:mypass."),
CLUSTER_USER(String.class, false, "The name of the user that Whirr " +
@@ -239,7 +239,7 @@ public class ClusterSpec {
private String serviceName;
private String clusterUser;
- private String loginUser;
+ private String bootstrapUser;
private List<InstanceTemplate> instanceTemplates;
private int maxStartupRetries;
@@ -304,7 +304,7 @@ public class ClusterSpec {
setClusterName(getString(Property.CLUSTER_NAME));
setServiceName(getString(Property.SERVICE_NAME));
- setLoginUser(getString(Property.LOGIN_USER));
+ setBootstrapUser(getBootstrapUserOrDeprecatedLoginUser());
setClusterUser(getString(Property.CLUSTER_USER));
setInstanceTemplates(InstanceTemplate.parse(config));
@@ -341,7 +341,7 @@ public class ClusterSpec {
Map<String, List<String>> fr = new HashMap<String, List<String>>();
String firewallPrefix = Property.FIREWALL_RULES.getConfigName();
Pattern firewallRuleKeyPattern = Pattern.compile("^".concat(Pattern.quote(firewallPrefix).concat("(?:\\.(.+))?$")));
- for (String key: Iterators.toArray(config.getKeys(), String.class)) {
+ for (String key: Iterators.<String>toArray(config.getKeys(), String.class)) {
Matcher m = firewallRuleKeyPattern.matcher(key);
if (!m.matches()) continue;
@@ -354,6 +354,15 @@ public class ClusterSpec {
setRunUrlBase(getString(Property.RUN_URL_BASE));
}
+ private String getBootstrapUserOrDeprecatedLoginUser() {
+ final String loginUserConfig = "whirr.login-user";
+ if (config.containsKey(loginUserConfig)) {
+ LOG.warn("whirr.login-user is deprecated. Please rename to whirr.bootstrap-user.");
+ return config.getString(loginUserConfig, null);
+ }
+ return getString(Property.BOOTSTRAP_USER);
+ }
+
/**
* Create a deep object copy. It's not enough to just copy the configuration
* because the object can also be modified using the setters and the changes
@@ -365,7 +374,7 @@ public class ClusterSpec {
r.setClusterName(getClusterName());
r.setServiceName(getServiceName());
- r.setLoginUser(getLoginUser());
+ r.setBootstrapUser(getBootstrapUser());
r.setClusterUser(getClusterUser());
r.setInstanceTemplates(Lists.newLinkedList(getInstanceTemplates()));
@@ -632,8 +641,13 @@ public class ClusterSpec {
return clusterUser;
}
+ public String getBootstrapUser() {
+ return bootstrapUser;
+ }
+
+ @Deprecated
public String getLoginUser() {
- return loginUser;
+ return getBootstrapUser();
}
public void setInstanceTemplates(List<InstanceTemplate> instanceTemplates) {
@@ -823,14 +837,19 @@ public class ClusterSpec {
this.clusterUser = user;
}
- public void setLoginUser(String user) {
- loginUser = config.getString(Property.LOGIN_USER.getConfigName());
- if (loginUser != null) {
+ public void setBootstrapUser(String bootstrapUser) {
+ this.bootstrapUser = bootstrapUser;
+ if (this.bootstrapUser != null) {
// patch until jclouds 1.0-beta-10
- System.setProperty("whirr.login-user", loginUser);
+ System.setProperty("whirr.bootstrap-user", this.bootstrapUser);
}
}
+ @Deprecated
+ public void setLoginUser(String user) {
+ setBootstrapUser(user);
+ }
+
public Configuration getConfiguration() {
return config;
}
@@ -883,7 +902,7 @@ public class ClusterSpec {
&& Objects.equal(getClusterName(), that.getClusterName())
&& Objects.equal(getServiceName(), that.getServiceName())
&& Objects.equal(getClusterUser(), that.getClusterUser())
- && Objects.equal(getLoginUser(), that.getLoginUser())
+ && Objects.equal(getBootstrapUser(), that.getBootstrapUser())
&& Objects.equal(getPublicKey(), that.getPublicKey())
&& Objects.equal(getPrivateKey(), that.getPrivateKey())
&& Objects.equal(getImageId(), that.getImageId())
@@ -917,7 +936,7 @@ public class ClusterSpec {
getClusterName(),
getServiceName(),
getClusterUser(),
- getLoginUser(),
+ getBootstrapUser(),
getPublicKey(),
getPrivateKey(),
getImageId(),
@@ -949,7 +968,7 @@ public class ClusterSpec {
.add("clusterName", getClusterName())
.add("serviceName", getServiceName())
.add("clusterUser", getClusterUser())
- .add("loginUser", getLoginUser())
+ .add("bootstrapUser", getBootstrapUser())
.add("publicKey", getPublicKey())
.add("privateKey", getPrivateKey())
.add("imageId", getImageId())
Added: whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/BindBootstrapCredentialsPatchForEC2.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/BindBootstrapCredentialsPatchForEC2.java?rev=1232191&view=auto
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/BindBootstrapCredentialsPatchForEC2.java (added)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/BindBootstrapCredentialsPatchForEC2.java Mon Jan 16 22:05:12 2012
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.service.jclouds;
+
+import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
+
+import com.google.inject.AbstractModule;
+
+/**
+ * patch until http://code.google.com/p/jclouds/issues/detail?id=441
+ */
+public class BindBootstrapCredentialsPatchForEC2 extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(EC2PopulateDefaultLoginCredentialsForImageStrategy.class).to(TakeBootstrapCredentialsFromWhirrProperties.class);
+ }
+
+}
Added: whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrProperties.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrProperties.java?rev=1232191&view=auto
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrProperties.java (added)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrProperties.java Mon Jan 16 22:05:12 2012
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.service.jclouds;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Credentials;
+import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
+
+@Singleton
+// patch until jclouds http://code.google.com/p/jclouds/issues/detail?id=441
+public class TakeBootstrapCredentialsFromWhirrProperties extends
+ EC2PopulateDefaultLoginCredentialsForImageStrategy {
+
+ @Override
+ public Credentials execute(Object resourceToAuthenticate) {
+ if (System.getProperties().containsKey("whirr.bootstrap-user") &&
+ !"".equals(System.getProperty("whirr.bootstrap-user").trim())) {
+ List<String> creds = Lists.newArrayList(Splitter.on(':').split(System.getProperty("whirr.bootstrap-user")));
+ if (creds.size() == 2)
+ return new Credentials(creds.get(0), creds.get(1));
+ return new Credentials(creds.get(0), null);
+ } else {
+ return super.execute(resourceToAuthenticate);
+ }
+ }
+}
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java?rev=1232191&r1=1232190&r2=1232191&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java Mon Jan 16 22:05:12 2012
@@ -37,8 +37,8 @@ public class Utils {
Cluster cluster, int maxPrint) {
out.println("You can log into instances using the following ssh commands:");
- String user = clusterSpec.getLoginUser() != null ? clusterSpec
- .getLoginUser() : clusterSpec.getClusterUser();
+ String user = clusterSpec.getBootstrapUser() != null ? clusterSpec
+ .getBootstrapUser() : clusterSpec.getClusterUser();
String pkFile = clusterSpec.getPrivateKeyFile().getAbsolutePath();
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=1232191&r1=1232190&r2=1232191&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 Mon Jan 16 22:05:12 2012
@@ -70,13 +70,12 @@ public class ClusterSpecTest {
}
@Test
- public void testLoginUserSetsSystemProperty()
+ public void testBootstrapUserSetsSystemProperty()
throws ConfigurationException {
Configuration conf = new PropertiesConfiguration();
- conf.setProperty(ClusterSpec.Property.LOGIN_USER.getConfigName(),
- "ubuntu");
+ conf.setProperty(ClusterSpec.Property.BOOTSTRAP_USER.getConfigName(), "ubuntu");
ClusterSpec.withNoDefaults(conf);
- assertThat(System.getProperty("whirr.login-user"), is("ubuntu"));
+ assertThat(System.getProperty("whirr.bootstrap-user"), is("ubuntu"));
}
@Test
Added: whirr/trunk/core/src/test/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrPropertiesTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrPropertiesTest.java?rev=1232191&view=auto
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrPropertiesTest.java (added)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/service/jclouds/TakeBootstrapCredentialsFromWhirrPropertiesTest.java Mon Jan 16 22:05:12 2012
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.service.jclouds;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import org.jclouds.domain.Credentials;
+import org.junit.Test;
+
+public class TakeBootstrapCredentialsFromWhirrPropertiesTest {
+ TakeBootstrapCredentialsFromWhirrProperties strat =
+ new TakeBootstrapCredentialsFromWhirrProperties();
+
+ @Test
+ public synchronized void testNotSetIsDefault() throws IOException {
+ try {
+ System.getProperties().remove("whirr.bootstrap-user");
+ assertThat(
+ strat.execute(null),
+ equalTo(new Credentials("root", null)));
+ } finally {
+ System.getProperties().remove("whirr.bootstrap-user");
+ }
+ }
+
+ @Test
+ public synchronized void testSetEmptyIsDefault() throws IOException {
+ try {
+ System.setProperty("whirr.bootstrap-user", "");
+ assertThat(
+ strat.execute(null),
+ equalTo(new Credentials("root", null)));
+ } finally {
+ System.getProperties().remove("whirr.bootstrap-user");
+ }
+ }
+
+ @Test
+ public synchronized void testSetUsername() throws IOException {
+ try {
+ System.setProperty("whirr.bootstrap-user", "ubuntu");
+ assertThat(
+ strat.execute(null),
+ equalTo(new Credentials("ubuntu", null)));
+ } finally {
+ System.getProperties().remove("whirr.bootstrap-user");
+ }
+ }
+
+ @Test
+ public synchronized void testSetUsernamePassword() throws IOException {
+ try {
+ System.setProperty("whirr.bootstrap-user", "ubuntu:pass");
+ assertThat(
+ strat.execute(null),
+ equalTo(new Credentials("ubuntu", "pass")));
+ } finally {
+ System.getProperties().remove("whirr.bootstrap-user");
+ }
+ }
+}
Modified: whirr/trunk/src/site/xdoc/configuration-guide.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/src/site/xdoc/configuration-guide.xml?rev=1232191&r1=1232190&r2=1232191&view=diff
==============================================================================
--- whirr/trunk/src/site/xdoc/configuration-guide.xml (original)
+++ whirr/trunk/src/site/xdoc/configuration-guide.xml Mon Jan 16 22:05:12 2012
@@ -279,10 +279,10 @@ xsi:schemaLocation="http://maven.apache.
</tr>
<tr valign="top">
<td>
- <tt>whirr.login-user</tt>
+ <tt>whirr.bootstrap-user</tt>
</td>
<td>
- <tt>--login-user</tt>
+ <tt>--bootstrap-user</tt>
</td>
<td>none</td>
<td>Override the default login user used to bootstrap whirr. E.g. ubuntu or