You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/02/18 13:41:51 UTC
[2/4] incubator-brooklyn git commit: Jclouds openIptables: avoid NPE
if no inboundPorts
Jclouds openIptables: avoid NPE if no inboundPorts
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2227415b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2227415b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2227415b
Branch: refs/heads/master
Commit: 2227415b25f0b821f23c1899181f6040195fc54b
Parents: 0416bd1
Author: Aled Sage <al...@gmail.com>
Authored: Wed Feb 18 10:08:24 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 12:06:26 2015 +0000
----------------------------------------------------------------------
.../location/jclouds/JcloudsLocation.java | 38 +++++++++++---------
1 file changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2227415b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index 37272d4..706b3ee 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -742,25 +742,31 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
}
if (setup.get(OPEN_IPTABLES)) {
- customisationForLogging.add("open iptables");
-
@SuppressWarnings("unchecked")
- List<String> iptablesRules = createIptablesRulesForNetworkInterface((Iterable<Integer>) setup.get(INBOUND_PORTS));
- iptablesRules.add(IptablesCommands.saveIptablesRules());
- List<String> batch = Lists.newArrayList();
- // Some entities, such as Riak (erlang based) have a huge range of ports, which leads to a script that
- // is too large to run (fails with a broken pipe). Batch the rules into batches of 50
- for (String rule : iptablesRules) {
- batch.add(rule);
- if (batch.size() == 50) {
- sshMachineLocation.execCommands("Inserting iptables rules, 50 command batch", batch);
- batch.clear();
+ Iterable<Integer> inboundPorts = (Iterable<Integer>) setup.get(INBOUND_PORTS);
+
+ if (inboundPorts == null || Iterables.isEmpty(inboundPorts)) {
+ LOG.info("No ports to open in iptables (no inbound ports) for {} at {}", sshMachineLocation, this);
+ } else {
+ customisationForLogging.add("open iptables");
+
+ List<String> iptablesRules = createIptablesRulesForNetworkInterface(inboundPorts);
+ iptablesRules.add(IptablesCommands.saveIptablesRules());
+ List<String> batch = Lists.newArrayList();
+ // Some entities, such as Riak (erlang based) have a huge range of ports, which leads to a script that
+ // is too large to run (fails with a broken pipe). Batch the rules into batches of 50
+ for (String rule : iptablesRules) {
+ batch.add(rule);
+ if (batch.size() == 50) {
+ sshMachineLocation.execCommands("Inserting iptables rules, 50 command batch", batch);
+ batch.clear();
+ }
}
+ if (batch.size() > 0) {
+ sshMachineLocation.execCommands("Inserting iptables rules", batch);
+ }
+ sshMachineLocation.execCommands("List iptables rules", ImmutableList.of(IptablesCommands.listIptablesRule()));
}
- if (batch.size() > 0) {
- sshMachineLocation.execCommands("Inserting iptables rules", batch);
- }
- sshMachineLocation.execCommands("List iptables rules", ImmutableList.of(IptablesCommands.listIptablesRule()));
}
if (setup.get(STOP_IPTABLES)) {