[openstack-dev] [Neutron][ML2] Modular L2 agent architecture

Zang MingJie zealot0630 at gmail.com
Thu Jun 19 10:26:19 UTC 2014


I don't like the idea of ResourceDriver and AgentDriver. I suggested
use a singleton worker thread to manager all underlying setup, so the
driver should do nothing other than fire a update event to the worker.

The worker thread may looks like this one:

# the only variable store all local state which survives between
different events, including lvm, fdb or whatever
state = {}

# loop forever
while True:
    event = ev_queue.pop()
    if not event:
        sleep() # may be interrupted when new event comes

    origin_state = state
    new_state = event.merge_state(state)

    if event.is_ovsdb_changed():
        if event.is_tunnel_changed():
            setup_tunnel(new_state, old_state, event)
        if event.is_port_tags_changed():
            setup_port_tags(new_state, old_state, event)

    if event.is_flow_changed():
        if event.is_flow_table_1_changed():
            setup_flow_table_1(new_state, old_state, event)
        if event.is_flow_table_2_changed():
            setup_flow_table_2(new_state, old_state, event)
        if event.is_flow_table_3_changed():
            setup_flow_table_3(new_state, old_state, event)
        if event.is_flow_table_4_changed():
            setup_flow_table_4(new_state, old_state, event)

    if event.is_iptable_changed():
        if event.is_iptable_nat_changed():
            setup_iptable_nat(new_state, old_state, event)
        if event.is_iptable_filter_changed():
            setup_iptable_filter(new_state, old_state, event)

   state = new_state

when any part has been changed by a event, the corresponding setup_xxx
function rebuild the whole part, then use the restore like
`iptables-restore` or `ovs-ofctl replace-flows` to reset the whole

More information about the OpenStack-dev mailing list