Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 950111 Details for
Bug 1044179
objectclass may, must lists skip rest of objectclass once first is found in sup
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
compareschema.py
compareschema.py (text/python), 4.98 KB, created by
Rich Megginson
on 2014-10-23 22:36:49 UTC
(
hide
)
Description:
compareschema.py
Filename:
MIME Type:
Creator:
Rich Megginson
Created:
2014-10-23 22:36:49 UTC
Size:
4.98 KB
patch
obsolete
> >import ldap >from ldap.cidict import cidict >from ldap.schema import SubSchema >import ldif >import sys >import pprint > >attrclass = ldap.schema.models.AttributeType >occlass = ldap.schema.models.ObjectClass > >def ochasattr(subschema, oc, mustormay, attr, key): > """See if the oc and any of its parents and ancestors have the > given attr""" > rc = False > if not key in oc.__dict__: > dd = cidict() > for ii in oc.__dict__[mustormay]: > dd[ii] = ii > oc.__dict__[key] = dd > if attr in oc.__dict__[key]: > rc = True > else: > # look in parents > for noroid in oc.sup: > ocpar = subschema.get_obj(occlass, noroid) > assert(ocpar) > rc = ochasattr(subschema, ocpar, mustormay, attr, key) > if rc: > break > return rc > >def ochasattrs(subschema, oc, mustormay, attrs): > key = mustormay + "dict" > ret = [] > for attr in attrs: > if not ochasattr(subschema, oc, mustormay, attr, key): > ret.append(attr) > return ret > >def mycmp(v1, v2): > v1ary, v2ary = [v1], [v2] > if isinstance(v1, list) or isinstance(v1, tuple): > v1ary, v2ary = list(set([x.lower() for x in v1])), list(set([x.lower() for x in v2])) > if not len(v1ary) == len(v2ary): > return False > for v1, v2 in zip(v1ary, v2ary): > if isinstance(v1, basestring): > if not len(v1) == len(v2): > return False > if not v1 == v2: > return False > return True > >def ocgetdiffs(ldschema, oc1, oc2): > fields = ['obsolete', 'names', 'desc', 'must', 'may', 'kind', 'sup'] > ret = '' > for field in fields: > v1, v2 = oc1.__dict__[field], oc2.__dict__[field] > if field == 'may' or field == 'must': > missing = ochasattrs(ldschema, oc1, field, oc2.__dict__[field]) > if missing: > ret = ret + '\t%s is missing %s\n' % (field, missing) > missing = ochasattrs(ldschema, oc2, field, oc1.__dict__[field]) > if missing: > ret = ret + '\t%s is missing %s\n' % (field, missing) > elif not mycmp(v1, v2): > ret = ret + '\t%s differs: [%s] vs. [%s]\n' % (field, oc1.__dict__[field], oc2.__dict__[field]) > return ret > >def atgetparfield(subschema, at, field): > v = None > for nameoroid in at.sup: > atpar = subschema.get_obj(attrclass, nameoroid) > assert(atpar) > v = atpar.__dict__.get(field, atgetparfield(subschema, atpar, field)) > if v is not None: > break > return v > >def atgetdiffs(ldschema, at1, at2): ># fields = ['names', 'desc', 'obsolete', 'sup', 'equality', 'ordering', 'substr', 'syntax', 'syntax_len', 'single_value', 'collective', 'no_user_mod', 'usage'] > fields = ['names', 'desc', 'obsolete', 'sup', 'equality', 'ordering', 'substr', 'syntax', 'single_value', 'collective', 'no_user_mod', 'usage'] > ret = '' > for field in fields: > v1 = at1.__dict__.get(field) or atgetparfield(ldschema, at1, field) > v2 = at2.__dict__.get(field) or atgetparfield(ldschema, at2, field) > if not mycmp(v1, v2): > ret = ret + '\t%s differs: [%s] vs. [%s]\n' % (field, at1.__dict__[field], at2.__dict__[field]) > return ret > ># read and parse each schema file given on the command line >allattrs = ldap.cidict.cidict() >dupattrs = ldap.cidict.cidict() >allocs = ldap.cidict.cidict() >dupocs = ldap.cidict.cidict() >alloids = {} >dupoids = {} > ># these are schema elements present in files but missing from ldap >missingfromld = [] ># these are schema elements present in ldap but missing from files >missingfromfiles = [] ># these are schema elements which differ ># key is oid - val is a list - 0 is ld version, 1 is file version >atdiffs = {} >ocdiffs = {} > >dn, ldschema = ldap.schema.subentry.urlfetch(sys.argv[1]) >retval = 0 >for myfile in sys.argv[2:]: > try: > dn, sc = ldap.schema.subentry.urlfetch(myfile) > except IndexError: > print "skipping file due to parsing errors", myfile > continue > for oid in sc.listall(occlass): > se = sc.get_obj(occlass, oid) > assert(se) > ldse = ldschema.get_obj(occlass, oid) > if not ldse: > print "objectclass in %s but not in %s: %s" % (myfile, sys.argv[1], se) > missingfromld.append(se) > retval = 1 > continue > ret = ocgetdiffs(ldschema, ldse, se) > if ret: > sys.stdout.write("name %s oid %s\n%s" % (se.names[0], oid, ret)) > ocdiffs[oid] = [se, ldse] > retval = 1 > for oid in sc.listall(attrclass): > se = sc.get_obj(attrclass, oid) > assert(se) > ldse = ldschema.get_obj(attrclass, oid) > if not ldse: > print "attributetype in %s but not in %s: %s" % (myfile, sys.argv[1], se) > missingfromld.append(se) > retval = 1 > continue > ret = atgetdiffs(ldschema, ldse, se) > if ret: > sys.stdout.write("name %s oid %s\n%s" % (se.names[0], oid, ret)) > atdiffs[oid] = [se, ldse] > retval = 1 > >sys.exit(retval)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1044179
:
950111
|
979340