summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/lib_utils.py
diff options
context:
space:
mode:
authorRajesh Madaka <rmadaka@redhat.com>2018-02-04 17:37:57 +0530
committerNigel Babu <nigelb@redhat.com>2018-04-25 08:54:26 +0000
commitdc906e7451a920248e5a85fa4cf051758bc3fc6f (patch)
treea32caef94081c7de16d52bd2774e2d57504eac71 /glustolibs-gluster/glustolibs/gluster/lib_utils.py
parentfb1f00022716df511dc16c6a532b83c5e230e245 (diff)
Opening firewall ports for rhel7
Change-Id: I06194cd8968e0beb1dbd0815deaa999fc409272c Signed-off-by: Rajesh Madaka <rmadaka@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/lib_utils.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/lib_utils.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
index 472c58c..3cb1e44 100644
--- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
@@ -832,3 +832,48 @@ def is_core_file_created(nodes, testrun_timestamp,
else:
g.log.info("No core files found ")
return True
+
+
+def open_firewall(nodes, firewall_service, permanent=False):
+ """Opening firewall services on nodes
+ This library only for RHEL7, for RHEL6 not required
+ Args:
+ nodes(list|str): List of server on which firewalls services to be
+ removed
+ firewall_service(list|str): List of firewall services to be removed
+ permanent(boolean): True|False
+ Return:
+ bool: True|False(Firewall removed or Failed)
+ """
+
+ if isinstance(nodes, str):
+ nodes = [nodes]
+
+ if isinstance(firewall_service, str):
+ firewall_service = [firewall_service]
+
+ _rc = True
+ if is_rhel7(nodes):
+ for service in firewall_service:
+ cmd = ("firewall-cmd --zone=public " + "--remove-service=" +
+ service)
+ results = g.run_parallel(nodes, cmd)
+ # Check for return status
+ for host in results:
+ ret, _, _ = results[host]
+ if ret != 0:
+ g.log.error("Failed to remove firewall")
+ _rc = False
+ if permanent and _rc:
+ for service in firewall_service:
+ cmd = ("firewall-cmd --zone=public " + "--remove-service=" +
+ service + " --permanent")
+ results = g.run_parallel(nodes, cmd)
+ # Check for return status
+ for host in results:
+ ret, _, _ = results[host]
+ if ret != 0:
+ g.log.error("Failed to remove firewall pemanently")
+ _rc = False
+
+ return _rc