diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-12-12 21:53:10 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-12-12 21:53:10 +0000 |
commit | 330a28040095fff67e9cb105019f3b4cb7cb5f0e (patch) | |
tree | 802d2a763f9210a3a1f581a9f758bdde301b96df /pynslcd/ether.py | |
parent | f4b3ad848987eb6ac2cf50d7ea99d1a7b579c70c (diff) |
move check of required attributes and other common tests to the Request.handle_entry() method
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1570 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd/ether.py')
-rw-r--r-- | pynslcd/ether.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/pynslcd/ether.py b/pynslcd/ether.py index 756e572..05dea72 100644 --- a/pynslcd/ether.py +++ b/pynslcd/ether.py @@ -40,23 +40,21 @@ filter = '(objectClass=ieee802Device)' class EtherRequest(common.Request): + case_insensitive = ('cn', ) + limit_attributes = ('cn', 'macAddress') + required = ('cn', 'macAddress') + def write(self, dn, attributes, parameters): - # get name and check against requested name + # get names names = attributes['cn'] - if not names: - print 'Error: entry %s does not contain %s value' % ( dn, attmap['cn']) - if 'cn' in parameters: - if parameters['cn'].lower() not in (x.lower() for x in names): - return # skip entry - names = ( parameters['cn'], ) # get addresses and convert to binary form addresses = [ether_aton(x) for x in attributes['macAddress']] - if not addresses: - print 'Error: entry %s does not contain %s value' % ( dn, attmap['macAddress']) if 'macAddress' in parameters: - if ether_aton(parameters['macAddress']) not in addresses: + address = ether_aton(parameters['macAddress']) + if address not in addresses: + print 'value %r for attribute %s not found in %s' % (parameters['macAddress'], attmap['macAddress'], dn) return - addresses = ( ether_aton(parameters['macAddress']), ) + addresses = ( address, ) # write results for name in names: for ether in addresses: |