DaanHoogland commented on code in PR #8530:
URL: https://github.com/apache/cloudstack/pull/8530#discussion_r1633511235
##########
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/IpTablesHelper.java:
##########
@@ -0,0 +1,50 @@
+package org.apache.cloudstack.storage.resource;
+
+import com.cloud.utils.script.Script;
+import org.apache.cloudstack.storage.template.DownloadManagerImpl;
+import org.apache.log4j.Logger;
+
+public class IpTablesHelper {
+ public static final Logger LOGGER = Logger.getLogger(IpTablesHelper.class);
+
+ public static final String OUTPUT_CHAIN = "OUTPUT";
+ public static final String INPUT_CHAIN = "INPUT";
+ public static final String INSERT = " -I ";
+ public static final String APPEND = " -A ";
+
+ public static boolean needsAdding(String chain, String rule) {
+ Script command = new Script("/bin/bash", LOGGER);
+ command.add("-c");
+ command.add("iptables -C " + chain + " " + rule);
+
+ String r1 = command.execute();
+ boolean needsAdding = (r1 != null && r1.contains("iptables: Bad rule
(does a matching rule exist in that chain?)."));
Review Comment:
I've been testing a lot with both, will do one last round and delete
whatever is not appropriate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]