Author: tomwhite
Date: Mon Oct 10 22:34:15 2011
New Revision: 1181281

URL: http://svn.apache.org/viewvc?rev=1181281&view=rev
Log:
WHIRR-395. Less verbose logging when setting firewall rules. Contributed by 
asavu.

Modified:
    whirr/trunk/CHANGES.txt
    whirr/trunk/core/src/main/java/org/apache/whirr/service/FirewallManager.java

Modified: whirr/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1181281&r1=1181280&r2=1181281&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Mon Oct 10 22:34:15 2011
@@ -26,6 +26,9 @@ Trunk (unreleased changes)
 
     WHIRR-387. Add Website Navigation Links (asavu)
 
+    WHIRR-395. Less verbose logging when setting firewall rules.
+    (asavu via tomwhite)
+
   BUG FIXES
 
     WHIRR-377. Fix broken CLI logging config. (asavu via tomwhite)

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/service/FirewallManager.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/FirewallManager.java?rev=1181281&r1=1181280&r2=1181281&view=diff
==============================================================================
--- 
whirr/trunk/core/src/main/java/org/apache/whirr/service/FirewallManager.java 
(original)
+++ 
whirr/trunk/core/src/main/java/org/apache/whirr/service/FirewallManager.java 
Mon Oct 10 22:34:15 2011
@@ -23,6 +23,8 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
 import org.apache.whirr.Cluster;
 import org.apache.whirr.Cluster.Instance;
 import org.apache.whirr.ClusterSpec;
@@ -35,6 +37,8 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
+import javax.annotation.Nullable;
+
 public class FirewallManager {
 
   public static class Rule {
@@ -133,10 +137,11 @@ public class FirewallManager {
   }
   
   /**
-   * Rules are additive. If no
-   * source is set then it will default to {@link 
ClusterSpec#getClientCidrs()},
-   * or, if that is not set, to the client's originating IP.
-   * If no destinations or ports are set then the rule has not effect.
+   * Rules are additive. If no source is set then it will default
+   * to {@link ClusterSpec#getClientCidrs()}, or, if that is not set,
+   * to the client's originating IP. If no destinations or ports
+   * are set then the rule has not effect.
+   *
    * @param rule The rule to add to the firewall. 
    * @throws IOException
    */
@@ -157,8 +162,18 @@ public class FirewallManager {
     } else {
       cidrs = Lists.newArrayList(rule.source + "/32");
     }
+
+    Iterable<String> instanceIds =
+      Iterables.transform(instances, new Function<Instance, String>() {
+        @Override
+        public String apply(@Nullable Instance instance) {
+          return instance == null ? "<null>" : instance.getId();
+        }
+      });
+
     LOG.info("Authorizing firewall ingress to {} on ports {} for {}",
-        new Object[] { instances, rule.ports, cidrs });
+        new Object[] { instanceIds, rule.ports, cidrs });
+
     FirewallSettings.authorizeIngress(computeServiceContext, instances,
         clusterSpec, cidrs, rule.ports);
   }


Reply via email to