summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/plugins/update_ca_topology.py
blob: e49f358838abec22fe574ff6ef6449d4984a9db6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#
# Copyright (C) 2015  FreeIPA Contributors see COPYING for license
#

from ipalib import errors
from ipalib import Registry
from ipalib import Updater
from ipapython.dn import DN
from ipaserver.install import cainstance
from ipaserver.install import ldapupdate
from ipaplatform.paths import paths

register = Registry()


@register()
class update_ca_topology(Updater):
    """
    Updates CA topology configuration entries
    """

    def execute(self, **options):

        ca = cainstance.CAInstance(self.api.env.realm)
        if not ca.is_configured():
            self.log.debug("CA is not configured on this host")
            return False, []

        ld = ldapupdate.LDAPUpdate(ldapi=True, sub_dict={
            'SUFFIX': self.api.env.basedn,
            'FQDN': self.api.env.host,
        })

        ld.update([paths.CA_TOPOLOGY_ULDIF])

        ldap = self.api.Backend.ldap2

        ca_replica_dn = DN(
            ('cn', 'replica'),
            ('cn', 'o=ipaca'),
            ('cn', 'mapping tree'),
            ('cn', 'config'))

        check_interval_attr = 'nsds5replicabinddngroupcheckinterval'
        default_check_interval = ['60']

        try:
            ca_replica_entry = ldap.get_entry(ca_replica_dn)
        except errors.NotFound:
            pass
        else:
            if check_interval_attr not in ca_replica_entry:
                ca_replica_entry[check_interval_attr] = default_check_interval
                ldap.update_entry(ca_replica_entry)

        return False, []