status update: /e/n/i parser and DHCP kinda working

martin f krafft madduck at debian.org
Thu Jun 14 21:21:01 UTC 2007


Dear colleagues,

not sure if anyone reads these updates, but they help me for sure,
so there. :)

Yesterday, following the last status update, I implemented a handler
and parser for /e/n/i, based largely on the work done by Thomas Hood
for his ifupdown 0.7/netconf implementation in Python from two years
ago (see /ref in the netconf/master.git repo).

Enrico Zini then went on to challenge it with some unittests, making
me remember that I had not been doing test-driven development, as
initially planned, but with threads and sockets and all that jazz,
I was having a hard time conceptualising how to do unittests, but
I know I should be working with mock-up objects or temp sockets.

If anyone wants to write unittests for anything in netconf, please
do.

Anyway, /e/n/i parsing and handling works, including mappings. If
I say works, all I mean is that the GETCONF handler obtains data
from the configuration source handlers, but the data is not properly
formatted yet, nor does anything happen on receipt. Keep that in
mind as you read on.

I spent today rethinking the configuration broker. Initially it was
conceived as an entity to be polled by the master daemon, but under
certain circumstances, the broker must be able to signal the client,
for instance:

  - if a DHCP lease cannot be renewed
  - in cases the user changes configuration through a GUI
  - …

I did not actually get as far as the broker because I spent all day
on the DHCP handler, which now works, or at least feeds the
environment variables normally passed to dhclient-script back to the
client (that's not where they end up, this is just demonstration).

  Client:
    connected to socket from PID 13873
    getconf eth0
    EOF received, closing sending socket...
    config: {'new_ip_address': '10.8.251.240', 'new_subnet_mask': '255.255.0.0', 'new_dhcp_server_identifier': '10.8.0.1', 'new_domain_name_servers': '10.8.0.1', 'pid': '13876', 'new_network_number': '10.8.0.0', 'new_expiry': '1185999627', 'new_routers': '10.8.0.1', 'new_domain_name': 'internal.dc7.debconf.org', 'interface': 'eth0', 'PATH': '/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin', 'new_dhcp_message_type': '5', 'reason': 'REBOOT', 'new_dhcp_lease_time': '4147200', 'new_broadcast_address': '10.8.255.255'}

  Daemon:
    MainThread: DEBUG: received event: <CtlSockEvent cmd=getconf args=['eth0'] peer=15400 uid=1000>
    MainThread: DEBUG: no handler for GETCONF known, trying to import...
    MainThread: DEBUG: imported handler: <class 'CtlSockEventHandlers.handlers.GETCONF.Handler'>
    MainThread: DEBUG: registering GETCONF event handler <class 'CtlSockEventHandlers.handlers.GETCONF.Handler'>
    MainThread: DEBUG: asking <cfgsources.handlers.ENI.Handler object at 0xb7aeb1ac> about interface eth0
    MainThread: DEBUG: asking <cfgsources.handlers.DHCP.Handler object at 0xb7b07d6c> about interface eth0
    MainThread: DEBUG: spawning dhclient handler thread
    MainThread: INFO: waiting for DHCP lease...
    dhclientThread_eth0: DEBUG: started dhclient handler thread for iface eth0
    dhclientThread_eth0: INFO: started dhclient[15403] for iface eth0
    dhclientThread_eth0: DEBUG: received pair: ['interface', 'eth0']
    dhclientThread_eth0: DEBUG: received pair: ['PATH', '/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin']
    dhclientThread_eth0: DEBUG: received pair: ['reason', 'PREINIT']
    dhclientThread_eth0: DEBUG: received pair: ['pid', '15403']
    dhclientThread_eth0: DEBUG: processing data received from dhclient...
    dhclientThread_eth0: INFO: got PREINIT: upping interface eth0
    MainThread: DEBUG: received SIGCHLD
    dhclientThread_eth0: DEBUG: received pair: ['new_ip_address', '10.8.251.240']
    dhclientThread_eth0: DEBUG: received pair: ['new_subnet_mask', '255.255.0.0']
    dhclientThread_eth0: DEBUG: received pair: ['new_dhcp_server_identifier', '10.8.0.1']
    dhclientThread_eth0: DEBUG: received pair: ['new_domain_name_servers', '10.8.0.1']
    dhclientThread_eth0: DEBUG: received pair: ['pid', '15403']
    dhclientThread_eth0: DEBUG: received pair: ['new_broadcast_address', '10.8.255.255']
    dhclientThread_eth0: DEBUG: received pair: ['new_network_number', '10.8.0.0']
    dhclientThread_eth0: DEBUG: received pair: ['interface', 'eth0']
    dhclientThread_eth0: DEBUG: received pair: ['new_expiry', '1186001257']
    dhclientThread_eth0: DEBUG: received pair: ['new_routers', '10.8.0.1']
    dhclientThread_eth0: DEBUG: received pair: ['new_domain_name', 'internal.dc7.debconf.org']
    dhclientThread_eth0: DEBUG: received pair: ['reason', 'REBOOT']
    dhclientThread_eth0: DEBUG: received pair: ['PATH', '/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin']
    dhclientThread_eth0: DEBUG: received pair: ['new_dhcp_message_type', '5']
    dhclientThread_eth0: DEBUG: received pair: ['new_dhcp_lease_time', '4147200']
    dhclientThread_eth0: DEBUG: processing data received from dhclient...
    dhclientThread_eth0: DEBUG: received new DHCP config: {'new_ip_address': '10.8.251.240', 'new_expiry': '1186001257', 'new_domain_name': 'internal.dc7.debconf.org', 'new_dhcp_server_identifier': '10.8.0.1', 'new_domain_name_servers': '10.8.0.1', 'pid': '15403', 'new_network_number': '10.8.0.0', 'new_broadcast_address': '10.8.255.255', 'new_dhcp_lease_time': '4147200', 'new_subnet_mask': '255.255.0.0', 'interface': 'eth0', 'PATH': '/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin', 'new_dhcp_message_type': '5', 'reason': 'REBOOT', 'new_routers': '10.8.0.1'}
    MainThread: INFO: dhclient returned: {'new_ip_address': '10.8.251.240', 'new_subnet_mask': '255.255.0.0', 'new_dhcp_server_identifier': '10.8.0.1', 'new_domain_name_servers': '10.8.0.1', 'pid': '15403', 'new_network_number': '10.8.0.0', 'new_expiry': '1186001257', 'new_routers': '10.8.0.1', 'new_domain_name': 'internal.dc7.debconf.org', 'interface': 'eth0', 'PATH': '/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin', 'new_dhcp_message_type': '5', 'reason': 'REBOOT', 'new_dhcp_lease_time': '4147200', 'new_broadcast_address': '10.8.255.255'}
    MainThread: DEBUG: eth0 configuration found by <cfgsources.handlers.DHCP.Handler object at 0xb7b07d6c>
    MainThread: DEBUG: configuration for eth0: {'new_ip_address': '10.8.251.240', 'new_subnet_mask': '255.255.0.0', 'new_dhcp_server_identifier': '10.8.0.1', 'new_domain_name_servers': '10.8.0.1', 'pid': '15403', 'new_network_number': '10.8.0.0', 'new_expiry': '1186001257', 'new_routers': '10.8.0.1', 'new_domain_name': 'internal.dc7.debconf.org', 'interface': 'eth0', 'PATH': '/usr/ucb:/usr/bin:/usr/sbin:/bin:/sbin', 'new_dhcp_message_type': '5', 'reason': 'REBOOT', 'new_dhcp_lease_time': '4147200', 'new_broadcast_address': '10.8.255.255'}
    CtlSockHander_15400: DEBUG: end-of-response received, exiting...

Tomorrow I shall have to think about a generic Interface
configuration struct that can handle all kinds of configuration data
returned from the configuration handlers.

I think a combination of a cfgsources.handlers.ENI.Parser._liface
struct with a dict for additional variable will be swell. Input
welcome.

anon:  git://git.debian.org/git/netconf/netconf/master.git
devel: ssh://git.debian.org/git/netconf/netconf/master.git

If you plan to do work on this, get an alioth account and check out
with ssh. Keep committing and ask me for access. Once I added you to
the netconf project, you can push your commits.

git is really cool.

-- 
 .''`.   martin f. krafft <madduck at debian.org>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
 
"we have a firm commitment to nato, we are a part of nato.
 we have a firm commitment to europe. we are a part of europe." 
                                                      - george w. bush 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature (GPG/PGP)
Url : http://lists.alioth.debian.org/pipermail/netconf-devel/attachments/20070614/9294e559/attachment.pgp 


More information about the netconf-devel mailing list