diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
index 48dee48..75b2aaf 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
@@ -64,6 +64,7 @@ s4connector_search = False
# FIXME: What is the use of the following line?
# __path__.append("users")
+
# manages properties
class base(object):
def __init__(self, co, lo, position, dn='', superordinate = None ):
@@ -299,7 +300,6 @@ class base(object):
return self.descriptions.keys()
def items(self):
-
# this returns emtpy strings resp. empty lists for attributes not set
r=[]
for key in self.keys():
@@ -456,7 +456,6 @@ class base(object):
class simpleLdap(base):
-
def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
global s4connector_present
global s4connector_search
@@ -528,7 +527,7 @@ class simpleLdap(base):
def description(self):
if self.dn:
rdn = self.lo.explodeDn(self.dn)[0]
- return rdn[rdn.find('=')+1:]
+ return rdn[rdn.find('=') + 1:]
else:
return 'none'
@@ -546,34 +545,25 @@ class simpleLdap(base):
self.exceptions=[]
# remove all properties which do not belong to chosen options
-
- chosen_options = None
- descriptions = None
-
try:
# these might not be set by an inheriting module
chosen_options = self.options
descriptions = self.descriptions
except:
- pass
+ chosen_options = None
+ descriptions = None
if chosen_options and descriptions:
for desc in descriptions:
propoptions = descriptions[desc].options
- if (propoptions==[]):
+ if not propoptions:
# property applies to all options
continue
- shortcut = False
-
- for i in propoptions:
- if i in chosen_options:
- # this property applies to one of the chosen options,
- # jump to next option
- shortcut = True
- continue
- if shortcut:
+ if set(propoptions) & set(chosen_options):
+ # this property applies to one of the chosen options,
+ # jump to next option
continue
# if we've come here, we found a property that does not apply
@@ -594,7 +584,6 @@ class simpleLdap(base):
ml.append(('objectClass', self.oldattr.get('objectClass', []), self.oldattr.get('objectClass', [])+['univentionPolicyReference']))
ml.append(('univentionPolicyReference', self.oldpolicies, self.policies))
-
return ml
def _create(self):
@@ -719,7 +708,7 @@ class simpleLdap(base):
self.save()
return self.dn
-#+++# MODIFY #+++#
+ #+++# MODIFY #+++#
def _modify(self, modify_childs=1, ignore_license=0):
self.exceptions=[]
@@ -744,7 +733,7 @@ class simpleLdap(base):
# iterate over all properties and call checkLdap() of corresponding syntax
self._call_checkLdap_on_all_property_syntaxes()
-#+++# MODLIST #+++#
+ #+++# MODLIST #+++#
ml=self._ldap_modlist()
# custom attributes
m=univention.admin.modules.get(self.module)
@@ -781,7 +770,6 @@ class simpleLdap(base):
ml.remove(i)
ml.extend( addlist )
-
else:
if deleteObjectClass == '1' and not self.info.has_key(pname):
# value is empty, should delete objectClass and Values
@@ -829,7 +817,6 @@ class simpleLdap(base):
ml.append( ('objectClass', self.oldattr.get('objectClass'), current_ocs+[prop.objClass]) )
else:
-
if prop.syntax == 'boolean' and self.info.has_key(prop.name) and self.info[prop.name] == '0':
# syntax is boolean and value == 0 ==> remove
dellist = []
@@ -1009,8 +996,6 @@ class simpleLdap(base):
self.policyObjects[policy_type]=univention.admin.objects.get(policy_module, None, self.lo, policy_position)
self.policyObjects[policy_type].copyIdentifier(self)
self._init_ldap_search( self.policyObjects[ policy_type ] )
- else:
- pass
return self.policyObjects[policy_type]
@@ -1122,7 +1107,7 @@ class simpleComputer( simpleLdap ):
zoneName.reverse( )
relativeDomainName = relativeDomainName.split( '.' )
relativeDomainName.reverse( )
- return '%s.%s' % ( string.join( zoneName, '.' ) , string.join( relativeDomainName, '.' ) )
+ return '.'.join(zoneName + relativeDomainName)
def __ip_from_ptr_ipv6( self, zoneName, relativeDomainName ):
fullName = relativeDomainName + '.' + zoneName.replace('.ip6.arpa', '')
@@ -1408,13 +1393,12 @@ class simpleComputer( simpleLdap ):
object[ 'host' ] = object[ 'host' ].replace( old_name, new_name )
object.modify( )
-
def __remove_from_dhcp_object( self, position = None, name = None, oldname = None, mac = None, ip = None ):
# if we got the mac addres, then we remove the object
# if we only got the ip addres, we remove the ip address
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should remove a dhcp object: position="%s", name="%s", oldname="%s", mac="%s", ip="%s"' % ( position, name, oldname, mac, ip ) )
-
+
dn = None
tmppos = univention.admin.uldap.position( self.position.getDomain( ) )
@@ -1494,11 +1478,10 @@ class simpleComputer( simpleLdap ):
for dn2, attributes2 in self.lo.search(scope='domain', attr=[ 'zoneName' ], filter='(&(relativeDomainName=%s)(objectClass=dNSZone))' % name, unique=0 ):
self.lo.modify( dn, [('pTRRecord', '%s.%s.' % (name, attributes2['zoneName'][0]), '')] )
- zone = univention.admin.handlers.dns.reverse_zone.object( self.co, self.lo, self.position, zoneDN)
+ zone = univention.admin.handlers.dns.reverse_zone.object( self.co, self.lo, self.position, zoneDN)
zone.open()
zone.modify()
-
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should remove a dns reverse object: dnsEntryZoneReverse="%s", name="%s", ip="%s"' % ( dnsEntryZoneReverse, name, ip ) )
if dnsEntryZoneReverse:
rdn = self.calc_dns_reverse_entry_name( ip, dnsEntryZoneReverse )
@@ -1519,7 +1502,7 @@ class simpleComputer( simpleLdap ):
modify(rdn, zone)
except univention.admin.uexceptions.noObject:
pass
- pass
+
def __add_dns_reverse_object( self, name, zoneDn, ip ):
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should create a dns reverse object: zoneDn="%s", name="%s", ip="%s"' % ( zoneDn, name, ip ) )
if name and zoneDn and ip:
@@ -1644,8 +1627,6 @@ class simpleComputer( simpleLdap ):
for dn, attributes in self.lo.search(base=zoneDN, scope='domain', attr=['pTRRecord'], filter=search_filter):
self.lo.modify(dn, [('pTRRecord', '', ptrrecord)])
-
-
def __remove_related_ptrrecords(self, zoneDN, ip):
ptrrecord = '%s.%s.' % (self.info['name'], zoneDN.split('=')[1].split(',')[0])
ip_split = ip.split('.')
@@ -1655,7 +1636,6 @@ class simpleComputer( simpleLdap ):
for dn, attributes in self.lo.search(base=zoneDN, scope='domain', attr=['pTRRecord'], filter=search_filter):
if ptrrecord in attributes['pTRRecord']:
self.lo.modify(dn, [('pTRRecord', ptrrecord, '')])
-
def check_common_name_length(self):
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'check_common_name_length with self["ip"] = %r and self["dnsEntryZoneForward"] = %r' % (self['ip'], self['dnsEntryZoneForward'], ))
@@ -1779,7 +1759,6 @@ class simpleComputer( simpleLdap ):
else:
self.lo.modify( dn, [ ( 'aRecord', '' , ip ) ] )
-
def __add_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, alias ):
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'add a dns alias object: name="%s", dnsForwardZone="%s", dnsAliasZoneContainer="%s", alias="%s"' % ( name, dnsForwardZone, dnsAliasZoneContainer, alias ) )
if name and dnsForwardZone and dnsAliasZoneContainer and alias:
@@ -1798,7 +1777,6 @@ class simpleComputer( simpleLdap ):
else:
# thow exeption, cNAMERecord is single value
raise univention.admin.uexceptions.dnsAliasAlreadyUsed, _('DNS alias is already in use.')
- pass
def __remove_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, alias = None ):
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'remove a dns alias object: name="%s", dnsForwardZone="%s", dnsAliasZoneContainer="%s", alias="%s"' % ( name, dnsForwardZone, dnsAliasZoneContainer, alias ) )
@@ -1845,9 +1823,7 @@ class simpleComputer( simpleLdap ):
pass
def _ldap_post_modify( self ):
-
- if len ( self[ 'mac' ] ) > 1 or len( self[ 'ip' ] ) > 1:
- self.__multiip = True
+ self.__multiip |= len(self['mac']) > 1 or len(self['ip']) > 1
for entry in self.__changes[ 'dhcpEntryZone' ][ 'remove' ]:
univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'simpleComputer: dhcp check: removed: %s' % entry )
@@ -1900,7 +1876,6 @@ class simpleComputer( simpleLdap ):
else:
self.__add_dns_reverse_object( self[ 'name' ], dn, ip )
-
for entry in self.__changes[ 'dnsEntryZoneAlias' ][ 'remove' ]:
dnsForwardZone, dnsAliasZoneContainer, alias = entry
if not alias:
@@ -1963,7 +1938,6 @@ class simpleComputer( simpleLdap ):
self.__update_groups_after_namechange()
self.__rename_dhcp_object( position = None, old_name = self.__changes[ 'name' ][ 0 ], new_name = self.__changes[ 'name' ][ 1 ] )
self.__rename_dns_object( position = None, old_name = self.__changes[ 'name' ][ 0 ], new_name = self.__changes[ 'name' ][ 1 ] )
- pass
if self.ipRequest == 1 and self[ 'ip' ]:
for ipAddress in self[ 'ip' ]:
@@ -1981,17 +1955,16 @@ class simpleComputer( simpleLdap ):
def __remove_associated_domain( self, entry ):
dn, ip = self.__split_dns_line( entry )
- domain = string.join(ldap.explode_rdn(dn)[0].split('=')[1:], '=')
+ domain = ldap.explode_rdn(dn)[0].split('=', 1)[1]
if self.info.get('domain', None) == domain:
self.info['domain'] = None
def __set_associated_domain( self, entry ):
dn, ip = self.__split_dns_line( entry )
- domain = string.join(ldap.explode_rdn(dn)[0].split('=')[1:], '=')
+ domain = ldap.explode_rdn(dn)[0].split('=', 1)[1]
if not self.info.get('domain', None):
self.info['domain'] = domain
-
def _ldap_modlist( self ):
self.__changes = { 'mac': {'remove': [ ], 'add': [ ]}, 'ip': {'remove': [ ], 'add': [ ]}, 'name': None,
'dnsEntryZoneForward': { 'remove': [ ], 'add': [ ] },
@@ -2029,13 +2002,13 @@ class simpleComputer( simpleLdap ):
newAaaaRecord = []
if oldAddresses != newAddresses:
if oldAddresses:
- for address in oldAddresses:
+ for address in oldAddresses:
if ':' in address: # IPv6
oldAaaaRecord.append(address)
else:
oldARecord.append(address)
if newAddresses:
- for address in newAddresses:
+ for address in newAddresses:
if ':' in address: # IPv6
newAaaaRecord.append(ipaddr.IPv6Address(address).exploded)
else:
@@ -2075,19 +2048,17 @@ class simpleComputer( simpleLdap ):
continue
self.__changes[ 'ip' ][ 'remove' ].append( ipAddress )
-
if self.hasChanged( 'name' ):
ml.append( ( 'sn', self.oldattr.get( 'sn', [ None ] )[ 0 ], self[ 'name' ] ) )
self.__changes[ 'name' ] = ( self.oldattr.get( 'sn', [ None ] )[ 0 ], self[ 'name' ] )
if self.hasChanged('ip') or self.hasChanged('mac'):
-
if len(self.info.get('ip', [])) == 1 and len(self.info.get('mac', [])) == 1 and len(self.info.get('dhcpEntryZone', [])):
# In this special case, we assume the mapping between ip/mac address to be
# unique. The dhcp entry needs to contain the mac address (as sepcified by
- # the ldap search for dhcp entries), the ip address may not correspond to
- # the ip address associated with the computer ldap object, but this would
- # be erroneous anyway. We therefore update the dhcp entry to correspond to
+ # the ldap search for dhcp entries), the ip address may not correspond to
+ # the ip address associated with the computer ldap object, but this would
+ # be erroneous anyway. We therefore update the dhcp entry to correspond to
# the current ip and mac address. (Bug #20315)
dn, ip, mac = self.__split_dhcp_line( self.info['dhcpEntryZone'][0] )
@@ -2171,12 +2142,9 @@ class simpleComputer( simpleLdap ):
else:
raise univention.admin.uexceptions.invalidDNSAliasEntry, _('The DNS alias entry for this host should contain the zone name, the alias zone container LDAP-DN and the alias.')
- if len ( self[ 'mac' ] ) < 2 and len( self[ 'ip' ] ) < 2:
- self.__multiip = False
- else:
- self.__multiip = True
+ self.__multiip = len(self['mac']) > 1 or len(self['ip']) > 1
- ml = ml + super( simpleComputer, self )._ldap_modlist( )
+ ml += super(simpleComputer, self)._ldap_modlist()
return ml
@@ -2191,6 +2159,7 @@ class simpleComputer( simpleLdap ):
subnet=ldap.explode_dn(reverseDN, 1)[0].replace('.in-addr.arpa','').split('.')
ip=sip.split('.')
return self.calc_dns_reverse_entry_name_do(4, subnet, ip)
+
def calc_dns_reverse_entry_name_do(self, maxLength, zoneNet, ip):
zoneNet.reverse()
if not ip[:len(zoneNet)] == zoneNet:
@@ -2222,7 +2191,6 @@ class simpleComputer( simpleLdap ):
else:
self.__modify_dhcp_object( dn, self[ 'name' ], ip, mac )
-
for entry in self.__changes[ 'dnsEntryZoneForward' ][ 'remove' ]:
dn, ip = self.__split_dns_line( entry )
if not ip and not self.__multiip:
@@ -2314,7 +2282,6 @@ class simpleComputer( simpleLdap ):
groupObject = univention.admin.objects.get(univention.admin.modules.get('groups/group'), self.co, self.lo, self.position, group)
groupObject.fast_member_remove( [ self.dn ], self.oldattr.get('uid',[]), ignore_license=1 )
-
def __update_groups_after_namechange(self):
oldname = self.oldinfo.get('name')
newname = self.info.get('name')
@@ -2356,7 +2323,6 @@ class simpleComputer( simpleLdap ):
self.lo.modify(group, [('uniqueMember', oldUniqueMembers, newUniqueMembers), ('memberUid', oldMemberUids, newMemberUids)])
-
def update_groups(self):
if not self.hasChanged('groups') and \
not ('oldPrimaryGroupDn' in self.__dict__ and self.oldPrimaryGroupDn) and \
@@ -2400,7 +2366,6 @@ class simpleComputer( simpleLdap ):
groupObject['hosts'].remove(self.dn)
groupObject.modify(ignore_license=1)
-
def primary_group(self):
if not self.hasChanged('primaryGroup'):
return
@@ -2545,9 +2510,6 @@ class simpleComputer( simpleLdap ):
self.__saved_dhcp_entry = network_object['dhcpEntryZone']
self.old_network=value
- else:
- pass
-
elif key == 'ip':
self.ip_freshly_set = True
@@ -2581,8 +2543,8 @@ class simpleComputer( simpleLdap ):
if raise_after:
raise raise_after
-class simpleLdapSub(simpleLdap):
+class simpleLdapSub(simpleLdap):
def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
base.__init__(self, co, lo, position, dn, superordinate )
@@ -2601,9 +2563,9 @@ class simpleLdapSub(simpleLdap):
if hasattr(self,"_ldap_post_remove"):
self._ldap_post_remove()
+
class simplePolicy(simpleLdap):
def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
-
self.resultmode=0
self.dn=dn
@@ -2786,7 +2748,6 @@ class simplePolicy(simpleLdap):
self.policy_result()
if self.polinfo.has_key(key):
-
if self.polinfo[key] != newvalue or self.polinfo_more[key]['policy'] == self.cloned or ( self.info.has_key( key ) and self.info[ key ] != newvalue ):
if self.polinfo_more[key]['fixed'] and self.polinfo_more[key]['policy'] != self.cloned:
raise univention.admin.uexceptions.policyFixedAttribute, key
@@ -2795,9 +2756,7 @@ class simplePolicy(simpleLdap):
if self.hasChanged(key):
univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'polinfo: key:%s hasChanged' % (key) )
self.changes=1
- return
- else:
- return
+ return
# this object did not exist before
if not self.oldinfo:
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/__common.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/__common.py
index e8ded03..6ad97a3 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/__common.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/__common.py
@@ -30,55 +30,115 @@
# /usr/share/common-licenses/AGPL-3; if not, see
# .
-import copy
-
+import sys
import univention.admin.localization
-from univention.admin.layout import Tab, Group
+from univention.admin.layout import Tab
+from univention.admin.handlers import simpleLdap
-translation = univention.admin.localization.translation( 'univention.admin.handlers.dhcp' )
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
_ = translation.translate
+
+_options = {
+ 'options': univention.admin.option(
+ short_description=_('Allow custom DHCP options'),
+ long_description=_("Allow adding custom DHCP options. Experts only!"),
+ default=False,
+ editable=True,
+ objectClasses=['dhcpOptions'],
+ ),
+}
+
+
_properties = {
'option': univention.admin.property(
- short_description = _( 'DHCP options' ),
- long_description = _( 'Defines DHCP options for the subnet.' ),
- syntax = univention.admin.syntax.string,
- multivalue = True,
- options = [],
- required = 0,
- may_change = True,
- identifies = 0
- ),
+ short_description=_('DHCP options'),
+ long_description=_('Defines additional DHCP options.'),
+ syntax=univention.admin.syntax.string,
+ multivalue=True,
+ options=["options"],
+ required=False,
+ may_change=True,
+ identifies=False,
+ ),
}
-# def optionMap( value ):
-# return map( lambda x: ' '.join( x ), value )
-# def optionUnmap( value ):
-# return map( lambda x: x.split( ' ', 1 ), value )
+def rangeMap(value):
+ return map(lambda x: ' '.join(x), value)
+
+
+def rangeUnmap(value):
+ return map(lambda x: x.split(), value)
+
_mappings = (
- # ( 'option', 'dhcpOption', optionMap, optionUnmap ),
- ( 'option', 'dhcpOption', None, univention.admin.mapping.ListToString ),
- )
+ ('option', 'dhcpOption', None, None),
+)
+
-def add_dhcp_options( properties, mapping, layout ):
- global _properties, _mappings
+def add_dhcp_options(module_name):
+ module = sys.modules[module_name]
- for name, prop in _properties.items():
- properties[ name ] = prop
+ options = getattr(module, "options")
+ options.update(_options)
+ properties = getattr(module, "property_descriptions")
+ properties.update(_properties)
+
+ mapping = getattr(module, "mapping")
for item in _mappings:
- mapping.register( *item )
+ mapping.register(*item)
+
+ layout = getattr(module, "layout")
+ layout.append(Tab(
+ _('DHCP options'),
+ _('Custom DHCP options'),
+ advanced=True,
+ layout=['option']
+ ))
+
+
+class SimpleDhcp(simpleLdap):
+ @classmethod
+ def lookup(cls, co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
+ filter_str = unicode(cls.lookup_filter(filter_s))
+ res = [
+ cls(co, lo, None, dn=dn, superordinate=superordinate, attributes=attrs)
+ for dn, attrs in lo.search(filter_str, base, scope, [], unique, required, timeout, sizelimit)
+ ]
+ return res
+
+
+class DhcpOptions(SimpleDhcp):
+ def setup_options(self, options):
+ self.options = []
+ self._define_options(options)
+
+ def open(self):
+ super(DhcpOptions, self).open()
+ try:
+ ocs = self.oldattr['objectClass']
+ if "dhcpOptions" in ocs:
+ self.options.append("options")
+ except LookupError:
+ pass
+ self.old_options = list(self.options)
+
+ def _ldap_modlist(self):
+ if "options" not in self.options:
+ del self.info.get('option', [])[:]
- # currently not visible
- #layout.append( Tab( _( 'Advanced' ), _( 'Advanced DHCP options' ), layout = [ 'option' ] ) )
+ mod_list = super(DhcpOptions, self)._ldap_modlist()
-def add_dhcp_objectclass( self, ml ):
- oldOCs = self.oldattr.get( 'objectClass', [] )
- newOCs = copy.copy( oldOCs )
- if self.info.get( 'option', [] ) and not 'dhcpOptions' in oldOCs:
- newOCs.append( 'dhcpOptions' )
- ml.append( ( 'objectClass', oldOCs, newOCs ) )
+ old_ocs = self.oldattr.get('objectClass', [])
+ if self.info.get('option', []):
+ if 'dhcpOptions' not in old_ocs:
+ new_ocs = old_ocs + ['dhcpOptions']
+ mod_list.append(('objectClass', old_ocs, new_ocs))
+ elif "options" not in self.options and 'dhcpOptions' in old_ocs:
+ new_ocs = list(old_ocs)
+ new_ocs.remove("dhcpOptions")
+ mod_list.append(('objectClass', old_ocs, new_ocs))
- return ml
+ return mod_list
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/dhcp.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/dhcp.py
index 82e00d0..f812041 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/dhcp.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/dhcp.py
@@ -44,78 +44,87 @@ import univention.admin.handlers.dhcp.sharedsubnet
import univention.admin.handlers.dhcp.subnet
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
-
-
-module='dhcp/dhcp'
-
-childs=0
-short_description=_('DHCP')
-long_description=''
-operations=['search']
-usewizard=1
-wizardmenustring=_("DHCP")
-wizarddescription=_("Add, edit and delete DHCP objects")
-wizardoperations={"add":[_("Add"), _("Add DHCP object")],"find":[_("Search"), _("Search DHCP object(s)")]}
-wizardpath="univentionDhcpObject"
-wizardsuperordinates = ( 'None', 'dhcp/service', 'dhcp/shared' )
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+
+module = 'dhcp/dhcp'
+
+childs = 0
+short_description = _('DHCP')
+long_description = ''
+operations = ['search']
+usewizard = 1
+wizardmenustring = _("DHCP")
+wizarddescription = _("Add, edit and delete DHCP objects")
+wizardoperations = {
+ "add": [_("Add"), _("Add DHCP object")],
+ "find": [_("Search"), _("Search DHCP object(s)")],
+}
+wizardpath = "univentionDhcpObject"
+wizardsuperordinates = ('None', 'dhcp/service', 'dhcp/shared')
wizardtypesforsuper = {
- 'None' : ( 'dhcp/service', ),
- 'dhcp/service' : ( 'dhcp/host', 'dhcp/server', 'dhcp/shared', 'dhcp/subnet' ),
- 'dhcp/shared' : ( 'dhcp/sharedsubnet', )
- }
-
-childmodules=["dhcp/host","dhcp/pool","dhcp/server","dhcp/service","dhcp/shared","dhcp/sharedsubnet","dhcp/subnet"]
-virtual=1
-options={
+ 'None': ('dhcp/service',),
+ 'dhcp/service': ('dhcp/host', 'dhcp/server', 'dhcp/shared', 'dhcp/subnet'),
+ 'dhcp/shared': ('dhcp/sharedsubnet',)
+}
+
+childmodules = [
+ "dhcp/host",
+ "dhcp/pool",
+ "dhcp/server",
+ "dhcp/service",
+ "dhcp/shared",
+ "dhcp/sharedsubnet",
+ "dhcp/subnet",
+]
+virtual = 1
+
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'name': univention.admin.property(
- short_description=_('Name'),
- long_description='',
- syntax=univention.admin.syntax.string,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=1,
- identifies=1
- )
+ short_description=_('Name'),
+ long_description='',
+ syntax=univention.admin.syntax.string,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=True
+ )
}
-layout = [ Tab( _( 'General' ), _( 'Basic settings' ), layout = [ "name" ] ) ]
+layout = [Tab(_('General'), _('Basic settings'), layout=["name"])]
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
class object(univention.admin.handlers.simpleLdap):
- module=module
+ module = module
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.mapping = mapping
+ self.descriptions = property_descriptions
- self.mapping=mapping
- self.descriptions=property_descriptions
-
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
- ret=[]
+ ret = []
if superordinate:
- ret+= univention.admin.handlers.dhcp.host.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
- ret+= univention.admin.handlers.dhcp.pool.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
- ret+=univention.admin.handlers.dhcp.server.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
- ret+= univention.admin.handlers.dhcp.shared.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
- ret+= univention.admin.handlers.dhcp.sharedsubnet.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
- ret+= univention.admin.handlers.dhcp.subnet.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.host.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.pool.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.server.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.shared.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.sharedsubnet.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.subnet.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
else:
- ret+= univention.admin.handlers.dhcp.service.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
+ ret += univention.admin.handlers.dhcp.service.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit)
return ret
+
def identify(dn, attr, canonical=0):
pass
-
-
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/host.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/host.py
index e7cc0d3..11b36d2 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/host.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/host.py
@@ -34,127 +34,137 @@ from univention.admin.layout import Tab, Group
import univention.admin.filter
import univention.admin.handlers
import univention.admin.localization
-import univention.debug
-
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
-
-module='dhcp/host'
-operations=['add','edit','remove','search']
-superordinate='dhcp/service'
-childs=0
-usewizard=1
-short_description=_('DHCP: Host')
-long_description=''
-options={
+import univention.debug as ud
+
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+module = 'dhcp/host'
+operations = ['add', 'edit', 'remove', 'search']
+superordinate = 'dhcp/service'
+childs = 0
+usewizard = 1
+short_description = _('DHCP: Host')
+long_description = ''
+
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'host': univention.admin.property(
- short_description=_('Hostname'),
- long_description='',
- syntax=univention.admin.syntax.string,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=1,
- identifies=1
- ),
+ short_description=_('Hostname'),
+ long_description='',
+ syntax=univention.admin.syntax.string,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=True
+ ),
'hwaddress': univention.admin.property(
- short_description=_('Hardware address'),
- long_description=_('Currently, only the ethernet and token-ring types are recognized. \
-The hardware-address should be a set of hexadecimal octets (numbers from 0 through ff) separated by colons.'),
- syntax=univention.admin.syntax.DHCP_HardwareAddress,
- multivalue=0,
- options=[],
- required=1,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Hardware address'),
+ long_description=_(
+ 'Currently, only the ethernet and token-ring types are recognized.'
+ 'The hardware-address should be a set of hexadecimal octets (numbers from 0 through ff) separated by colons.'),
+ syntax=univention.admin.syntax.DHCP_HardwareAddress,
+ multivalue=False,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=False
+ ),
'fixedaddress': univention.admin.property(
- short_description=_('Fixed IP addresses'),
- long_description=_('Assign one or more fixed IP addresses. \
-Each address should be either an IP address or a domain name that resolves to one or more IP addresses'),
- syntax=univention.admin.syntax.string,
- multivalue=1,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Fixed IP addresses'),
+ long_description=_(
+ 'Assign one or more fixed IP addresses.'
+ 'Each address should be either an IP address or a domain name that resolves to one or more IP addresses'),
+ syntax=univention.admin.syntax.string,
+ multivalue=True,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
}
-layout=[
- Tab( _('General'), _('Basic settings'), layout = [
- Group( _( 'General' ), layout = [
+
+layout = [
+ Tab(_('General'), _('Basic settings'), layout=[
+ Group(_('General'), layout=[
'host',
'hwaddress',
'fixedaddress'
- ] ),
- ] )
+ ]),
+ ])
]
+
def unmapHWAddress(old):
- univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'host.py: unmapHWAddress: old: %s' % old)
+ ud.debug(ud.ADMIN, ud.INFO, 'host.py: unmapHWAddress: old: %s' % old)
if not old:
return ['', '']
return old[0].split(' ')
+
def mapHWAddress(old):
- univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'host.py: mapHWAddress: old: %s' % old)
+ ud.debug(ud.ADMIN, ud.INFO, 'host.py: mapHWAddress: old: %s' % old)
if not old[0]:
return ''
else:
- if len (old) > 1:
+ if len(old) > 1:
return '%s %s' % (old[0], old[1])
else:
return old
-mapping=univention.admin.mapping.mapping()
+
+mapping = univention.admin.mapping.mapping()
mapping.register('host', 'cn', None, univention.admin.mapping.ListToString)
mapping.register('hwaddress', 'dhcpHWAddress', mapHWAddress, unmapHWAddress)
mapping.register('fixedaddress', 'univentionDhcpFixedAddress')
-class object(univention.admin.handlers.simpleLdap):
- module=module
+from .__common import add_dhcp_options, DhcpOptions
+add_dhcp_options(__name__)
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
- self.mapping=mapping
- self.descriptions=property_descriptions
+class object(DhcpOptions):
+ module = module
+
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not superordinate:
raise univention.admin.uexceptions.insufficientInformation, 'superordinate object not present'
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
+ self.setup_options(options)
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('host'), mapping.mapValue('host', self.info['host']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('host'),
+ mapping.mapValue('host', self.info['host']),
+ self.position.getDn()
+ )
def _ldap_addlist(self):
return [
('objectClass', ['top', 'univentionDhcpHost']),
]
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
+ @staticmethod
+ def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.expression('objectClass', 'univentionDhcpHost')
+ ])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.expression('objectClass', 'univentionDhcpHost')
- ])
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
+lookup_filter = object.lookup_filter
+lookup = object.lookup
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
- return res
def identify(dn, attr):
-
return 'univentionDhcpHost' in attr.get('objectClass', [])
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/pool.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/pool.py
index f02c862..6c96521 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/pool.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/pool.py
@@ -31,7 +31,6 @@
# .
import copy
-import string
from univention.admin.layout import Tab, Group
import univention.admin.filter
@@ -39,211 +38,204 @@ import univention.admin.handlers
import univention.admin.localization
import univention.admin.uexceptions
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
-module='dhcp/pool'
-operations=['add','edit','remove','search']
+module = 'dhcp/pool'
+operations = ['add', 'edit', 'remove', 'search']
superordinate = 'dhcp/subnet'
-childs=0
-usewizard=1
-short_description=_('DHCP: Pool')
-long_description=''
-options={
+childs = 0
+usewizard = 1
+short_description = _('DHCP: Pool')
+long_description = ''
+
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'name': univention.admin.property(
- short_description=_('Name'),
- long_description='',
- syntax=univention.admin.syntax.string,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=0,
- identifies=1
- ),
+ short_description=_('Name'),
+ long_description=_('A unique name used to identify this pool, e.g. "known" or "guests"'),
+ syntax=univention.admin.syntax.string,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=False,
+ identifies=True
+ ),
'range': univention.admin.property(
- short_description=_('IP range for dynamic assignment'),
- long_description='',
- syntax=univention.admin.syntax.IPv4_AddressRange,
- multivalue=1,
- options=[],
- required=1,
- may_change=1,
- identifies=0
- ),
+ short_description=_('IP range for dynamic assignment'),
+ long_description='',
+ syntax=univention.admin.syntax.IPv4_AddressRange,
+ multivalue=True,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=False
+ ),
'failover_peer': univention.admin.property(
- short_description=_('Failover peer'),
- long_description='',
- syntax=univention.admin.syntax.string,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0,
- ),
+ short_description=_('Failover peer'),
+ long_description=_('The name of a failover configuration manually configured in /etc/dhcp/local.conf.'),
+ syntax=univention.admin.syntax.string,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False,
+ ),
'known_clients': univention.admin.property(
- short_description=_('Allow known clients'),
- long_description='',
- syntax=univention.admin.syntax.AllowDeny,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Give IP to known clients'),
+ long_description=_('Addresses are allocated for client, which have a host entry matching their MAC address.'),
+ syntax=univention.admin.syntax.AllowDeny,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
'unknown_clients': univention.admin.property(
- short_description=_('Allow unknown clients'),
- long_description='',
- syntax=univention.admin.syntax.AllowDeny,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Give IP to unknown clients'),
+ long_description=_('Addresses are allocated for clients, which do not have a host entry mating their MAC address.'),
+ syntax=univention.admin.syntax.AllowDeny,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
'dynamic_bootp_clients': univention.admin.property(
- short_description=_('Allow dynamic BOOTP clients'),
- long_description='',
- syntax=univention.admin.syntax.AllowDeny,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Give IP to dynamic BOOTP clients'),
+ long_description=_(
+ 'Give addresses to clients using the legacy BOOTP protocol.'
+ 'Since BOOTP does not support an expiry date or a release mechanism, addresses are allocated indefinitely!'),
+ syntax=univention.admin.syntax.AllowDeny,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
'all_clients': univention.admin.property(
- short_description=_('All clients'),
- long_description='',
- syntax=univention.admin.syntax.AllowDeny,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Give IP from this pool'),
+ long_description=_('Give addresses from this pool at all or not.'),
+ syntax=univention.admin.syntax.AllowDeny,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
}
-options={
+options = {
}
layout = [
- Tab(_('General'), _('Basic settings'), layout = [
- Group( _( 'General' ), layout = [
+ Tab(_('General'), _('Basic settings'), layout=[
+ Group(_('General'), layout=[
'name',
'range'
- ] ),
- ] ),
- Tab( _( 'Advanced' ), _('Advanced DHCP pool options'), advanced = True, layout = [
+ ]),
+ ]),
+ Tab(_('Advanced'), _('Advanced DHCP pool options'), advanced=True, layout=[
'failover_peer',
- [ 'known_clients', 'unknown_clients' ],
- [ 'dynamic_bootp_clients', 'all_clients' ]
- ] )
+ ['known_clients', 'unknown_clients'],
+ ['dynamic_bootp_clients', 'all_clients']
+ ])
]
-def rangeMap( value ):
- return map( lambda x: ' '.join( x ), value )
-def rangeUnmap( value ):
- return map( lambda x: x.split( ' ' ), value )
+from .__common import rangeMap, rangeUnmap, add_dhcp_options, DhcpOptions
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
mapping.register('name', 'cn', None, univention.admin.mapping.ListToString)
mapping.register('range', 'dhcpRange', rangeMap, rangeUnmap)
mapping.register('failover_peer', 'univentionDhcpFailoverPeer', None, univention.admin.mapping.ListToString)
-class object(univention.admin.handlers.simpleLdap):
- module=module
+add_dhcp_options(__name__)
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
- self.mapping=mapping
- self.descriptions=property_descriptions
+class object(DhcpOptions):
+ module = module
+
+ permits_udm2dhcp = {
+ 'known_clients': "known clients",
+ 'unknown_clients': "unknown clients",
+ 'dynamic_bootp_clients': "dynamic bootp clients",
+ 'all_clients': "all clients",
+ }
+ permits_dhcp2udm = dict((value, key) for (key, value) in permits_udm2dhcp.items())
+
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not superordinate:
raise univention.admin.uexceptions.insufficientInformation, 'superordinate object not present'
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
+ self.setup_options(options)
def open(self):
-
- univention.admin.handlers.simpleLdap.open(self)
+ super(object, self).open()
for i in self.oldattr.get('dhcpPermitList', []):
- pos=i.find(' ')
- permit=i[:pos]
- name=i[pos+1:]
- if name == 'known clients':
- self['known_clients']=permit
- elif name == 'unknown clients':
- self['unknown_clients']=permit
- elif name == 'dynamic bootp clients':
- self['dynamic_bootp_clients']=permit
- elif name == 'all clients':
- self['all_clients']=permit
+ permit, name = i.split(' ', 1)
+ prop = self.permits_dhcp2udm[name]
+ self[prop] = permit
self.save()
-
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('name'), mapping.mapValue('name', self.info['name']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('name'),
+ mapping.mapValue('name', self.info['name']),
+ self.position.getDn()
+ )
def _ldap_addlist(self):
return [
('objectClass', ['top', 'univentionDhcpPool']),
]
-
+
def _ldap_modlist(self):
- ml=univention.admin.handlers.simpleLdap._ldap_modlist(self)
- if self.hasChanged(['known_clients', 'unknown_clients', 'dynamic_bootp_clients', 'all_clients']):
- old=self.oldattr.get('dhcpPermitList', [])
- new=copy.deepcopy(old)
-
- if self.oldinfo.has_key('known_clients') and self.oldinfo['known_clients']:
- new.remove(self.oldinfo['known_clients']+' known clients')
- if self.info.has_key('known_clients') and self.info['known_clients']:
- new.append(self.info['known_clients']+' known clients')
-
- if self.oldinfo.has_key('unknown_clients') and self.oldinfo['unknown_clients']:
- new.remove(self.oldinfo['unknown_clients']+' unknown clients')
- if self.info.has_key('unknown_clients') and self.info['unknown_clients']:
- new.append(self.info['unknown_clients']+' unknown clients')
-
- if self.oldinfo.has_key('dynamic_bootp_clients') and self.oldinfo['dynamic_bootp_clients']:
- new.remove(self.oldinfo['dynamic_bootp_clients']+' dynamic bootp clients')
- if self.info.has_key('dynamic_bootp_clients') and self.info['dynamic_bootp_clients']:
- new.append(self.info['dynamic_bootp_clients']+' dynamic bootp clients')
-
- if self.oldinfo.has_key('all_clients') and self.oldinfo['all_clients']:
- new.remove(self.oldinfo['all_clients']+' all clients')
- if self.info.has_key('all_clients') and self.info['all_clients']:
- new.append(self.info['all_clients']+' all clients')
-
+ ml = super(object, self)._ldap_modlist()
+ if self.hasChanged(self.permits_udm2dhcp.keys()):
+ old = self.oldattr.get('dhcpPermitList', [])
+ new = copy.deepcopy(old)
+ for prop, value in self.permits_udm2dhcp.items():
+ try:
+ permit = self.oldinfo[prop]
+ new.remove("%s %s" % (permit, value))
+ except LookupError:
+ pass
+ try:
+ permit = self.info[prop]
+ new.append("%s %s" % (permit, value))
+ except LookupError:
+ pass
ml.append(('dhcpPermitList', old, new))
+
if self.info.get('failover_peer', None) and not self.info.get('dynamic_bootp_clients', None) == 'deny':
raise univention.admin.uexceptions.bootpXORFailover
+
return ml
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
+ @staticmethod
+ def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.expression('objectClass', 'univentionDhcpPool')
+ ])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.expression('objectClass', 'univentionDhcpPool')
- ])
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
+lookup_filter = object.lookup_filter
+lookup = object.lookup
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
- return res
def identify(dn, attr):
return 'univentionDhcpPool' in attr.get('objectClass', [])
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/server.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/server.py
index 98e43c0..55b6d78 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/server.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/server.py
@@ -35,71 +35,73 @@ import univention.admin.filter
import univention.admin.handlers
import univention.admin.localization
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
-
-module='dhcp/server'
-operations=['add','edit','remove','search']
-superordinate='dhcp/service'
-childs=0
-usewizard=1
-short_description=_('DHCP: Server')
-long_description=''
-options={
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+module = 'dhcp/server'
+operations = ['add', 'edit', 'remove', 'search']
+superordinate = 'dhcp/service'
+childs = 0
+usewizard = 1
+short_description = _('DHCP: Server')
+long_description = ''
+
+options = {
}
-property_descriptions={
+property_descriptions = {
'server': univention.admin.property(
- short_description=_('Server name'),
- long_description='',
- syntax=univention.admin.syntax.string,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=1,
- identifies=1
- ),
+ short_description=_('Server name'),
+ long_description='',
+ syntax=univention.admin.syntax.string,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=True
+ ),
}
layout = [
- Tab( _( 'General' ), _('General settings'), layout = [
- Group( _( 'General' ), layout = [
+ Tab(_('General'), _('General settings'), layout=[
+ Group(_('General'), layout=[
'server'
- ] ),
- ] )
+ ]),
+ ])
]
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
mapping.register('server', 'cn', None, univention.admin.mapping.ListToString)
from .__common import add_dhcp_options
+add_dhcp_options(__name__)
-add_dhcp_options( property_descriptions, mapping, layout )
class object(univention.admin.handlers.simpleLdap):
- module=module
-
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
+ module = module
- self.superordinate=superordinate
- self.mapping=mapping
- self.descriptions=property_descriptions
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.superordinate = superordinate
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not superordinate:
raise univention.admin.uexceptions.insufficientInformation, 'superordinate object not present'
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('server'), mapping.mapValue('server', self.info['server']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('server'),
+ mapping.mapValue('server', self.info['server']),
+ self.position.getDn()
+ )
def _ldap_addlist(self):
- searchBase=self.position.getDomain()
+ searchBase = self.position.getDomain()
if self.lo.searchDn(base=searchBase, filter='(&(objectClass=dhcpServer)(cn=%s))' % (self.info['server'])):
raise univention.admin.uexceptions.dhcpServerAlreadyUsed, self.info['server']
@@ -107,33 +109,36 @@ class object(univention.admin.handlers.simpleLdap):
('objectClass', ['top', 'dhcpServer']),
('dhcpServiceDN', self.superordinate.dn),
]
+
def _ldap_post_move(self, olddn):
'''edit dhcpServiceDN'''
- oldServiceDN=self.lo.getAttr(self.dn, 'dhcpServiceDN')
- module=univention.admin.modules.identifyOne(self.position.getDn(), self.lo.get(self.position.getDn()))
- object=univention.admin.objects.get(module, None, self.lo, self.position, dn=self.position.getDn())
- shadow_module, shadow_object=univention.admin.objects.shadow(self.lo, module, object, self.position)
+ oldServiceDN = self.lo.getAttr(self.dn, 'dhcpServiceDN')
+ module = univention.admin.modules.identifyOne(self.position.getDn(), self.lo.get(self.position.getDn()))
+ object = univention.admin.objects.get(module, None, self.lo, self.position, dn=self.position.getDn())
+ shadow_module, shadow_object = univention.admin.objects.shadow(self.lo, module, object, self.position)
self.lo.modify(self.dn, [('dhcpServiceDN', oldServiceDN[0], shadow_object.dn)])
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.expression('objectClass', 'dhcpServer')
+def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.expression('objectClass', 'dhcpServer')
])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
- if superordinate:
- filter.expressions.append(univention.admin.filter.expression('dhcpServiceDN', superordinate.dn))
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
+def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
+ filter_obj = lookup_filter(filter_s)
+ if superordinate:
+ filter_obj.expressions.append(univention.admin.filter.expression('dhcpServiceDN', superordinate.dn))
+ filter_str = unicode(filter_obj)
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
+ res = [
+ object(co, lo, None, dn=dn, superordinate=superordinate, attributes=attrs)
+ for dn, attrs in lo.search(filter_str, base, scope, [], unique, required, timeout, sizelimit)
+ ]
return res
-def identify(dn, attr):
+def identify(dn, attr):
return 'dhcpServer' in attr.get('objectClass', [])
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/service.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/service.py
index 4d0d026..19c0061 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/service.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/service.py
@@ -35,93 +35,88 @@ import univention.admin.filter
import univention.admin.handlers
import univention.admin.localization
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
-
-module='dhcp/service'
-operations=['add','edit','remove','search']
-childs=1
-usewizard=1
-short_description=_('DHCP: Service')
-long_description=''
-options={
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+module = 'dhcp/service'
+operations = ['add', 'edit', 'remove', 'search']
+childs = 1
+usewizard = 1
+short_description = _('DHCP: Service')
+long_description = ''
+
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'service': univention.admin.property(
- short_description=_('Service name'),
- long_description='',
- syntax=univention.admin.syntax.string,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=0,
- identifies=1
- ),
+ short_description=_('Service name'),
+ long_description='',
+ syntax=univention.admin.syntax.string,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=False,
+ identifies=True
+ ),
}
layout = [
- Tab( _( 'General' ), _( 'Basic settings' ), layout = [
- Group( _( 'General' ), layout = [
+ Tab(_('General'), _('Basic settings'), layout=[
+ Group(_('General'), layout=[
'service',
- ] ),
- ] ),
+ ]),
+ ]),
]
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
mapping.register('service', 'cn', None, univention.admin.mapping.ListToString)
-from .__common import add_dhcp_options, add_dhcp_objectclass
-
-add_dhcp_options( property_descriptions, mapping, layout )
+from .__common import add_dhcp_options, DhcpOptions
+add_dhcp_options(__name__)
-class object(univention.admin.handlers.simpleLdap):
- module=module
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
+class object(DhcpOptions):
+ module = module
- self.mapping=mapping
- self.descriptions=property_descriptions
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
+ self.setup_options(options)
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('service'), mapping.mapValue('service', self.info['service']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('service'),
+ mapping.mapValue('service', self.info['service']),
+ self.position.getDn()
+ )
def _ldap_addlist(self):
return [
- ('objectClass', [ 'top', 'univentionDhcpService', 'dhcpOptions' ] ),
+ ('objectClass', ['top', 'univentionDhcpService']),
]
- def _ldap_modlist(self):
- ml = univention.admin.handlers.simpleLdap._ldap_modlist( self )
-
- return add_dhcp_objectclass( self, ml )
-
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
-
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.conjunction('|', [
- univention.admin.filter.expression('objectClass', 'dhcpService'),
- univention.admin.filter.expression('objectClass', 'univentionDhcpService')
+ @staticmethod
+ def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.conjunction('|', [
+ univention.admin.filter.expression('objectClass', 'dhcpService'),
+ univention.admin.filter.expression('objectClass', 'univentionDhcpService')
+ ])
])
- ])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
+
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
+lookup_filter = object.lookup_filter
+lookup = object.lookup
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
- return res
def identify(dn, attr):
- return 'dhcpService' in attr.get('objectClass', []) \
- or 'univentionDhcpService' in attr.get('objectClass', [])
+ return bool(set(('dhcpService', 'univentionDhcpService')) & set(attr.get('objectClass', [])))
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/shared.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/shared.py
index d1a068e..5018118 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/shared.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/shared.py
@@ -36,91 +36,88 @@ import univention.admin.handlers
import univention.admin.ipaddress
import univention.admin.localization
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
-
-module='dhcp/shared'
-operations=['add','edit','remove','search']
-superordinate='dhcp/service'
-childs=1
-short_description=_('DHCP: Shared network')
-long_description=''
-options={
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+module = 'dhcp/shared'
+operations = ['add', 'edit', 'remove', 'search']
+superordinate = 'dhcp/service'
+childs = 1
+short_description = _('DHCP: Shared network')
+long_description = ''
+
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'name': univention.admin.property(
- short_description=_('Shared network name'),
- long_description='',
- syntax=univention.admin.syntax.uid,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=0,
- identifies=1
- )
-}
-options={
+ short_description=_('Shared network name'),
+ long_description='',
+ syntax=univention.admin.syntax.uid,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=False,
+ identifies=True
+ )
}
layout = [
- Tab( _( 'General' ), _( 'Basic settings' ), layout = [
- Group( _( 'General' ), layout = [
+ Tab(_('General'), _('Basic settings'), layout=[
+ Group(_('General'), layout=[
'name'
- ] ),
- ] ),
+ ]),
+ ]),
]
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
mapping.register('name', 'cn', None, univention.admin.mapping.ListToString)
-class object(univention.admin.handlers.simpleLdap):
- module=module
+from .__common import add_dhcp_options, DhcpOptions
+add_dhcp_options(__name__)
+
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
+class object(DhcpOptions):
+ module = module
- self.mapping=mapping
- self.descriptions=property_descriptions
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not superordinate:
raise univention.admin.uexceptions.insufficientInformation, 'superordinate object not present'
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
-
- def open(self):
- univention.admin.handlers.simpleLdap.open(self)
-
- self.save()
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
+ self.setup_options(options)
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('name'), mapping.mapValue('name', self.info['name']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('name'),
+ mapping.mapValue('name', self.info['name']),
+ self.position.getDn(),
+ )
def _ldap_addlist(self):
return [
('objectClass', ['top', 'dhcpSharedNetwork'])
]
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.expression('objectClass', 'dhcpSharedNetwork')
- ])
+ @staticmethod
+ def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.expression('objectClass', 'dhcpSharedNetwork')
+ ])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
- return res
+lookup_filter = object.lookup_filter
+lookup = object.lookup
+
def identify(dn, attr):
-
return 'dhcpSharedNetwork' in attr.get('objectClass', [])
-
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/sharedsubnet.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/sharedsubnet.py
index 9fa93da..b8598f9 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/sharedsubnet.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/sharedsubnet.py
@@ -30,145 +30,132 @@
# /usr/share/common-licenses/AGPL-3; if not, see
# .
-import string
-
from univention.admin.layout import Tab, Group
import univention.admin.filter
import univention.admin.handlers
import univention.admin.ipaddress
import univention.admin.localization
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+module = 'dhcp/sharedsubnet'
+operations = ['add', 'edit', 'remove', 'search']
+superordinate = 'dhcp/shared'
+childs = 1
+short_description = _('DHCP: Shared subnet')
+long_description = ''
-module='dhcp/sharedsubnet'
-operations=['add','edit','remove','search']
-superordinate='dhcp/shared'
-childs=1
-short_description=_('DHCP: Shared subnet')
-long_description=''
-options={
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'subnet': univention.admin.property(
- short_description=_('Subnet address'),
- long_description='',
- syntax=univention.admin.syntax.ipv4Address,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=0,
- identifies=1
- ),
+ short_description=_('Subnet address'),
+ long_description='',
+ syntax=univention.admin.syntax.ipv4Address,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=False,
+ identifies=True
+ ),
'subnetmask': univention.admin.property(
- short_description=_('Netmask'),
- long_description='',
- syntax=univention.admin.syntax.v4netmask,
- multivalue=0,
- options=[],
- required=1,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Netmask'),
+ long_description='',
+ syntax=univention.admin.syntax.v4netmask,
+ multivalue=False,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=False
+ ),
'broadcastaddress': univention.admin.property(
- short_description=_('Broadcast address'),
- long_description='',
- syntax=univention.admin.syntax.ipv4Address,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Broadcast address'),
+ long_description='',
+ syntax=univention.admin.syntax.ipv4Address,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
'range': univention.admin.property(
- short_description=_('Dynamic address assignment'),
- long_description=_( 'Define a pool of addresses available for dynamic address assignment.'),
- syntax=univention.admin.syntax.IPv4_AddressRange,
- multivalue=1,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
-}
-
-options={
+ short_description=_('Dynamic address assignment'),
+ long_description=_('Define a pool of addresses available for dynamic address assignment.'),
+ syntax=univention.admin.syntax.IPv4_AddressRange,
+ multivalue=True,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
}
layout = [
- Tab(_('General'), _('Basic settings'), layout = [
- Group( _( 'General' ), layout = [
- [ 'subnet', 'subnetmask' ],
+ Tab(_('General'), _('Basic settings'), layout=[
+ Group(_('General'), layout=[
+ ['subnet', 'subnetmask'],
'broadcastaddress',
'range'
- ] ),
- ] ),
+ ]),
+ ]),
]
-def rangeMap( value ):
- return map( lambda x: ' '.join( x ), value ) or None
-def rangeUnmap( value ):
- return map( lambda x: x.split( ' ' ), value )
+from .__common import rangeMap, rangeUnmap, add_dhcp_options, DhcpOptions
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
mapping.register('subnet', 'cn', None, univention.admin.mapping.ListToString)
mapping.register('range', 'dhcpRange', rangeMap, rangeUnmap)
mapping.register('subnetmask', 'dhcpNetMask', None, univention.admin.mapping.ListToString)
mapping.register('broadcastaddress', 'univentionDhcpBroadcastAddress', None, univention.admin.mapping.ListToString)
-from .__common import add_dhcp_options, add_dhcp_objectclass
-
-add_dhcp_options( property_descriptions, mapping, layout )
+add_dhcp_options(__name__)
-class object(univention.admin.handlers.simpleLdap):
- module=module
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
+class object(DhcpOptions):
+ module = module
- self.superordinate=superordinate
- self.mapping=mapping
- self.descriptions=property_descriptions
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.superordinate = superordinate
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not superordinate:
raise univention.admin.uexceptions.insufficientInformation, 'superordinate object not present'
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
+ self.setup_options(options)
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('subnet'), mapping.mapValue('subnet', self.info['subnet']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('subnet'),
+ mapping.mapValue('subnet', self.info['subnet']),
+ self.position.getDn()
+ )
def _ldap_addlist(self):
return [
- ('objectClass', ['top', 'univentionDhcpSubnet', 'univentionDhcpSharedSubnet', 'dhcpOptions' ]),
+ ('objectClass', ['top', 'univentionDhcpSubnet', 'univentionDhcpSharedSubnet']),
]
- def _ldap_modlist(self):
- ml = univention.admin.handlers.simpleLdap._ldap_modlist( self )
-
- return add_dhcp_objectclass( self, ml )
-
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
+ @staticmethod
+ def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.expression('objectClass', 'univentionDhcpSubnet'),
+ univention.admin.filter.expression('objectClass', 'univentionDhcpSharedSubnet')
+ ])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.expression('objectClass', 'univentionDhcpSubnet'),
- univention.admin.filter.expression('objectClass', 'univentionDhcpSharedSubnet')
- ])
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
+lookup_filter = object.lookup_filter
+lookup = object.lookup
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
- return res
def identify(dn, attr):
- return 'univentionDhcpSubnet' in attr.get('objectClass', []) and 'univentionDhcpSharedSubnet' in attr.get('objectClass', [])
+ return set(('univentionDhcpSubnet', 'univentionDhcpSharedSubnet')) <= set(attr.get('objectClass', []))
diff --git a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/subnet.py b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/subnet.py
index 687392e..8a5ca6b 100644
--- a/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/subnet.py
+++ b/branches/ucs-3.2/ucs-3.2-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/dhcp/subnet.py
@@ -30,146 +30,136 @@
# /usr/share/common-licenses/AGPL-3; if not, see
# .
-import string
-
from univention.admin.layout import Tab, Group
import univention.admin.filter
import univention.admin.handlers
import univention.admin.ipaddress
import univention.admin.localization
-translation=univention.admin.localization.translation('univention.admin.handlers.dhcp')
-_=translation.translate
-
-module='dhcp/subnet'
-operations=['add','edit','remove','search']
-superordinate='dhcp/service'
-childs=1
-usewizard=1
-short_description=_('DHCP: Subnet')
-long_description=''
-options={
+translation = univention.admin.localization.translation('univention.admin.handlers.dhcp')
+_ = translation.translate
+
+module = 'dhcp/subnet'
+operations = ['add', 'edit', 'remove', 'search']
+superordinate = 'dhcp/service'
+childs = 1
+usewizard = 1
+short_description = _('DHCP: Subnet')
+long_description = ''
+
+options = {
}
-property_descriptions={
+
+property_descriptions = {
'subnet': univention.admin.property(
- short_description=_('Subnet address'),
- long_description='',
- syntax=univention.admin.syntax.ipv4Address,
- multivalue=0,
- include_in_default_search=1,
- options=[],
- required=1,
- may_change=0,
- identifies=1
- ),
+ short_description=_('Subnet address'),
+ long_description='',
+ syntax=univention.admin.syntax.ipv4Address,
+ multivalue=False,
+ include_in_default_search=True,
+ options=[],
+ required=True,
+ may_change=False,
+ identifies=True
+ ),
'subnetmask': univention.admin.property(
- short_description=_('Netmask'),
- long_description='',
- syntax=univention.admin.syntax.v4netmask,
- multivalue=0,
- options=[],
- required=1,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Netmask'),
+ long_description='',
+ syntax=univention.admin.syntax.v4netmask,
+ multivalue=False,
+ options=[],
+ required=True,
+ may_change=True,
+ identifies=False
+ ),
'broadcastaddress': univention.admin.property(
- short_description=_('Broadcast address'),
- long_description='',
- syntax=univention.admin.syntax.ipv4Address,
- multivalue=0,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
+ short_description=_('Broadcast address'),
+ long_description='',
+ syntax=univention.admin.syntax.ipv4Address,
+ multivalue=False,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
'range': univention.admin.property(
- short_description=_('Dynamic address assignment'),
- long_description=_( 'Define a pool of addresses available for dynamic address assignment.' ),
- syntax=univention.admin.syntax.IPv4_AddressRange,
- multivalue=1,
- options=[],
- required=0,
- may_change=1,
- identifies=0
- ),
-}
-
-options={
+ short_description=_('Dynamic address assignment'),
+ long_description=_('Define a pool of addresses available for dynamic address assignment.'),
+ syntax=univention.admin.syntax.IPv4_AddressRange,
+ multivalue=True,
+ options=[],
+ required=False,
+ may_change=True,
+ identifies=False
+ ),
}
layout = [
- Tab( _( 'General' ), _('Basic settings'), layout = [
- Group( _( 'General' ), layout = [
- [ 'subnet', 'subnetmask' ],
+ Tab(_('General'), _('Basic settings'), layout=[
+ Group(_('General'), layout=[
+ ['subnet', 'subnetmask'],
'broadcastaddress',
'range'
- ] ),
- ] ),
+ ]),
+ ]),
]
-def rangeMap( value ):
- return map( lambda x: ' '.join( x ), value )
+from .__common import rangeUnmap, add_dhcp_options, DhcpOptions
-def rangeUnmap( value ):
- return map( lambda x: x.split(), value )
-
-mapping=univention.admin.mapping.mapping()
+mapping = univention.admin.mapping.mapping()
mapping.register('subnet', 'cn', None, univention.admin.mapping.ListToString)
mapping.register('subnetmask', 'dhcpNetMask', None, univention.admin.mapping.ListToString)
mapping.register('broadcastaddress', 'univentionDhcpBroadcastAddress', None, univention.admin.mapping.ListToString)
-from .__common import add_dhcp_options, add_dhcp_objectclass
-
-add_dhcp_options( property_descriptions, mapping, layout )
+add_dhcp_options(__name__)
-class object(univention.admin.handlers.simpleLdap):
- module=module
- def __init__(self, co, lo, position, dn='', superordinate=None, attributes = [] ):
- global mapping
- global property_descriptions
+class object(DhcpOptions):
+ module = module
- self.superordinate=superordinate
- self.mapping=mapping
- self.descriptions=property_descriptions
+ def __init__(self, co, lo, position, dn='', superordinate=None, attributes=[]):
+ self.superordinate = superordinate
+ self.mapping = mapping
+ self.descriptions = property_descriptions
if not superordinate:
raise univention.admin.uexceptions.insufficientInformation, 'superordinate object not present'
if not dn and not position:
raise univention.admin.uexceptions.insufficientInformation, 'neither dn nor position present'
- univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes )
-
+ super(object, self).__init__(co, lo, position, dn, superordinate, attributes=attributes)
+ self.setup_options(options)
def open(self):
- univention.admin.handlers.simpleLdap.open(self)
- self.info['range'] = rangeUnmap( self.oldattr.get('dhcpRange', []) )
- self.oldinfo['range'] = rangeUnmap( self.oldattr.get('dhcpRange', []) )
-
+ super(object, self).open()
+ self.info['range'] = self.oldinfo['range'] = rangeUnmap(self.oldattr.get('dhcpRange', []))
def _ldap_pre_create(self):
- self.dn='%s=%s,%s' % (mapping.mapName('subnet'), mapping.mapValue('subnet', self.info['subnet']), self.position.getDn())
+ self.dn = '%s=%s,%s' % (
+ mapping.mapName('subnet'),
+ mapping.mapValue('subnet', self.info['subnet']),
+ self.position.getDn()
+ )
def _ldap_addlist(self):
return [
- ( 'objectClass', [ 'top', 'univentionDhcpSubnet' ] ),
+ ('objectClass', ['top', 'univentionDhcpSubnet']),
]
def _ldap_modlist(self):
-
- ml=univention.admin.handlers.simpleLdap._ldap_modlist(self)
+ ml = super(object, self)._ldap_modlist()
if self.hasChanged('range'):
- dhcpRange=[]
+ dhcpRange = []
for i in self['range']:
for j in self['range']:
if i != j and univention.admin.ipaddress.is_range_overlapping(i, j):
raise univention.admin.uexceptions.rangesOverlapping, '%s-%s; %s-%s' % (i[0], i[1], j[0], j[1])
- ip_in_network=1
+ ip_in_network = True
for j in i:
if not univention.admin.ipaddress.ip_is_in_network(self['subnet'], self['subnetmask'], j):
- ip_in_network=0
+ ip_in_network = False
if univention.admin.ipaddress.ip_is_network_address(self['subnet'], self['subnetmask'], j):
raise univention.admin.uexceptions.rangeInNetworkAddress, '%s-%s' % (i[0], i[1])
@@ -178,32 +168,30 @@ class object(univention.admin.handlers.simpleLdap):
raise univention.admin.uexceptions.rangeInBroadcastAddress, '%s-%s' % (i[0], i[1])
if ip_in_network:
- dhcpRange.append(string.join(i, ' '))
+ dhcpRange.append(' '.join(i))
else:
raise univention.admin.uexceptions.rangeNotInNetwork, '%s-%s' % (i[0], i[1])
#univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'old Range: %s' % self.oldinfo['range'])
if '' in dhcpRange:
dhcpRange.remove('')
ml.append(('dhcpRange', self.oldattr.get('dhcpRange', []), dhcpRange))
- return add_dhcp_objectclass( self, ml )
-def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0):
+ return ml
+
+ @staticmethod
+ def lookup_filter(filter_s=None, lo=None):
+ filter_obj = univention.admin.filter.conjunction('&', [
+ univention.admin.filter.expression('objectClass', 'univentionDhcpSubnet'),
+ univention.admin.filter.conjunction('!', [univention.admin.filter.expression('objectClass', 'univentionDhcpSharedSubnet')])
+ ])
+ filter_obj.append_unmapped_filter_string(filter_s, univention.admin.mapping.mapRewrite, mapping)
+ return filter_obj
- filter=univention.admin.filter.conjunction('&', [
- univention.admin.filter.expression('objectClass', 'univentionDhcpSubnet'),
- univention.admin.filter.conjunction('!', [univention.admin.filter.expression('objectClass', 'univentionDhcpSharedSubnet')])
- ])
- if filter_s:
- filter_p=univention.admin.filter.parse(filter_s)
- univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
- filter.expressions.append(filter_p)
+lookup_filter = object.lookup_filter
+lookup = object.lookup
- res=[]
- for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
- res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs )))
- return res
def identify(dn, attr):
-
- return 'univentionDhcpSubnet' in attr.get('objectClass', []) and not 'univentionDhcpSharedSubnet' in attr.get('objectClass', [])
+ ocs = set(attr.get('objectClass', []))
+ return 'univentionDhcpSubnet' in ocs and not 'univentionDhcpSharedSubnet' in ocs