summaryrefslogtreecommitdiffstats
path: root/roles/os_firewall
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-01-16 13:50:18 -0500
committerGitHub <noreply@github.com>2017-01-16 13:50:18 -0500
commitb01d19b5a37330c4b3fea5f1f54efd6ef0e207c0 (patch)
tree52922092a2676b14b77b38a4ecad8200cec79258 /roles/os_firewall
parente68f1946e665c2d0f8af0fdb96c96d966a4353ef (diff)
parentd9fe14e9b53590d7949cbdd53cedb89bbc0ee037 (diff)
downloadopenshift-b01d19b5a37330c4b3fea5f1f54efd6ef0e207c0.tar.gz
openshift-b01d19b5a37330c4b3fea5f1f54efd6ef0e207c0.tar.bz2
openshift-b01d19b5a37330c4b3fea5f1f54efd6ef0e207c0.tar.xz
openshift-b01d19b5a37330c4b3fea5f1f54efd6ef0e207c0.zip
Merge pull request #3096 from abutcher/node_ports
Support openshift_node_port_range for configuring service NodePorts
Diffstat (limited to 'roles/os_firewall')
-rwxr-xr-xroles/os_firewall/library/os_firewall_manage_iptables.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/roles/os_firewall/library/os_firewall_manage_iptables.py b/roles/os_firewall/library/os_firewall_manage_iptables.py
index b60e52dfe..8ba650994 100755
--- a/roles/os_firewall/library/os_firewall_manage_iptables.py
+++ b/roles/os_firewall/library/os_firewall_manage_iptables.py
@@ -127,9 +127,17 @@ class IpTablesManager(object): # pylint: disable=too-many-instance-attributes
check_cmd = self.cmd + ['-C'] + rule
return True if subprocess.call(check_cmd) == 0 else False
+ @staticmethod
+ def port_as_argument(port):
+ if isinstance(port, int):
+ return str(port)
+ if isinstance(port, basestring): # noqa: F405
+ return port.replace('-', ":")
+ return port
+
def gen_rule(self, port, proto):
return [self.chain, '-p', proto, '-m', 'state', '--state', 'NEW',
- '-m', proto, '--dport', str(port), '-j', 'ACCEPT']
+ '-m', proto, '--dport', IpTablesManager.port_as_argument(port), '-j', 'ACCEPT']
def create_jump(self):
if self.check_mode:
@@ -231,7 +239,7 @@ def main():
create_jump_rule=dict(required=False, type='bool', default=True),
jump_rule_chain=dict(required=False, default='INPUT'),
protocol=dict(required=False, choices=['tcp', 'udp']),
- port=dict(required=False, type='int'),
+ port=dict(required=False, type='str'),
ip_version=dict(required=False, default='ipv4',
choices=['ipv4', 'ipv6']),
),