schema.py revision 4974
4865N/A# The contents of this file are subject to the terms of the 4865N/A# Common Development and Distribution License, Version 1.0 only 4865N/A# (the "License"). You may not use this file except in compliance 4865N/A# You can obtain a copy of the license at 4865N/A# See the License for the specific language governing permissions 4865N/A# and limitations under the License. 4865N/A# When distributing Covered Code, include this CDDL HEADER in each 4865N/A# file and include the License file at 4865N/A# add the following below this CDDL HEADER, with the fields enclosed 4865N/A# Portions Copyright [yyyy] [name of copyright owner] 4865N/A# Copyright 2009 Sun Microsystems, Inc. 4865N/A# Global variable containing the list of servers ("Server" class instances) deployed 4865N/A# Define ChangelogServer class 4865N/A """OIDDict is a dictionary class that help lookup OID <-> litteral name 4865N/A of both objeclasses, and attributtypes""" 4865N/A return the tuple (OID,List of names) 4865N/A the List of aliases starts from list of names[1:] when exist. for ex : 4865N/A attributeTypes: ( 2.5.4.4 NAME ( 'sn' 'surname' ) SUP name X-ORIGIN 'RFC 4519' ) 4865N/A # populate the NAME to OID : "dict" dictionary 4974N/A # TODO encoded schema is not handled for now 4974N/A # TODO encoded schema is not handled for now 4974N/A # populate SUP and MUST / MAY, : "sup", "may", "must" dictionaries 4865N/A """extract a list of attributes for a given myStr section. 4865N/A The section should contain () when multivalued. 4865N/A If another section comes after it starts with a Upercase. 4865N/A example MUST (sn cn) MAY ( description ... ) 4865N/A myStr : name of the section ex(MAY) 4865N/A if None, function will figure out end of section""" 4865N/A if s[
0] >=
'A' and s[
0] <=
'Z':
4865N/A elif s[
0] !=
'$' and s[
0] !=
'|':
4865N/A if s[
0] ==
'\'' and s[-
1] ==
'\'':
4865N/A """will return the attributes the objectclassname MUST implement""" 4865N/A # avoiding duplication of MUSTs 4865N/A """will return the attributes the objectclassname MAY implement""" 4865N/A # avoiding duplication of MAYs 4865N/A """will return the objectclassname that this objectclassname inherit""" 4865N/A """get the schema as a string 4865N/A and attributetypes only.""" 4865N/A # line continuation aggregated into 'line' 4865N/A # populate the OID <-> Names dictionary 4865N/A """get example schema.ldif file with : 4974N/A ldapsearch -b 'cn=schema' -Dcn=directory\ manager -s base -wpassword objectclass=* objectClasses attributeTypes > /tmp/schema.ldif 4865N/A for cn in [
'rFC822LocalPart',
'inetOrgPerson',
'top',
'doMain',
'2.5.6.7',
'BLAH']: