da97433d5cd26e422a370d186f98659383c06721csovant# CDDL HEADER START
da97433d5cd26e422a370d186f98659383c06721csovant# The contents of this file are subject to the terms of the
da97433d5cd26e422a370d186f98659383c06721csovant# Common Development and Distribution License, Version 1.0 only
da97433d5cd26e422a370d186f98659383c06721csovant# (the "License"). You may not use this file except in compliance
da97433d5cd26e422a370d186f98659383c06721csovant# with the License.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac# You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
da97433d5cd26e422a370d186f98659383c06721csovant# See the License for the specific language governing permissions
da97433d5cd26e422a370d186f98659383c06721csovant# and limitations under the License.
da97433d5cd26e422a370d186f98659383c06721csovant# When distributing Covered Code, include this CDDL HEADER in each
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac# file and include the License file at legal-notices/CDDLv1_0.txt.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac# If applicable, add the following below this CDDL HEADER, with the
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac# fields enclosed by brackets "[]" replaced with your own identifying
da97433d5cd26e422a370d186f98659383c06721csovant# information:
da97433d5cd26e422a370d186f98659383c06721csovant# Portions Copyright [yyyy] [name of copyright owner]
da97433d5cd26e422a370d186f98659383c06721csovant# CDDL HEADER END
da97433d5cd26e422a370d186f98659383c06721csovant# Copyright 2009 Sun Microsystems, Inc.
da97433d5cd26e422a370d186f98659383c06721csovant# Global variable containing the list of servers ("Server" class instances) deployed
da97433d5cd26e422a370d186f98659383c06721csovant# Define ChangelogServer class
da97433d5cd26e422a370d186f98659383c06721csovant """OIDDict is a dictionary class that help lookup OID <-> litteral name
da97433d5cd26e422a370d186f98659383c06721csovant of both objeclasses, and attributtypes"""
da97433d5cd26e422a370d186f98659383c06721csovant """given a schema entry definition for objectclass/attributtype
da97433d5cd26e422a370d186f98659383c06721csovant return the tuple (OID,List of names)
da97433d5cd26e422a370d186f98659383c06721csovant the List of aliases starts from list of names[1:] when exist. for ex :
da97433d5cd26e422a370d186f98659383c06721csovant attributeTypes: ( 2.5.4.4 NAME ( 'sn' 'surname' ) SUP name X-ORIGIN 'RFC 4519' )
da97433d5cd26e422a370d186f98659383c06721csovant (2.5.4.4,['sn','surname']
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant More details : https://www.opends.org/wiki/page/AttributeTypeDescriptionFormat
da97433d5cd26e422a370d186f98659383c06721csovant # populate the NAME to OID : "dict" dictionary
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant # TODO encoded schema is not handled for now
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant # TODO encoded schema is not handled for now
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant # populate SUP and MUST / MAY, : "sup", "may", "must" dictionaries
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant for m in r:
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant for m in r:
da97433d5cd26e422a370d186f98659383c06721csovant """extract a list of attributes for a given myStr section.
da97433d5cd26e422a370d186f98659383c06721csovant The section should contain () when multivalued.
da97433d5cd26e422a370d186f98659383c06721csovant If another section comes after it starts with a Upercase.
da97433d5cd26e422a370d186f98659383c06721csovant example MUST (sn cn) MAY ( description ... )
da97433d5cd26e422a370d186f98659383c06721csovant line : line to parse
da97433d5cd26e422a370d186f98659383c06721csovant myStr : name of the section ex(MAY)
da97433d5cd26e422a370d186f98659383c06721csovant right : right boundary,
da97433d5cd26e422a370d186f98659383c06721csovant if None, function will figure out end of section"""
da97433d5cd26e422a370d186f98659383c06721csovant return None
da97433d5cd26e422a370d186f98659383c06721csovant """will return the attributes the objectclassname MUST implement"""
da97433d5cd26e422a370d186f98659383c06721csovant # avoiding duplication of MUSTs
da97433d5cd26e422a370d186f98659383c06721csovant ret.extend([e for e in self.getMust(h) if ret.count(e) == 0])
da97433d5cd26e422a370d186f98659383c06721csovant """will return the attributes the objectclassname MAY implement"""
da97433d5cd26e422a370d186f98659383c06721csovant # avoiding duplication of MAYs
da97433d5cd26e422a370d186f98659383c06721csovant ret.extend([e for e in self.getMay(h) if ret.count(e) == 0])
da97433d5cd26e422a370d186f98659383c06721csovant """will return the objectclassname that this objectclassname inherit"""
da97433d5cd26e422a370d186f98659383c06721csovant return None
da97433d5cd26e422a370d186f98659383c06721csovant """get the schema as a string
da97433d5cd26e422a370d186f98659383c06721csovant lookit up line by line, extracting OID/literal name for objectclasses
da97433d5cd26e422a370d186f98659383c06721csovant and attributetypes only."""
da97433d5cd26e422a370d186f98659383c06721csovant # not handled for now
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant elif len(line) > 0 and len(f) > 0 and f[0].isspace():
da97433d5cd26e422a370d186f98659383c06721csovant # line continuation aggregated into 'line'
da97433d5cd26e422a370d186f98659383c06721csovant elif f.startswith("objectClasses") or f.startswith("attributeTypes"):
da97433d5cd26e422a370d186f98659383c06721csovant # populate the OID <-> Names dictionary
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant # parsing the last line
da97433d5cd26e422a370d186f98659383c06721csovant """get example schema.ldif file with :
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant ldapsearch -b 'cn=schema' -Dcn=directory\ manager -s base -wpassword objectclass=* objectClasses attributeTypes > /tmp/schema.ldif
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant print '[ Objectclasses dictionary ]'.center(80, '-')
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant print "%s\t%s"%(k,v)
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant print '[ AttributeTypes dictionary ]'.center(80, '-')
da97433d5cd26e422a370d186f98659383c06721csovant print "%s\t%s"%(k,v)
da97433d5cd26e422a370d186f98659383c06721csovant print "%s\t%s"%(k,v)
da97433d5cd26e422a370d186f98659383c06721csovant print "%s\t%s"%(k,v)
da97433d5cd26e422a370d186f98659383c06721csovant print "%s\t%s"%(k,v)
da97433d5cd26e422a370d186f98659383c06721csovant for cn in ['rFC822LocalPart','inetOrgPerson','top','doMain','2.5.6.7','BLAH']:
28eeffb99d4c7f8ff501c22d1d21501cbfe3ad32csovant print 'got %s MUSTs size = %sKb' % (len(oidDict.allmust),mustSize/1024.0)