diff options
author | Simo Sorce <ssorce@redhat.com> | 2012-10-22 20:48:24 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-11-01 10:58:19 -0400 |
commit | 09dbc1f36bbc14c1224e45778cbc59586dfeea75 (patch) | |
tree | 492bae279e81d5214832bd8c1f1d2c3af7dc3617 /ipapython/platform/systemd.py | |
parent | 3d7ff982ec281935ca3c2b55eea03a08723fe1e2 (diff) | |
download | freeipa.git-09dbc1f36bbc14c1224e45778cbc59586dfeea75.tar.gz freeipa.git-09dbc1f36bbc14c1224e45778cbc59586dfeea75.tar.xz freeipa.git-09dbc1f36bbc14c1224e45778cbc59586dfeea75.zip |
Preserve original service_name in services
This is needed to be able to reference stuff always wth the same name.
The platform specific private name must be kept in a platform specific
variable.
In the case of systemd we store it in systemd_name
For the redhat platform wellknown names and service name are the same so
currently no special name is needed.
Diffstat (limited to 'ipapython/platform/systemd.py')
-rw-r--r-- | ipapython/platform/systemd.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ipapython/platform/systemd.py b/ipapython/platform/systemd.py index c174488c..6c25a79b 100644 --- a/ipapython/platform/systemd.py +++ b/ipapython/platform/systemd.py @@ -27,25 +27,26 @@ class SystemdService(base.PlatformService): SYSTEMD_LIB_PATH = "/lib/systemd/system/" SYSTEMD_SRV_TARGET = "%s.target.wants" - def __init__(self, service_name): + def __init__(self, service_name, systemd_name): super(SystemdService, self).__init__(service_name) - self.lib_path = os.path.join(self.SYSTEMD_LIB_PATH, self.service_name) + self.systemd_name = systemd_name + self.lib_path = os.path.join(self.SYSTEMD_LIB_PATH, self.systemd_name) self.lib_path_exists = None def service_instance(self, instance_name): if self.lib_path_exists is None: self.lib_path_exists = os.path.exists(self.lib_path) - elements = self.service_name.split("@") + elements = self.systemd_name.split("@") # Short-cut: if there is already exact service name, return it if self.lib_path_exists and len(instance_name) == 0: if len(elements) == 1: # service name is like pki-tomcatd.target or krb5kdc.service - return self.service_name + return self.systemd_name if len(elements) > 1 and elements[1][0] != '.': # Service name is like pki-tomcatd@pki-tomcat.service and that file exists - return self.service_name + return self.systemd_name if len(elements) > 1: # We have dynamic service @@ -59,7 +60,7 @@ class SystemdService(base.PlatformService): if os.path.exists(srv_lib): return tgt_name - return self.service_name + return self.systemd_name def parse_variables(self, text, separator=None): """ @@ -82,7 +83,7 @@ class SystemdService(base.PlatformService): if instance_name in base.wellknownports: ports = base.wellknownports[instance_name] else: - elements = self.service_name.split("@") + elements = self.systemd_name.split("@") if elements[0] in base.wellknownports: ports = base.wellknownports[elements[0]] if ports: @@ -141,7 +142,7 @@ class SystemdService(base.PlatformService): def enable(self, instance_name=""): if self.lib_path_exists is None: self.lib_path_exists = os.path.exists(self.lib_path) - elements = self.service_name.split("@") + elements = self.systemd_name.split("@") l = len(elements) if self.lib_path_exists and (l > 1 and elements[1][0] != '.'): @@ -183,7 +184,7 @@ class SystemdService(base.PlatformService): self.__enable(instance_name) def disable(self, instance_name=""): - elements = self.service_name.split("@") + elements = self.systemd_name.split("@") if instance_name != "" and len(elements) > 1: # Remove instance, we need to do following: # Remove link from /etc/systemd/system/<service>.target.wants/<service>@<instance_name>.service |