Imported Debian patch 4.0.5-6~numeezy

This commit is contained in:
Alexandre Ellert
2016-02-17 15:07:45 +01:00
committed by Mario Fetka
parent c44de33144
commit 10dfc9587b
1203 changed files with 53869 additions and 241462 deletions

View File

@@ -20,27 +20,30 @@
import os
import pwd
from ipapython import ipaldap
from ipaserver.install.plugins import MIDDLE
from ipaserver.install.plugins.baseupdate import PreUpdate
from ipaserver.install import replication
from ipalib import api
from ipalib import Updater
EXCLUDE_TEMPLATE = '(objectclass=*) $ EXCLUDE %s'
class update_replica_attribute_lists(Updater):
class update_replica_attribute_lists(PreUpdate):
"""
Run through all replication agreements and ensure that EXCLUDE list
has all the required attributes so that we don't cause replication
storms.
"""
order = MIDDLE
def execute(self, **options):
# We need an IPAdmin connection to the backend
self.log.debug("Start replication agreement exclude list update task")
conn = self.api.Backend.ldap2
conn = ipaldap.IPAdmin(api.env.host, ldapi=True, realm=api.env.realm)
conn.do_external_bind(pwd.getpwuid(os.geteuid()).pw_name)
repl = replication.ReplicationManager(self.api.env.realm,
self.api.env.host,
repl = replication.ReplicationManager(api.env.realm, api.env.host,
None, conn=conn)
# We need to update only IPA replica agreements, not winsync
@@ -49,8 +52,7 @@ class update_replica_attribute_lists(Updater):
self.log.debug("Found %d agreement(s)", len(ipa_replicas))
for replica in ipa_replicas:
for desc in replica.get('description', []):
self.log.debug(desc)
self.log.debug(replica.single_value.get('description'))
self._update_attr(repl, replica,
'nsDS5ReplicatedAttributeList',
@@ -63,7 +65,7 @@ class update_replica_attribute_lists(Updater):
self.log.debug("Done updating agreements")
return False, [] # No restart, no updates
return (False, False, []) # No restart, no apply now, no updates
def _update_attr(self, repl, replica, attribute, values, template='%s'):
"""Add or update an attribute of a replication agreement
@@ -89,7 +91,7 @@ class update_replica_attribute_lists(Updater):
try:
repl.conn.update_entry(replica)
self.log.debug("Updated")
except Exception as e:
except Exception, e:
self.log.error("Error caught updating replica: %s", str(e))
else:
@@ -107,7 +109,7 @@ class update_replica_attribute_lists(Updater):
try:
repl.conn.update_entry(replica)
self.log.debug("Updated %s", attribute)
except Exception as e:
except Exception, e:
self.log.error("Error caught updating %s: %s",
attribute, str(e))
else: