[PATCH] samba.netbios module Python 3 compatible

Lumir Balhar lbalhar at redhat.com
Wed Aug 2 09:23:19 UTC 2017


On 06/28/2017 08:17 AM, Andreas Schneider via samba-technical wrote:
> On Tuesday, 27 June 2017 22:43:05 CEST Lumir Balhar via samba-technical wrote:
>> On 06/27/2017 06:54 PM, Andrew Bartlett via samba-technical wrote:
>>> On Tue, 2017-06-27 at 13:00 +0200, Lumir Balhar via samba-technical
>>>
>>> wrote:
>>>> Hello.
>>>>
>>>> I've ported Python module samba.netbios to Python 3 compatible form.
>>>>
>>>> As discussed before [0], it's really hard to write tests for modules
>>>> like this because it works mostly with networks. I've tried to write
>>>> some tests but I am only able test proper exceptions raising. I tested
>>>> ported module manually on my LAN.
>>>>
>>>> [0]
>>>> https://lists.samba.org/archive/samba-technical/2017-June/120869.html
>>>> and https://lists.samba.org/archive/samba-technical/2017-May/120863.html
>>>>
>>>> Thank you and have a nice day.
>>> Sorry, ENOPATCH :-)
>> Sorry, I forget to add an attachment. :-)
>>
>>> We have a full emulated network in make test, so network tests should
>>> be entirely practical.  Mostly just run it in an environment (rather
>>> than none) and have it interrogate $SERVER from the environment.
>> Could you please show me some example of tests which use emulated
>> network? Or create one for samba.netbios which I can use as an example?
> If you reach me over internal IRC or just call my internal number we can have
> a share screen session and I explain you our awesome test environment ;)
>
>
> 	Andreas
>

Hello.

Thanks to Andreas, I know a lot more about samba testing environments 
but with netbios module, I am lost.

I have samba.netbios ported to Python 3 compatible form and I can use it 
on my LAN. For example:

 >>> from samba import netbios
 >>> n = netbios.Node()
 >>> n.query_name('frenzy-nas', '10.0.0.5', timeout=2)
('10.0.0.5', ('frenzy-nas', 0), ['10.0.0.5'])
 >>> n.name_status('frenzy-nas', '10.0.0.5', timeout=2)
('10.0.0.5', ('frenzy-nas', 0), [('FRENZY-NAS     ', 1024, 0), 
('FRENZY-NAS     ', 1024, 3), ('FRENZY-NAS     ', 1024, 32), 
('WORKGROUP      ', 33792, 0), ('WORKGROUP      ', 33792, 30)])

Frenzy-nas is my local NAS and '10.0.0.5' is its IP address. The same 
example works also in Python 3.

But when I try the same check in 'ad_dc' test environment, it fails. For 
example:

 >>> from samba import netbios
 >>> n = netbios.Node()
 >>> n.query_name('addomain', '127.0.0.30', timeout=2)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
samba.NTSTATUSError: (-1073741643, '{Device Timeout} The specified I/O 
operation on %hs was not completed before the time-out period expired.')
 >>> n.name_status('addomain', '127.0.0.30', timeout=2)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
samba.NTSTATUSError: (-1073741643, '{Device Timeout} The specified I/O 
operation on %hs was not completed before the time-out period expired.')

'addomain' is in $DOMAIN and '127.0.0.30' is in $SERVER_IP.

 From this point of view it seems that there is something wrong in the 
testing environment and samba isn't providing netbios but when I try the 
same query with nmblookup, it works.

$ bin/nmblookup addomain
127.0.0.30 addomain<00>

I don't know what I am doing wrong. Could you please help me find out 
why is there a difference between netbios queries from the Python module 
and nmblookup tool?

Thank you. Have a nice day.
Lumír



More information about the samba-technical mailing list