On Tue, Feb 09, 2010 at 12:35:26PM +0000, Balazs Lecz wrote:
> Also add a missing step to run-in-tempdir that copies the Ganeti library
> into the test tempdir.
> 
> Signed-off-by: Balazs Lecz <[email protected]>
> ---
>  Makefile.am              |    3 +-
>  autotools/run-in-tempdir |    1 +
>  daemons/ganeti-nld       |    1 +
>  lib/nflog_dispatcher.py  |   58 
> ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 62 insertions(+), 1 deletions(-)
>  create mode 100644 lib/nflog_dispatcher.py
> 
> diff --git a/Makefile.am b/Makefile.am
> index 474c904..610483f 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -30,7 +30,8 @@ pkgpython_PYTHON = \
>       lib/config.py \
>       lib/iptables.py \
>       lib/networktables.py \
> -     lib/server.py
> +     lib/server.py \
> +     lib/nflog_dispatcher.py
>  

If we keep these in alphabetic order you also avoid the need of adding the
slash at the end of lib/server.py :)

>  nodist_pkgpython_PYTHON = \
>       lib/_autoconf.py
> diff --git a/autotools/run-in-tempdir b/autotools/run-in-tempdir
> index 6f620e6..468ddc3 100755
> --- a/autotools/run-in-tempdir
> +++ b/autotools/run-in-tempdir
> @@ -7,5 +7,6 @@ trap "rm -rf $tmpdir" EXIT
>  
>  cp -r scripts lib test $tmpdir
>  mv $tmpdir/lib $tmpdir/ganeti_nbma
> +cp -r ganeti.git/lib $tmpdir/ganeti
>  
>  cd $tmpdir && "$@"
> diff --git a/daemons/ganeti-nld b/daemons/ganeti-nld
> index 3e0d52f..8805155 100755
> --- a/daemons/ganeti-nld
> +++ b/daemons/ganeti-nld
> @@ -43,6 +43,7 @@ from ganeti_nbma import constants
>  from ganeti_nbma import networktables
>  from ganeti_nbma import config
>  from ganeti_nbma import server
> +from ganeti_nbma import nflog_dispatcher
>  

We probably shouldn't import it yet, if we're not using it.

>  from ganeti import confd
>  from ganeti import constants as gnt_constants
> diff --git a/lib/nflog_dispatcher.py b/lib/nflog_dispatcher.py
> new file mode 100644
> index 0000000..857bac0
> --- /dev/null
> +++ b/lib/nflog_dispatcher.py
> @@ -0,0 +1,58 @@
> +#
> +#
> +
> +# Copyright (C) 2009 Google Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +# 02110-1301, USA.
> +
> +
> +"""Async NFLOG interface
> +
> +"""
> +
> +import asyncore
> +import logging
> +import nflog
> +import sys
> +
> +from socket import AF_INET, inet_ntoa
> +
> +def NFLogLoggingCallback(i, payload):
> +  logging.debug("NFLogLoggingCallback() called. i: %s payload length: %s",
> +                i, payload.get_length())
> +  return 1
> +
> +
> +class AsyncNFLog(asyncore.file_dispatcher):
> +  """An asyncore dispatcher of NFLOG events.
> +
> +  """
> +
> +  def __init__(self, callback, log_group=0, family=AF_INET,
> +               asyncore_channel_map=None):
> +    self._q = nflog.log()
> +    self._q.set_callback(callback)
> +    self._q.fast_open(log_group, family)
> +    self.fd = self._q.get_fd()
> +    asyncore.file_dispatcher.__init__(self, self.fd, asyncore_channel_map)
> +    self._q.set_mode(nflog.NFULNL_COPY_PACKET)
> +
> +  def handle_read(self):
> +    self._q.process_pending(5)
> +
> +  # We don't need to check for the socket to be ready for writing
> +  def writable(self):
> +    return False

LGTM for the rest

Thanks,

Guido

Reply via email to