/** * Returns the command that adds firewalld direct rule. * * @return Returns the command that adds firewalld direct rule. */ public static String addFirewalldRule(Chain chain, org.apache.brooklyn.util.net.Protocol protocol, int port, Policy policy) { return addFirewalldRule(chain, Optional.<String>absent(), protocol, port, policy); }
@Test public void testAddFirewalldRule() { Assert.assertEquals(IptablesCommands.addFirewalldRule(Chain.INPUT, Protocol.TCP, 3306, Policy.ACCEPT), addFirewalldRule); }
protected void openIptablesImpl(Iterable<Integer> inboundPorts, SshMachineLocation machine) { if (inboundPorts == null || Iterables.isEmpty(inboundPorts)) { log.info("No ports to open in iptables (no inbound ports) for {} at {}", machine, this); } else { log.info("Opening ports in iptables for {} at {}", entity(), machine); List<String> iptablesRules = Lists.newArrayList(); String iptablesInstallCommands = null; Task<Integer> checkFirewall = checkLocationFirewall(machine); if (checkFirewall.getUnchecked() == 0) { for (Integer port : inboundPorts) { iptablesRules.add(IptablesCommands.addFirewalldRule(Chain.INPUT, Protocol.TCP, port, Policy.ACCEPT)); } } else { iptablesRules = createIptablesRulesForNetworkInterface(inboundPorts); iptablesInstallCommands = IptablesCommands.saveIptablesRules(); } insertIptablesRules(iptablesRules, iptablesInstallCommands, machine); listIptablesRules(machine); } }