mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-29 10:21:18 -06:00
2f4b3972a0
There are two reasons for the plugin framework: 1. To provide a way of doing manual/complex LDAP changes without having to keep extending ldapupdate.py (like we did with managed entries). 2. Allows for better control of restarts. There are two types of plugins, preop and postop. A preop plugin runs before any file-based updates are loaded. A postop plugin runs after all file-based updates are applied. A preop plugin may update LDAP directly or craft update entries to be applied with the file-based updates. Either a preop or postop plugin may attempt to restart the dirsrv instance. The instance is only restartable if ipa-ldap-updater is being executed as root. A warning is printed if a restart is requested for a non-root user. Plugins are not executed by default. This is so we can use ldapupdate to apply simple updates in commands like ipa-nis-manage. https://fedorahosted.org/freeipa/ticket/1789 https://fedorahosted.org/freeipa/ticket/1790 https://fedorahosted.org/freeipa/ticket/2032
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
# Authors:
|
|
# Rob Crittenden <rcritten@redhat.com>
|
|
#
|
|
# Copyright (C) 2011 Red Hat
|
|
# 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/>.
|
|
|
|
from ipalib import api
|
|
from ipalib import errors
|
|
from ipalib import Updater, Object
|
|
from ipaserver.install import service
|
|
from ipaserver.install.plugins import PRE_UPDATE, POST_UPDATE, MIDDLE
|
|
|
|
class DSRestart(service.Service):
|
|
"""
|
|
Restart the 389-ds service.
|
|
"""
|
|
def __init__(self):
|
|
"""
|
|
This class is present to provide ldapupdate the means to
|
|
restart 389-ds.
|
|
"""
|
|
service.Service.__init__(self, "dirsrv")
|
|
|
|
def create_instance(self):
|
|
self.step("stopping directory server", self.stop)
|
|
self.step("starting directory server", self.start)
|
|
self.start_creation("Restarting Directory server to apply updates")
|
|
|
|
class update(Object):
|
|
"""
|
|
Generic object used to register all updates into a single namespace.
|
|
"""
|
|
backend_name = 'ldap2'
|
|
|
|
api.register(update)
|
|
|
|
class PreUpdate(Updater):
|
|
"""
|
|
Base class for updates that run prior to file processing.
|
|
"""
|
|
updatetype = PRE_UPDATE
|
|
order = MIDDLE
|
|
|
|
def __init__(self):
|
|
super(PreUpdate, self).__init__()
|
|
|
|
class PostUpdate(Updater):
|
|
"""
|
|
Base class for updates that run after file processing.
|
|
"""
|
|
updatetype = POST_UPDATE
|
|
order = MIDDLE
|
|
|
|
def __init__(self):
|
|
super(PostUpdate, self).__init__()
|