2014-05-26 09:40:18 -05:00
|
|
|
# Author: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
|
# Tomas Babej <tbabej@redhat.com>
|
2014-05-26 09:38:25 -05:00
|
|
|
#
|
2014-05-26 09:40:18 -05:00
|
|
|
# Copyright (C) 2011-2014 Red Hat
|
2014-05-26 09:38:25 -05:00
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
"""
|
|
|
|
Contains Fedora-specific service class implementations.
|
|
|
|
"""
|
2014-05-26 09:40:18 -05:00
|
|
|
|
2018-04-05 02:21:16 -05:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-08-29 05:58:12 -05:00
|
|
|
from ipaplatform.osinfo import osinfo
|
2014-10-03 04:14:56 -05:00
|
|
|
from ipaplatform.redhat import services as redhat_services
|
2014-05-26 09:40:18 -05:00
|
|
|
|
|
|
|
# Mappings from service names as FreeIPA code references to these services
|
|
|
|
# to their actual systemd service names
|
2016-11-16 03:39:05 -06:00
|
|
|
fedora_system_units = redhat_services.redhat_system_units.copy()
|
2014-05-26 09:40:18 -05:00
|
|
|
|
2018-06-11 03:09:51 -05:00
|
|
|
# Fedora 28 and earlier have fedora-domainname.service. Starting from
|
|
|
|
# Fedora 29, the service is called nis-domainname.service as defined in
|
|
|
|
# ipaplatform.redhat.services.
|
2019-02-26 06:59:06 -06:00
|
|
|
HAS_FEDORA_DOMAINNAME_SERVICE = osinfo.version_number <= (28,)
|
2018-06-11 03:09:51 -05:00
|
|
|
|
|
|
|
if HAS_FEDORA_DOMAINNAME_SERVICE:
|
|
|
|
fedora_system_units['domainname'] = 'fedora-domainname.service'
|
2014-05-26 09:40:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Service classes that implement Fedora-specific behaviour
|
|
|
|
|
2014-10-03 04:14:56 -05:00
|
|
|
class FedoraService(redhat_services.RedHatService):
|
|
|
|
system_units = fedora_system_units
|
2014-05-26 09:40:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Function that constructs proper Fedora-specific server classes for services
|
|
|
|
# of specified name
|
|
|
|
|
2016-11-18 08:42:23 -06:00
|
|
|
def fedora_service_class_factory(name, api=None):
|
2018-06-11 03:09:51 -05:00
|
|
|
if HAS_FEDORA_DOMAINNAME_SERVICE and name == 'domainname':
|
2016-11-18 08:42:23 -06:00
|
|
|
return FedoraService(name, api)
|
|
|
|
return redhat_services.redhat_service_class_factory(name, api)
|
2014-05-26 09:40:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Magicdict containing FedoraService instances.
|
|
|
|
|
2014-10-03 04:14:56 -05:00
|
|
|
class FedoraServices(redhat_services.RedHatServices):
|
2016-11-18 08:42:23 -06:00
|
|
|
def service_class_factory(self, name, api=None):
|
|
|
|
return fedora_service_class_factory(name, api)
|
2014-05-26 09:40:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Objects below are expected to be exported by platform module
|
|
|
|
|
2015-12-16 09:10:03 -06:00
|
|
|
timedate_services = redhat_services.timedate_services
|
2014-05-26 09:40:18 -05:00
|
|
|
service = fedora_service_class_factory
|
|
|
|
knownservices = FedoraServices()
|