mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
parent
09dbc1f36b
commit
1ef651e7f9
@ -17,6 +17,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from ipalib.plugable import MagicDict
|
from ipalib.plugable import MagicDict
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
# Canonical names of services as IPA wants to see them. As we need to have
|
# 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
|
# *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
|
'pki-tomcatd': [8080, 8443], # used if the incoming instance name is blank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SVC_LIST_FILE = "/var/run/ipa/services.list"
|
||||||
|
|
||||||
class AuthConfig(object):
|
class AuthConfig(object):
|
||||||
"""
|
"""
|
||||||
AuthConfig class implements system-independent interface to configure
|
AuthConfig class implements system-independent interface to configure
|
||||||
@ -133,6 +137,25 @@ class PlatformService(object):
|
|||||||
self.service_name = service_name
|
self.service_name = service_name
|
||||||
|
|
||||||
def start(self, instance_name="", capture_output=True, wait=True):
|
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
|
return
|
||||||
|
|
||||||
def stop(self, instance_name="", capture_output=True):
|
def stop(self, instance_name="", capture_output=True):
|
||||||
|
@ -71,6 +71,7 @@ class RedHatService(base.PlatformService):
|
|||||||
ipautil.run(["/sbin/service", self.service_name, "start", instance_name], capture_output=capture_output)
|
ipautil.run(["/sbin/service", self.service_name, "start", instance_name], capture_output=capture_output)
|
||||||
if wait and self.is_running(instance_name):
|
if wait and self.is_running(instance_name):
|
||||||
self.__wait_for_open_ports(instance_name)
|
self.__wait_for_open_ports(instance_name)
|
||||||
|
super(RedHatService, self).start(instance_name)
|
||||||
|
|
||||||
def restart(self, instance_name="", capture_output=True, wait=True):
|
def restart(self, instance_name="", capture_output=True, wait=True):
|
||||||
ipautil.run(["/sbin/service", self.service_name, "restart", instance_name], capture_output=capture_output)
|
ipautil.run(["/sbin/service", self.service_name, "restart", instance_name], capture_output=capture_output)
|
||||||
|
@ -96,6 +96,7 @@ class SystemdService(base.PlatformService):
|
|||||||
ipautil.run(["/bin/systemctl", "start", self.service_instance(instance_name)], capture_output=capture_output)
|
ipautil.run(["/bin/systemctl", "start", self.service_instance(instance_name)], capture_output=capture_output)
|
||||||
if wait and self.is_running(instance_name):
|
if wait and self.is_running(instance_name):
|
||||||
self.__wait_for_open_ports(self.service_instance(instance_name))
|
self.__wait_for_open_ports(self.service_instance(instance_name))
|
||||||
|
super(SystemdService, self).start(instance_name)
|
||||||
|
|
||||||
def restart(self, instance_name="", capture_output=True, wait=True):
|
def restart(self, instance_name="", capture_output=True, wait=True):
|
||||||
# Restart command is broken before systemd-36-3.fc16
|
# Restart command is broken before systemd-36-3.fc16
|
||||||
|
@ -51,4 +51,8 @@ backup_and_replace_hostname = backup_and_replace_hostname_default
|
|||||||
def check_selinux_status():
|
def check_selinux_status():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
from ipapython.platform.base import SVC_LIST_FILE
|
||||||
|
def get_svc_list_file():
|
||||||
|
return SVC_LIST_FILE
|
||||||
|
|
||||||
from ipapython.platform.SUPPORTED_PLATFORM import *
|
from ipapython.platform.SUPPORTED_PLATFORM import *
|
||||||
|
Loading…
Reference in New Issue
Block a user