summaryrefslogtreecommitdiffstats
path: root/ipapython/platform/base.py
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2012-10-22 20:48:25 -0400
committerRob Crittenden <rcritten@redhat.com>2012-11-01 10:58:37 -0400
commitf5805379277d0d9a2685aba69db49c95a36a6d1f (patch)
tree98124ece6b73f28c24423070d9c86fdd46eee082 /ipapython/platform/base.py
parent5d2a8e8b225766d6e6ee53d4c161c4c1b44ab74a (diff)
downloadfreeipa.git-f5805379277d0d9a2685aba69db49c95a36a6d1f.tar.gz
freeipa.git-f5805379277d0d9a2685aba69db49c95a36a6d1f.tar.xz
freeipa.git-f5805379277d0d9a2685aba69db49c95a36a6d1f.zip
Save service name on service startup
This is done as a default action of the ancestor class so that no matter what platform is currently used this code is always the same and the name is the wellknown service name. This information will be used by ipacl to stop only and all the services that have been started by any ipa tool/install script
Diffstat (limited to 'ipapython/platform/base.py')
-rw-r--r--ipapython/platform/base.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/ipapython/platform/base.py b/ipapython/platform/base.py
index 2d39d216..1101b5cd 100644
--- a/ipapython/platform/base.py
+++ b/ipapython/platform/base.py
@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ipalib.plugable import MagicDict
+import json
+import os
# Canonical names of services as IPA wants to see them. As we need to have
# *some* naming, set them as in Red Hat distributions. Actual implementation
@@ -40,6 +42,8 @@ wellknownports = {
'pki-tomcatd': [8080, 8443], # used if the incoming instance name is blank
}
+SVC_LIST_FILE = "/var/run/ipa/services.list"
+
class AuthConfig(object):
"""
AuthConfig class implements system-independent interface to configure
@@ -133,6 +137,25 @@ class PlatformService(object):
self.service_name = service_name
def start(self, instance_name="", capture_output=True, wait=True):
+ """
+ When a service is started record the fact in a special file.
+ This allows ipactl stop to always stop all services that have
+ been started via ipa tools
+ """
+ svc_list = []
+ try:
+ f = open(SVC_LIST_FILE, 'r')
+ svc_list = json.load(f)
+ except Exception:
+ # not fatal, may be the first service
+ pass
+
+ svc_list.append(self.service_name)
+
+ f = open(SVC_LIST_FILE, 'w')
+ json.dump(svc_list, f)
+ f.flush()
+ f.close()
return
def stop(self, instance_name="", capture_output=True):