diff options
author | Rob Crittenden <rcritten@redhat.com> | 2012-01-20 15:10:44 -0500 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-01-26 14:11:33 +0100 |
commit | 52e3488b75e1ed2de7a021148169901a522dbbcb (patch) | |
tree | caa45cbdf88aa0ef96e16b1651bea49ddfad52ec /ipalib/plugins | |
parent | ed061ce91011ce6ebf99c46f6424f0ee14d42def (diff) | |
download | freeipa-52e3488b75e1ed2de7a021148169901a522dbbcb.tar.gz freeipa-52e3488b75e1ed2de7a021148169901a522dbbcb.tar.xz freeipa-52e3488b75e1ed2de7a021148169901a522dbbcb.zip |
Add support for storing MAC address in host entries.
macaddress is a multi-valued attribute and we allow multiple entries.
This is from the objectclass ieee802device. This is added manually when
doing a mod or add and not as a default to support existing host entries
that do not have this objectclass. If this were added to the defaults
then existing hosts missing this objectclass would not be found by
host-find.
It is possible to get ethers data out of nss by configuring nsswitch.conf
to use ldap for ethers and running getent ethers <hostname>
I tested nslcd and it only returned one macaddress value.
https://fedorahosted.org/freeipa/ticket/1132
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/host.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index fb5f4ea24..a37297e48 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -224,7 +224,7 @@ class host(LDAPObject): default_attributes = [ 'fqdn', 'description', 'l', 'nshostlocation', 'krbprincipalname', 'nshardwareplatform', 'nsosversion', 'usercertificate', 'memberof', - 'managedby', 'memberindirect', 'memberofindirect', + 'managedby', 'memberindirect', 'memberofindirect', 'macaddress', ] uuid_attribute = 'ipauniqueid' attribute_members = { @@ -306,6 +306,14 @@ class host(LDAPObject): label=_('Principal name'), flags=['no_create', 'no_update', 'no_search'], ), + Str('macaddress*', + normalizer=lambda value: value.upper(), + pattern='^([a-fA-F0-9]{2}[:|\-]?){5}[a-fA-F0-9]{2}$', + pattern_errmsg='Must be of the form HH:HH:HH:HH:HH:HH, where each H is a hexadecimal character.', + csv=True, + label=_('MAC address'), + doc=_('Hardware MAC address(es) on this host'), + ), ) def get_dn(self, *keys, **options): @@ -442,6 +450,7 @@ class host_add(LDAPCreate): x509.verify_cert_subject(ldap, keys[-1], cert) entry_attrs['usercertificate'] = cert entry_attrs['managedby'] = dn + entry_attrs['objectclass'].append('ieee802device') return dn def post_callback(self, ldap, dn, entry_attrs, *keys, **options): @@ -681,6 +690,17 @@ class host_mod(LDAPUpdate): if options.get('random'): entry_attrs['userpassword'] = ipa_generate_password() setattr(context, 'randompassword', entry_attrs['userpassword']) + if 'macaddress' in entry_attrs: + if 'objectclass' in entry_attrs: + obj_classes = entry_attrs['objectclass'] + else: + (_dn, _entry_attrs) = ldap.get_entry( + dn, ['objectclass'] + ) + obj_classes = _entry_attrs['objectclass'] + if 'ieee802device' not in obj_classes: + obj_classes.append('ieee802device') + entry_attrs['objectclass'] = obj_classes return dn |