summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2012-01-20 15:10:44 -0500
committerMartin Kosek <mkosek@redhat.com>2012-01-26 14:13:29 +0100
commitd8314c5c054b98a3e583477eff66e6067745f0b6 (patch)
treecd49f31dbd85c32a80dd6306f10ac3ad293e6fc7 /ipalib
parent099cb7dc054f6d5941e8243a0c528ac0ace63557 (diff)
downloadfreeipa.git-d8314c5c054b98a3e583477eff66e6067745f0b6.tar.gz
freeipa.git-d8314c5c054b98a3e583477eff66e6067745f0b6.tar.xz
freeipa.git-d8314c5c054b98a3e583477eff66e6067745f0b6.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')
-rw-r--r--ipalib/plugins/host.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index fb5f4ea2..a37297e4 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