[ovs-dev] [PATCH 03/12] xenserver: Accept VLAN PIFs in pif_bridge_name().

Ian Campbell Ian.Campbell at citrix.com
Wed Feb 24 02:45:41 PST 2010


On Tue, 2010-02-23 at 17:50 +0000, Ben Pfaff wrote:
> On Tue, Feb 23, 2010 at 10:04:37AM +0000, Ian Campbell wrote:
> > I think this commit makes pif_bridge_name the same in
> > InterfaceReconfigureBridge.py and InterfaceReconfigureVswitch.py.
> > Perhaps we could hoist the function into InterfaceReconfigure.py?
> 
> Thanks for noticing, I hadn't spotted that myself.
> 
> I inserted this between commits 3 and 4:

Looks sane. Thanks.

> --8<--------------------------cut here-------------------------->8--
> 
> From 38884aa21dfb3e2e3026fd04c97f8d6efae7e0e5 Mon Sep 17 00:00:00 2001
> From: Ben Pfaff <blp at nicira.com>
> Date: Tue, 23 Feb 2010 09:47:31 -0800
> Subject: [PATCH] xenserver: Hoist identical bridge and vswitch functions into common code.
> 
> The previous commit made pif_bridge_name() in the bridge and vswitch
> versions of interface-reconfigure functionally identical, so this commit
> hoists them into a single common implementation in InterfaceReconfigure.py.
> 
> pif_is_bridged() also comes along for the ride because it is also generic
> and because it is logically related.  Only the bridge code uses it at the
> moment.
> 
> Suggested-by: Ian Campbell <ian.campbell at citrix.com>
> ---
>  .../opt_xensource_libexec_InterfaceReconfigure.py  |   28 ++++++++++++++++++++
>  ...xensource_libexec_InterfaceReconfigureBridge.py |   28 --------------------
>  ...ensource_libexec_InterfaceReconfigureVswitch.py |   16 -----------
>  3 files changed, 28 insertions(+), 44 deletions(-)
> 
> diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
> index 33f541a..3847cb6 100644
> --- a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
> +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
> @@ -638,6 +638,34 @@ def pif_netdev_name(pif):
>          return pifrec['device']
>  
>  #
> +# Bridges
> +#
> +
> +def pif_is_bridged(pif):
> +    pifrec = db().get_pif_record(pif)
> +    nwrec = db().get_network_record(pifrec['network'])
> +
> +    if nwrec['bridge']:
> +        # TODO: sanity check that nwrec['bridgeless'] != 'true'
> +        return True
> +    else:
> +        # TODO: sanity check that nwrec['bridgeless'] == 'true'
> +        return False
> +
> +def pif_bridge_name(pif):
> +    """Return the bridge name of a pif.
> +
> +    PIF must be a bridged PIF."""
> +    pifrec = db().get_pif_record(pif)
> +
> +    nwrec = db().get_network_record(pifrec['network'])
> +
> +    if nwrec['bridge']:
> +        return nwrec['bridge']
> +    else:
> +        raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
> +
> +#
>  # Bonded PIFs
>  #
>  def pif_is_bond(pif):
> diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py
> index 0fa9322..783fad3 100644
> --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py
> +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py
> @@ -136,34 +136,6 @@ def destroy_bond_device(pif):
>      __destroy_bond_device(name)
>  
>  #
> -# Bridges
> -#
> -
> -def pif_is_bridged(pif):
> -    pifrec = db().get_pif_record(pif)
> -    nwrec = db().get_network_record(pifrec['network'])
> -
> -    if nwrec['bridge']:
> -        # TODO: sanity check that nwrec['bridgeless'] != 'true'
> -        return True
> -    else:
> -        # TODO: sanity check that nwrec['bridgeless'] == 'true'
> -        return False
> -
> -def pif_bridge_name(pif):
> -    """Return the bridge name of a pif.
> -
> -    PIF must be a bridged PIF."""
> -    pifrec = db().get_pif_record(pif)
> -
> -    nwrec = db().get_network_record(pifrec['network'])
> -
> -    if nwrec['bridge']:
> -        return nwrec['bridge']
> -    else:
> -        raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
> -
> -#
>  # Bring Interface up/down.
>  #
>  
> diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
> index f777b17..41acf58 100644
> --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
> +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
> @@ -37,22 +37,6 @@ def netdev_up(netdev, mtu=None):
>      run_command(["/sbin/ifconfig", netdev, 'up'] + mtu)
>  
>  #
> -# Bridges
> -#
> -
> -def pif_bridge_name(pif):
> -    """Return the bridge name of a pif.
> -
> -    PIF must be a bridged PIF."""
> -
> -    pifrec = db().get_pif_record(pif)
> -    nwrec = db().get_network_record(pifrec['network'])
> -    if nwrec['bridge']:
> -        return nwrec['bridge']
> -    else:
> -        raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
> -
> -#
>  # PIF miscellanea
>  #
>  






More information about the dev mailing list