This is required by DNSSEC installer

Patch attached

--
Martin Basti

From 57a1beb4a3f554d65a6f9734e0a3b6b4856c5092 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Mon, 1 Sep 2014 10:49:28 +0200
Subject: [PATCH] Add mask, unmask methods for service

This patch allows mask and unmask services in IPA
---
 ipaplatform/base/services.py | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py
index ea066b283d776ba3ff555d050a830c6d8ecc60cc..2dc8b778ec811b12b50fe7fc801145a577408f4e 100644
--- a/ipaplatform/base/services.py
+++ b/ipaplatform/base/services.py
@@ -327,6 +327,21 @@ class SystemdService(PlatformService):
                 enabled = False
         return enabled
 
+    def is_masked(self, instance_name=""):
+        masked = False
+        try:
+            (sout, serr, rcode) = ipautil.run(
+                                      [paths.SYSTEMCTL,
+                                       "is-enabled",
+                                        self.service_instance(instance_name)])
+
+            if rcode == 1 and sout == 'masked':
+                masked = True
+
+        except ipautil.CalledProcessError:
+                pass
+        return masked
+
     def enable(self, instance_name=""):
         if self.lib_path_exists is None:
             self.lib_path_exists = os.path.exists(self.lib_path)
@@ -402,6 +417,18 @@ class SystemdService(PlatformService):
         else:
             self.__disable(instance_name)
 
+    def mask(self, instance_name=""):
+        if instance_name != "":
+            srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, instance_name)
+            # remove instance file or link before masking
+            if os.path.islink(srv_tgt):
+                os.unlink(srv_tgt)
+
+        self.__mask(instance_name)
+
+    def unmask(self, instance_name=""):
+        self.__unmask(instance_name)
+
     def __enable(self, instance_name=""):
         try:
             ipautil.run([paths.SYSTEMCTL, "enable",
@@ -416,6 +443,20 @@ class SystemdService(PlatformService):
         except ipautil.CalledProcessError:
             pass
 
+    def __mask(self, instance_name=""):
+        try:
+            ipautil.run([paths.SYSTEMCTL, "mask",
+                         self.service_instance(instance_name)])
+        except ipautil.CalledProcessError:
+            pass
+
+    def __unmask(self, instance_name=""):
+        try:
+            ipautil.run([paths.SYSTEMCTL, "unmask",
+                         self.service_instance(instance_name)])
+        except ipautil.CalledProcessError:
+            pass
+
     def install(self):
         self.enable()
 
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to