On Wed, Jun 30, 2010 at 02:14:28PM +0200, Manuel Franceschini wrote:
> This patch series basically adds a new parameter 'family' to the constructors
> of daemon.AsyncUDPSocket and confd.client.ConfdUDPClient. This enables the
> users of these to classes to support IPv6.
> 
> In ganeti-confd.ConfdAsyncUDPClient a method to check the address families of
> all peers is added.
> 
> Furthermore it adds unittests for the added functionality.
> 
> Signed-off-by: Manuel Franceschini <[email protected]>

LGTM, with two small comments:

> @@ -384,6 +385,18 @@ class ConfdClient:
>        else:
>          return MISSING
>  
> +  def _SetPeersAddressFamily(self):
> +    if not self._peers:
> +      raise errors.ConfdClientError("Peer list empty")
> +    try:
> +      peer = self._peers[0]
> +      self._family = utils.GetAddressFamily(peer)
> +      for peer in self._peers[1:]:
> +        if utils.GetAddressFamily(peer) != self._family:
> +          raise errors.ConfdClientError("Peers must be of same address 
> family")

This could be simplified, a bit:
  families = set(utils.GetAddressFamily(peer) for peer in peers)
  if len(families) > 1:
    …

(eliminates the explicit loop)

> +    except errors.GenericError:
> +      raise errors.ConfdClientError("Peer address %s invalid" % peer)
> +
>  
>  # UPCALL_REPLY: server reply upcall
>  # has all ConfdUpcallPayload fields populated
> diff --git a/lib/daemon.py b/lib/daemon.py
> index 304b527..d2fe7bd 100644
> --- a/lib/daemon.py
> +++ b/lib/daemon.py
> @@ -309,13 +309,14 @@ class AsyncUDPSocket(GanetiBaseAsyncoreDispatcher):
>    """An improved asyncore udp socket.
>  
>    """
> -  def __init__(self):
> +  def __init__(self, family):
>      """Constructor for AsyncUDPSocket
>  
>      """
>      GanetiBaseAsyncoreDispatcher.__init__(self)
>      self._out_queue = []
> -    self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
> +    self._family = family
> +    self.create_socket(family, socket.SOCK_DGRAM)
>  
>    # this method is overriding an asyncore.dispatcher method
>    def handle_connect(self):
> @@ -330,7 +331,11 @@ class AsyncUDPSocket(GanetiBaseAsyncoreDispatcher):
>                                        constants.MAX_UDP_DATA_SIZE)
>      if recv_result is not None:
>        payload, address = recv_result
> -      ip, port = address
> +      if self._family == socket.AF_INET6:
> +        ip, port, _, _ = address

Can you add a comment about that we ignore here (the 3rd/4th values)?

iustin

Reply via email to