Bug 37832 - AttributeError: 'NoneType' object has no attribute 'find' when changing IP/MAC addresses
AttributeError: 'NoneType' object has no attribute 'find' when changing IP/MA...
Status: RESOLVED DUPLICATE of bug 16923
Product: UCS
Classification: Unclassified
Component: UMC - Computers
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.0-x
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-02-18 09:55 CET by Florian Best
Modified: 2018-04-13 13:29 CEST (History)
2 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2017031921000102
Bug group (optional): External feedback
Max CVSS v3 score:
best: Patch_Available+


Attachments
patch (784 bytes, patch)
2015-02-26 09:30 CET, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2015-02-18 09:55:43 CET
Execution of command 'udm/put computers/computer' has failed:

Traceback (most recent call last):
  File "%PY2.7%/univention/management/console/modules/__init__.py", line 176, in _decorated
    return function(self, request, *args, **kwargs)
  File "%PY2.7%/notifier/threads.py", line 82, in _run
    tmp = self._function()
  File "%PY2.7%/notifier/__init__.py", line 104, in __call__
    return self._function( *tmp, **self._kwargs )
  File "%PY2.7%/univention/management/console/modules/udm/__init__.py", line 408, in _thread
    module.modify(properties)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 159, in _decorated
    return func(*args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 139, in wrapper_func
    ret = func(*args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 547, in modify
    obj.modify()
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 364, in modify
    return self._modify(modify_childs,ignore_license=ignore_license)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 962, in _modify
    self._ldap_post_modify()
  File "%PY2.7%/univention/admin/handlers/computers/domaincontroller_backup.py", line 585, in _ldap_post_modify
    univention.admin.handlers.simpleComputer._ldap_post_modify( self )
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 2007, in _ldap_post_modify
    self.__add_dns_forward_object( self[ 'name' ], dn, ip )
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 1831, in __add_dns_forward_object
    if ip.find(':')!=-1: #IPv6
AttributeError: 'NoneType' object has no attribute 'find'


Remark:
Updating Computers in UCSM

Version:
4.0-1 errata82 (Walle)
Comment 1 Florian Best univentionstaff 2015-02-26 09:30:11 CET
Created attachment 6721 [details]
patch

He reported it again, 4.0-1 errata84 (Walle)

It is reproducible by having a computer object with 2 MAC or IP addresses but no IP.
When assigning the DNS forward zone for this object, leaving the IP address field emtpy, this traceback occurs.

I don't know why he want to do this but here is a patch.
Comment 2 Florian Best univentionstaff 2015-02-26 09:30:58 CET
(In reply to Florian Best from comment #1)
> It is reproducible by having a computer object with 2 MAC or IP addresses
> but no IP.
but no IP at the forward zone.
Comment 3 Philipp Hahn univentionstaff 2015-03-05 16:22:29 CET
# udm computers/ipmanagedclient create \
> --position "cn=computers,$(ucr get ldap/base)" \
> --set name=storage00 \
> --set description="IBM Storwize V3700" \
> --append inventoryNumber=11S00AR104YM1BBG4CE08K \
> --append inventoryNumber=11S00AR104YM1BBG4CF0ET \
> --append mac=98:be:94:0f:03:5e \
> --append mac=98:be:94:0f:03:5f \
> --append mac=00:90:fa:8b:15:0c \
> --append mac=00:90:fa:8b:15:0e \
> --append ip=10.200.38.10 \
> --append ip=192.168.70.121 \
> --append ip=192.168.70.122 \
> --append mac=98:be:94:0f:08:0c \
> --append mac=98:be:94:0f:08:0d \
> --append mac=00:90:fa:8b:14:e0 \
> --append mac=00:90:fa:8b:14:e2 \
> --set dnsEntryZoneForward="$(udm dns/forward_zone list | sed -ne 's/^DN: //p;T;q')" \
> --set dnsEntryZoneReverse="$(udm dns/reverse_zone list | sed -ne 's/^DN: //p;T;q')"
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 222, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 393, in doit
    out=_doit(arglist)
  File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 804, in _doit
    dn=object.create()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 352, in create
    return self._create()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 790, in _create
    self._ldap_post_create()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/computers/ipmanagedclient.py", line 278, in _ldap_post_create
    univention.admin.handlers.simpleComputer._ldap_post_create( self )
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 2377, in _ldap_post_create
    self.__add_dns_forward_object( self[ 'name' ], dn, ip )
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 1831, in __add_dns_forward_object
    if ip.find(':')!=-1: #IPv6
AttributeError: 'NoneType' object has no attribute 'find'
Comment 4 Florian Best univentionstaff 2016-03-08 13:23:59 CET
(In reply to Philipp Hahn from comment #3)
> > --set dnsEntryZoneForward="$(udm dns/forward_zone list | sed -ne 's/^DN: //p;T;q')" \
> > --set dnsEntryZoneReverse="$(udm dns/reverse_zone list | sed -ne 's/^DN: //p;T;q')"
Well, this is kind of wrong syntax (for multi-ip hosts).
It would work if you set:
--set dnsEntryZoneForward="$(udm dns/forward_zone list | sed -ne 's/^DN: //p;T;q') 192.168.70.121"
--set dnsEntryZoneReverse="$(udm dns/reverse_zone list | sed -ne 's/^DN: //p;T;q') 192.168.70.121"

Nevertheless I think if no IP for the DNS forward zone/ reverse zone / DHCP zonewas provided we should add every IP?

Multiple entries can be added in this way (does somehow not work for dnsEntryZoneReverse):

udm computers/ipmanagedclient create \
--position "cn=computers,$(ucr get ldap/base)" \
--set name=storage00 \
--set description="IBM Storwize V3700" \
--append inventoryNumber=11S00AR104YM1BBG4CE08K \
--append inventoryNumber=11S00AR104YM1BBG4CF0ET \
--append mac=98:be:94:0f:03:5e \
--append mac=98:be:94:0f:03:5f \
--append mac=00:90:fa:8b:15:0c \
--append mac=00:90:fa:8b:15:0e \
--append ip=10.200.38.10 \
--append ip=192.168.70.121 \
--append ip=192.168.70.122 \
--append mac=98:be:94:0f:08:0c \
--append mac=98:be:94:0f:08:0d \
--append mac=00:90:fa:8b:14:e0 \
--append mac=00:90:fa:8b:14:e2 \
--append dnsEntryZoneForward="$(udm dns/forward_zone list | sed -ne 's/^DN: //p;T;q') 10.200.38.10" \
--append dnsEntryZoneForward="$(udm dns/forward_zone list | sed -ne 's/^DN: //p;T;q') 192.168.70.121" \
--append dnsEntryZoneForward="$(udm dns/forward_zone list | sed -ne 's/^DN: //p;T;q') 192.168.70.122" \
--append dnsEntryZoneReverse="$(udm dns/reverse_zone list --filter zoneName=38.200.10.in-addr.arpa | sed -ne 's/^DN: //p;T;q') 10.200.38.10" \
--append dnsEntryZoneReverse="$(udm dns/reverse_zone list --filter zoneName=70.168.192.in-addr.arpa | sed -ne 's/^DN: //p;T;q') 192.168.70.121" \
--append dnsEntryZoneReverse="$(udm dns/reverse_zone list --filter zoneName=70.168.192.in-addr.arpa | sed -ne 's/^DN: //p;T;q') 192.168.70.122"
Comment 5 Florian Best univentionstaff 2016-03-11 08:10:08 CET
Reported again, 4.1-1 errata116

The patch (attachment 6721 [details]) would prevent the traceback but wouldn't set the correct settings.

Better would be to add a entry in the forward zone for every IP:
+                       elif not ip:
+                               for ip in self['ip']:
+                                       self.__add_dns_forward_object(self['name'], dn, ip)

The error also happens if the IP address is malformed.
Comment 6 Philipp Hahn univentionstaff 2016-11-29 11:19:14 CET
May be fixed by r74612 in UCS-4.2-0
Comment 7 Florian Best univentionstaff 2016-11-29 11:35:13 CET
Comment on attachment 6721 [details]
patch

>diff --git a/ucs-4.0-1/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py b/ucs-4.0-1/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
>index 57fe579..1d2d2a8 100644
>--- a/ucs-4.0-1/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
>+++ b/ucs-4.0-1/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
>@@ -2003,7 +2003,7 @@ def _ldap_post_modify( self ):
> 					ip = self['ip'][0]
> 				self.__add_dns_forward_object( self[ 'name' ], dn, ip )
> 				self.__add_related_ptrrecords(dn, ip)
>-			else:
>+			elif ip:
> 				self.__add_dns_forward_object( self[ 'name' ], dn, ip )
> 				self.__add_related_ptrrecords(dn, ip)
>
Comment 8 Florian Best univentionstaff 2016-12-23 16:16:08 CET

*** This bug has been marked as a duplicate of bug 16923 ***