whirr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r1028038 - in /incubator/whirr/trunk: ./ cli/ core/ scripts/apache/cassandra/ scripts/apache/zookeeper/ scripts/util/ services/cassandra/ services/cassandra/src/main/java/org/apache/whirr/service/cassandra/ services/hadoop/ services/hadoop/...
Date Wed, 27 Oct 2010 17:03:09 GMT
Author: tomwhite
Date: Wed Oct 27 17:03:08 2010
New Revision: 1028038

URL: http://svn.apache.org/viewvc?rev=1028038&view=rev
Log:
WHIRR-52. Support all services on Rackspace Cloud Servers.

Added:
    incubator/whirr/trunk/scripts/util/configure-hostnames
Modified:
    incubator/whirr/trunk/CHANGES.txt
    incubator/whirr/trunk/cli/pom.xml
    incubator/whirr/trunk/core/pom.xml
    incubator/whirr/trunk/pom.xml
    incubator/whirr/trunk/scripts/apache/cassandra/post-configure
    incubator/whirr/trunk/scripts/apache/zookeeper/post-configure
    incubator/whirr/trunk/services/cassandra/pom.xml
    incubator/whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/CassandraService.java
    incubator/whirr/trunk/services/hadoop/pom.xml
    incubator/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopService.java
    incubator/whirr/trunk/services/zookeeper/pom.xml
    incubator/whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/ZooKeeperService.java
    incubator/whirr/trunk/src/site/confluence/faq.confluence
    incubator/whirr/trunk/src/site/confluence/index.confluence

Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Wed Oct 27 17:03:08 2010
@@ -28,6 +28,8 @@ Trunk (unreleased changes)
 
     WHIRR-112. Expand documentation. (tomwhite)
 
+    WHIRR-52. Support all services on Rackspace Cloud Servers. (tomwhite)
+
   BUG FIXES
 
     WHIRR-93. Fail on checkstyle violation. (tomwhite)

Modified: incubator/whirr/trunk/cli/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/cli/pom.xml?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/cli/pom.xml (original)
+++ incubator/whirr/trunk/cli/pom.xml Wed Oct 27 17:03:08 2010
@@ -51,7 +51,7 @@
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>
-      <artifactId>jclouds-aws</artifactId>
+      <artifactId>jclouds-allcompute</artifactId>
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>

Modified: incubator/whirr/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/pom.xml?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/core/pom.xml (original)
+++ incubator/whirr/trunk/core/pom.xml Wed Oct 27 17:03:08 2010
@@ -31,7 +31,7 @@
   <dependencies>
     <dependency>
       <groupId>org.jclouds</groupId>
-      <artifactId>jclouds-aws</artifactId>
+      <artifactId>jclouds-allcompute</artifactId>
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>

Modified: incubator/whirr/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/pom.xml?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/pom.xml (original)
+++ incubator/whirr/trunk/pom.xml Wed Oct 27 17:03:08 2010
@@ -52,7 +52,7 @@
     <dependencies>
       <dependency>
         <groupId>org.jclouds</groupId>
-        <artifactId>jclouds-aws</artifactId>
+        <artifactId>jclouds-allcompute</artifactId>
         <version>${jclouds.version}</version>
       </dependency>
       <dependency>

Modified: incubator/whirr/trunk/scripts/apache/cassandra/post-configure
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/scripts/apache/cassandra/post-configure?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/scripts/apache/cassandra/post-configure (original)
+++ incubator/whirr/trunk/scripts/apache/cassandra/post-configure Wed Oct 27 17:03:08 2010
@@ -21,7 +21,30 @@
 set -x
 set -e
 
-SELF_HOST=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+CLOUD_PROVIDER=
+while getopts "c:" OPTION; do
+  case $OPTION in
+  c)
+    CLOUD_PROVIDER="$OPTARG"
+    shift $((OPTIND-1)); OPTIND=1
+    ;;
+  esac
+done
+
+case $CLOUD_PROVIDER in
+  # We want the gossip protocol to use internal (private) addresses, and the
+  # client to use public addresses.
+  # See http://wiki.apache.org/cassandra/FAQ#cant_listen_on_ip_any
+  ec2)
+    PRIVATE_SELF_HOST=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`
+    # EC2 is NATed
+    PUBLIC_SELF_HOST=$PRIVATE_SELF_HOST
+    ;;
+  *)
+    PUBLIC_SELF_HOST=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print
$1}'`
+    PRIVATE_SELF_HOST=`/sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print
$1}'`
+    ;;
+esac
 
 config_file=/etc/cassandra/conf/storage-conf.xml
 
@@ -33,8 +56,8 @@ done
 
 #TODO set replication
 sed -i -e "s|<Seed>127.0.0.1</Seed>|$seeds|" $config_file
-sed -i -e "s|<ListenAddress>localhost</ListenAddress>|<ListenAddress>$SELF_HOST</ListenAddress>|"
$config_file
-sed -i -e "s|<ThriftAddress>localhost</ThriftAddress>|<ThriftAddress>$SELF_HOST</ThriftAddress>|"
$config_file
+sed -i -e "s|<ListenAddress>localhost</ListenAddress>|<ListenAddress>$PRIVATE_SELF_HOST</ListenAddress>|"
$config_file
+sed -i -e "s|<ThriftAddress>localhost</ThriftAddress>|<ThriftAddress>$PUBLIC_SELF_HOST</ThriftAddress>|"
$config_file
 
 # Now that it's configured, start Cassandra
 nohup /etc/rc.local &
\ No newline at end of file

Modified: incubator/whirr/trunk/scripts/apache/zookeeper/post-configure
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/scripts/apache/zookeeper/post-configure?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/scripts/apache/zookeeper/post-configure (original)
+++ incubator/whirr/trunk/scripts/apache/zookeeper/post-configure Wed Oct 27 17:03:08 2010
@@ -18,12 +18,31 @@
 # Configure Apache ZooKeeper after the ensemble has started.
 #
 # Call with arguments listing all the servers in the ensemble:
-# post-configure <server-ip>*
+# post-configure -c <cloud-provider> <server-ip>*
 
 set -x
 set -e
 
-SELF_HOST=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+CLOUD_PROVIDER=
+while getopts "c:" OPTION; do
+  case $OPTION in
+  c)
+    CLOUD_PROVIDER="$OPTARG"
+    shift $((OPTIND-1)); OPTIND=1
+    ;;
+  esac
+done
+
+case $CLOUD_PROVIDER in
+  # Use private IP for SELF_HOST
+  # ZooKeeper listens on all addresses, not just the one specified in server.<id>
+  ec2)
+    SELF_HOST=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`
+    ;;
+  *)
+    SELF_HOST=`/sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+    ;;
+esac
 
 myid_file=/var/log/zookeeper/txlog/myid
 config_file=/etc/zookeeper/conf/zoo.cfg

Added: incubator/whirr/trunk/scripts/util/configure-hostnames
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/scripts/util/configure-hostnames?rev=1028038&view=auto
==============================================================================
--- incubator/whirr/trunk/scripts/util/configure-hostnames (added)
+++ incubator/whirr/trunk/scripts/util/configure-hostnames Wed Oct 27 17:03:08 2010
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# Ensure that hostnames resolve correctly.
+
+set -x
+set -e
+
+CLOUD_PROVIDER=
+while getopts "c:" OPTION; do
+  case $OPTION in
+  c)
+    CLOUD_PROVIDER="$OPTARG"
+    shift $((OPTIND-1)); OPTIND=1
+    ;;
+  esac
+done
+
+case $CLOUD_PROVIDER in
+  cloudservers)
+    if which dpkg &> /dev/null; then
+      PRIVATE_IP=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+      HOSTNAME=`echo $PRIVATE_IP | tr . -`.static.cloud-ips.com
+      echo $HOSTNAME > /etc/hostname
+      sed -i -e "s/$PRIVATE_IP.*/$PRIVATE_IP $HOSTNAME/" /etc/hosts
+      set +e
+      /etc/init.d/hostname restart
+      set -e
+      sleep 2
+      hostname
+    fi
+    ;;
+esac
\ No newline at end of file

Modified: incubator/whirr/trunk/services/cassandra/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/cassandra/pom.xml?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/services/cassandra/pom.xml (original)
+++ incubator/whirr/trunk/services/cassandra/pom.xml Wed Oct 27 17:03:08 2010
@@ -43,7 +43,7 @@
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>
-      <artifactId>jclouds-aws</artifactId>
+      <artifactId>jclouds-allcompute</artifactId>
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>

Modified: incubator/whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/CassandraService.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/CassandraService.java?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/CassandraService.java
(original)
+++ incubator/whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/CassandraService.java
Wed Oct 27 17:03:08 2010
@@ -54,7 +54,9 @@ import org.jclouds.compute.RunScriptOnNo
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.RunScriptOptions;
 import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.domain.Credentials;
 import org.jclouds.io.Payload;
 import org.jclouds.ssh.ExecResponse;
 import org.slf4j.Logger;
@@ -121,14 +123,21 @@ public class CassandraService extends Se
     // Pass list of all servers in cluster to configure script.
     String servers = Joiner.on(' ').join(getPrivateIps(seeds));
     Payload configureScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
-            "apache/cassandra/post-configure " + servers));
+        String.format("apache/cassandra/post-configure -c %s %s",
+            clusterSpec.getProvider(),
+            servers)));
+    // Use private key to run script
+    Credentials credentials = new Credentials(
+      Iterables.get(nodes, 0).getCredentials().identity,
+      clusterSpec.readPrivateKey());
 
     try {
       LOG.info("Running configuration script");
       Map<? extends NodeMetadata, ExecResponse> responses = computeService
           .runScriptOnNodesMatching(
             NodePredicates.runningWithTag(clusterSpec.getClusterName()),
-              configureScript);
+              configureScript,
+              RunScriptOptions.Builder.overrideCredentialsWith(credentials));
       assert responses.size() > 0 : "no nodes matched "
           + clusterSpec.getClusterName();
     } catch (RunScriptOnNodesException e) {

Modified: incubator/whirr/trunk/services/hadoop/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hadoop/pom.xml?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/services/hadoop/pom.xml (original)
+++ incubator/whirr/trunk/services/hadoop/pom.xml Wed Oct 27 17:03:08 2010
@@ -43,7 +43,7 @@
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>
-      <artifactId>jclouds-aws</artifactId>
+      <artifactId>jclouds-allcompute</artifactId>
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>

Modified: incubator/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopService.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopService.java?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopService.java
(original)
+++ incubator/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopService.java
Wed Oct 27 17:03:08 2010
@@ -90,6 +90,7 @@ public class HadoopService extends Servi
     String hadoopInstallRunUrl = clusterSpec.getConfiguration().getString(
         "whirr.hadoop-install-runurl", "apache/hadoop/install");
     Payload nnjtBootScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
+      String.format("util/configure-hostnames -c %s", clusterSpec.getProvider()),
       "sun/java/install",
       String.format("%s nn,jt -c %s", hadoopInstallRunUrl,
           clusterSpec.getProvider())));
@@ -142,6 +143,7 @@ public class HadoopService extends Servi
 
     // Launch slaves (DN and TT)
     Payload slaveBootScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
+      String.format("util/configure-hostnames -c %s", clusterSpec.getProvider()),
       "sun/java/install",
       String.format("%s dn,tt -n %s -j %s -c %s",
           hadoopInstallRunUrl,
@@ -154,7 +156,7 @@ public class HadoopService extends Servi
       .installPrivateKey(clusterSpec.getPrivateKey())
       .authorizePublicKey(clusterSpec.getPublicKey()));
 
-    strategy.configureTemplateBuilder(clusterSpec, slaveTemplateBuilder);
+    slaveTemplateBuilder.fromTemplate(masterTemplate); // base on master
     slaveTemplateBuilder.locationId(masterTemplate.getLocation().getId());
     
     Template slaveTemplate = slaveTemplateBuilder.build();

Modified: incubator/whirr/trunk/services/zookeeper/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/zookeeper/pom.xml?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/services/zookeeper/pom.xml (original)
+++ incubator/whirr/trunk/services/zookeeper/pom.xml Wed Oct 27 17:03:08 2010
@@ -43,7 +43,7 @@
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>
-      <artifactId>jclouds-aws</artifactId>
+      <artifactId>jclouds-allcompute</artifactId>
     </dependency>
     <dependency>
       <groupId>org.jclouds</groupId>

Modified: incubator/whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/ZooKeeperService.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/ZooKeeperService.java?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/ZooKeeperService.java
(original)
+++ incubator/whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/ZooKeeperService.java
Wed Oct 27 17:03:08 2010
@@ -52,7 +52,9 @@ import org.jclouds.compute.RunScriptOnNo
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.RunScriptOptions;
 import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.domain.Credentials;
 import org.jclouds.io.Payload;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -116,11 +118,19 @@ public class ZooKeeperService extends Se
     // Position is significant: i-th server has id i.
     String servers = Joiner.on(' ').join(getPrivateIps(nodes));
     Payload configureScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
-      "apache/zookeeper/post-configure " + servers));
+      String.format("apache/zookeeper/post-configure -c %s %s",
+          clusterSpec.getProvider(),
+          servers)));
+    // Use private key to run script
+    Credentials credentials = new Credentials(
+      Iterables.get(nodes, 0).getCredentials().identity,
+      clusterSpec.readPrivateKey());
     try {
       LOG.info("Running configuration script");
       computeService.runScriptOnNodesMatching(NodePredicates.runningWithTag(
-          clusterSpec.getClusterName()), configureScript);
+          clusterSpec.getClusterName()),
+          configureScript,
+          RunScriptOptions.Builder.overrideCredentialsWith(credentials));
     } catch (RunScriptOnNodesException e) {
       // TODO: retry
       throw new IOException(e);
@@ -138,11 +148,11 @@ public class ZooKeeperService extends Se
       @Override
       public String apply(NodeMetadata node) {
         try {
-         return InetAddress.getByName(Iterables.get(node.getPrivateAddresses(), 0)).getHostAddress();
-      } catch (UnknownHostException e) {
-         Throwables.propagate(e);
-         return null;
-      }
+          return InetAddress.getByName(Iterables.get(node.getPrivateAddresses(), 0)).getHostAddress();
+        } catch (UnknownHostException e) {
+          Throwables.propagate(e);
+          return null;
+        }
       }
     });
   }
@@ -153,9 +163,9 @@ public class ZooKeeperService extends Se
       @Override
       public Instance apply(NodeMetadata node) {
         try {
-        return new Instance(node.getCredentials(), Collections.singleton(ZOOKEEPER_ROLE),
-          InetAddress.getByName(Iterables.get(node.getPublicAddresses(), 0)),
-          InetAddress.getByName(Iterables.get(node.getPrivateAddresses(), 0)));
+          return new Instance(node.getCredentials(), Collections.singleton(ZOOKEEPER_ROLE),
+            InetAddress.getByName(Iterables.get(node.getPublicAddresses(), 0)),
+            InetAddress.getByName(Iterables.get(node.getPrivateAddresses(), 0)));
         } catch (UnknownHostException e) {
           throw new RuntimeException(e);
         }
@@ -169,12 +179,12 @@ public class ZooKeeperService extends Se
       @Override
       public String apply(NodeMetadata node) {
         String publicIp;
-      try {
-         publicIp = InetAddress.getByName(Iterables.get(node.getPublicAddresses(), 0)).getHostName();
-      } catch (UnknownHostException e) {
-         Throwables.propagate(e);
-         return null;
-      }
+        try {
+          publicIp = InetAddress.getByName(Iterables.get(node.getPublicAddresses(), 0)).getHostName();
+        } catch (UnknownHostException e) {
+          Throwables.propagate(e);
+          return null;
+        }
         return String.format("%s:%d", publicIp, CLIENT_PORT);
       }
     });

Modified: incubator/whirr/trunk/src/site/confluence/faq.confluence
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/src/site/confluence/faq.confluence?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/src/site/confluence/faq.confluence (original)
+++ incubator/whirr/trunk/src/site/confluence/faq.confluence Wed Oct 27 17:03:08 2010
@@ -10,6 +10,21 @@ On EC2:
 
 Another good resource is [Understanding Access Credentials for AWS/EC2|http://alestic.com/2009/11/ec2-credentials]
by Eric Hammond.
 
+h2. Can I specify my own private key?
+
+Yes, by setting {{whirr.private-key-file}} (or {{\--private-key-file}} on the
+command line). You should also set {{whirr.public-key-file}}
+({{\--public-key-file}}) at the same time.
+
+Private keys must not have a passphrase associated with them. You can check this
+with:
+
+{code}
+grep ENCRYPTED ~/.ssh/id_rsa
+{code}
+
+If there is no passphrase then there will be no match.
+
 h2. How do I access my cluster from a different network?
 
 By default, access to clusters is restricted to the single IP address of the

Modified: incubator/whirr/trunk/src/site/confluence/index.confluence
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/src/site/confluence/index.confluence?rev=1028038&r1=1028037&r2=1028038&view=diff
==============================================================================
--- incubator/whirr/trunk/src/site/confluence/index.confluence (original)
+++ incubator/whirr/trunk/src/site/confluence/index.confluence Wed Oct 27 17:03:08 2010
@@ -16,7 +16,7 @@ the cloud provider and service combinati
 
 ||Cloud provider||Cassandra||Hadoop||ZooKeeper||
 |Amazon EC2|Yes|Yes|Yes|
-|Rackspace|No|No|No|
+|Rackspace Cloud Servers|Yes|Yes|Yes|
 
 h2. Download
 



Mime
View raw message