Imported Upstream version 4.3.1
This commit is contained in:
@@ -17,13 +17,13 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import logging
|
||||
import pprint
|
||||
|
||||
import ldap.schema
|
||||
|
||||
import ipapython.version
|
||||
from ipalib import api
|
||||
from ipapython.ipa_log_manager import log_mgr
|
||||
from ipapython.dn import DN
|
||||
from ipaserver.install.ldapupdate import connect
|
||||
from ipaserver.install import installutils
|
||||
@@ -38,7 +38,7 @@ SCHEMA_ELEMENT_CLASSES = (
|
||||
|
||||
ORIGIN = 'IPA v%s' % ipapython.version.VERSION
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
log = log_mgr.get_logger(__name__)
|
||||
|
||||
|
||||
def _get_oid_dependency_order(schema, cls):
|
||||
@@ -119,14 +119,13 @@ def update_schema(schema_files, ldapi=False, dm_password=None,):
|
||||
|
||||
# The exact representation the DS gives us for each OID
|
||||
# (for debug logging)
|
||||
old_entries_by_oid = {cls(attr).oid: attr.decode('utf-8')
|
||||
old_entries_by_oid = {cls(str(attr)).oid: str(attr)
|
||||
for (attrname, cls) in SCHEMA_ELEMENT_CLASSES
|
||||
for attr in schema_entry[attrname]}
|
||||
|
||||
for filename in schema_files:
|
||||
logger.debug('Processing schema LDIF file %s', filename)
|
||||
url = "file://{}".format(filename)
|
||||
_dn, new_schema = ldap.schema.subentry.urlfetch(url)
|
||||
log.debug('Processing schema LDIF file %s', filename)
|
||||
dn, new_schema = ldap.schema.subentry.urlfetch(filename)
|
||||
|
||||
for attrname, cls in SCHEMA_ELEMENT_CLASSES:
|
||||
for oids_set in _get_oid_dependency_order(new_schema, cls):
|
||||
@@ -144,15 +143,14 @@ def update_schema(schema_files, ldapi=False, dm_password=None,):
|
||||
# Note: An add will automatically replace any existing
|
||||
# schema with the same OID. So, we only add.
|
||||
value = add_x_origin(new_obj)
|
||||
new_elements.append(value)
|
||||
|
||||
if old_obj:
|
||||
old_attr = old_entries_by_oid.get(oid)
|
||||
logger.debug('Replace: %s', old_attr)
|
||||
logger.debug(' with: %s', value)
|
||||
log.debug('Replace: %s', old_attr)
|
||||
log.debug(' with: %s', value)
|
||||
else:
|
||||
logger.debug('Add: %s', value)
|
||||
|
||||
new_elements.append(value.encode('utf-8'))
|
||||
log.debug('Add: %s', value)
|
||||
|
||||
modified = modified or new_elements
|
||||
schema_entry[attrname].extend(new_elements)
|
||||
@@ -161,12 +159,11 @@ def update_schema(schema_files, ldapi=False, dm_password=None,):
|
||||
# so updates must be executed with groups of independent OIDs
|
||||
if new_elements:
|
||||
modlist = schema_entry.generate_modlist()
|
||||
logger.debug("Schema modlist:\n%s",
|
||||
pprint.pformat(modlist))
|
||||
log.debug("Schema modlist:\n%s", pprint.pformat(modlist))
|
||||
conn.update_entry(schema_entry)
|
||||
|
||||
if not modified:
|
||||
logger.debug('Not updating schema')
|
||||
log.debug('Not updating schema')
|
||||
|
||||
return modified
|
||||
|
||||
|
||||
Reference in New Issue
Block a user