On Wed, Dec 17, 2014 at 2:03 PM, Paul-Emmanuel Raoul
<skyper...@gmail.com> wrote:
> Thanks for your quick answer.
>
> In fact, I already use several fake bridges and I can't use the
> ovs-docker script to attach a Docker container to an Open vSwitch
> bridge without applying my patch.
>
> If I use the command given in the "INSTALL.Docker.md" document with my
> fake bridge "vlan_dev" for example, I get the following error :
>
>     # ovs-docker add-port vlan_dev eth0 e3db5e5653b0 192.168.70.1/24
>     ovs-vsctl: "--may-exist add-br vlan_dev" but vlan_dev is a VLAN bridge 
> for VLAN 70
>     ovs-docker: Failed to create bridge vlan_dev

I see. Thank you for the explanation. I think I understand the problem.
Can you make the following change and tell me whether that is good
enough for you? ( if so, can you create a patch out of it and send it
to dev@openvswitch.org? If you prefer that I do it, let me know.)

root@ubuntu14:~/git/ovs# git diff
diff --git a/utilities/ovs-docker b/utilities/ovs-docker
index 0c70890..48908b1 100755
--- a/utilities/ovs-docker
+++ b/utilities/ovs-docker
@@ -68,7 +68,8 @@ add_port () {
         exit 1
     fi

-    if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
+    if ovs_vsctl br-exists "$BRIDGE" || \
+        ovs_vsctl add-br "$BRIDGE"; then :; else
         echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
         exit 1
     fi


FYI,
"fake bridge" is sort of a wrapper around vlan ports. You can achieve
the result of a "fake bridge" doing the following too.
ovs-vsctl add-br br0
ovs-vsctl add-port br0 vlan_dev  -- set interface vlan_dev
type=internal -- set port vlan_dev tag=70

ovs-docker add-port br0 eth0 e3db5e5653b0 192.168.70.1/24
ovs-docker set-vlan br0 eth0 e3db5e5653b0 70


>
> On Wed, 2014-12-17 at 13:18 -0800, Gurucharan Shetty wrote:
>> On Wed, Dec 17, 2014 at 12:56 PM, Paul-Emmanuel Raoul
>> <skyper...@gmail.com> wrote:
>> > From 7b693f8f8b5028e445c116531d9d960603222e06 Mon Sep 17 00:00:00 2001
>> > From: Paul-Emmanuel Raoul <sky...@skyplabs.net>
>> > Date: Wed, 17 Dec 2014 02:25:30 +0100
>> > Subject: [PATCH] ovs-docker : add fake bridges support.
>> >
>> > Also updates ovs-docker README documentation.
>> >
>> > Signed-off-by: Paul-Emmanuel Raoul <sky...@skyplabs.net>
>> Can you please tell me the usecase for a 'fake bridge' and why you
>> feel that we need it inside the 'ovs-docker' script? I imagine that a
>> 'fake bridge' can be created asynchronously by simply using ovs-vsctl,
>> no? The only reason a bridge is created right now inside the
>> ovs-docker script is to prevent an error if someone executes this
>> script without previously having created any bridge. I would like to
>> avoid overloading the 'add-port' command.
>>
>> > ---
>> >  INSTALL.Docker.md    |  9 +++++++++
>> >  utilities/ovs-docker | 51
>> > ++++++++++++++++++++++++++++++++++++++-------------
>> >  2 files changed, 47 insertions(+), 13 deletions(-)
>> >
>> > diff --git a/INSTALL.Docker.md b/INSTALL.Docker.md
>> > index ddbef99..29b3a70 100644
>> > --- a/INSTALL.Docker.md
>> > +++ b/INSTALL.Docker.md
>> > @@ -56,10 +56,19 @@ and then attaches it to the Open vSwitch bridge
>> > 'br-int'.  This is done by
>> >  creating a veth pair.  One end of the interface becomes 'eth1' inside
>> > the
>> >  container and the other end attaches to 'br-int'.
>> >
>> > +If an Open vSwitch fake bridge should be used, you have to specify its
>> > +parent and VLAN.  e.g.:
>> > +
>> > +`% ovs-docker add-port br-int br-parent 10 eth1 $CONTAINER_ID`
>> > +
>> >  The script also lets one to add an IP address to the interface.  e.g.:
>> >
>> >  `% ovs-docker add-port br-int eth1 $CONTAINER_ID 192.168.1.1/24`
>> >
>> > +The previous two options can be combined :
>> > +
>> > +`% ovs-docker add-port br-int br-parent 10 eth1 $CONTAINER_ID
>> > 192.168.1.1/24`
>> > +
>> >  * A previously added network interface can be deleted.  e.g.:
>> >
>> >  `% ovs-docker del-port br-int eth1 $CONTAINER_ID`
>> > diff --git a/utilities/ovs-docker b/utilities/ovs-docker
>> > index 4a43a15..e2c306d 100755
>> > --- a/utilities/ovs-docker
>> > +++ b/utilities/ovs-docker
>> > @@ -43,20 +43,44 @@ delete_netns_link () {
>> >  }
>> >
>> >  add_port () {
>> > -    BRIDGE="$1"
>> > -    INTERFACE="$2"
>> > -    CONTAINER="$3"
>> > -    ADDRESS="$4"
>> > -
>> >      if [ "$#" -lt 3 ]; then
>> >          usage
>> >          exit 1
>> > +       elif [ "$#" -eq 3 ]; then
>> > +               BRIDGE="$1"
>> > +               INTERFACE="$2"
>> > +               CONTAINER="$3"
>> > +       elif [ "$#" -eq 4 ]; then
>> > +               BRIDGE="$1"
>> > +               INTERFACE="$2"
>> > +               CONTAINER="$3"
>> > +               ADDRESS="$4"
>> > +       elif [ "$#" -eq 5 ]; then
>> > +               BRIDGE="$1"
>> > +               PARENT="$2"
>> > +               VLAN="$3"
>> > +               INTERFACE="$4"
>> > +               CONTAINER="$5"
>> > +       elif [ "$#" -eq 6 ]; then
>> > +               BRIDGE="$1"
>> > +               PARENT="$2"
>> > +               VLAN="$3"
>> > +               INTERFACE="$4"
>> > +               CONTAINER="$5"
>> > +               ADDRESS="$6"
>> >      fi
>> >
>> > -    if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
>> > -        echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
>> > -        exit 1
>> > -    fi
>> > +       if [ -n "$PARENT" ]; then
>> > +               if ovs_vsctl --may-exist add-br "$BRIDGE" "$PARENT" 
>> > "$VLAN"; then :;
>> > else
>> > +                       echo >&2 "$UTIL: Failed to create fake bridge 
>> > $BRIDGE"
>> > +                       exit 1
>> > +               fi
>> > +       else
>> > +               if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
>> > +                       echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
>> > +                       exit 1
>> > +               fi
>> > +       fi
>> >
>> >      if PID=`docker inspect -f '{{.State.Pid}}' "$CONTAINER"`; then :;
>> > else
>> >          echo >&2 "$UTIL: Failed to get the PID of the container"
>> > @@ -142,11 +166,12 @@ ${UTIL}: Performs integration of Open vSwitch with
>> > Docker.
>> >  usage: ${UTIL} COMMAND
>> >
>> >  Commands:
>> > -  add-port BRIDGE INTERFACE CONTAINER [ADDRESS]
>> > +  add-port BRIDGE [PARENT] [VLAN] INTERFACE CONTAINER [ADDRESS]
>> >                      Adds INTERFACE inside CONTAINER and connects it as
>> > a port
>> > -                    in Open vSwitch BRIDGE. Optionally, sets ADDRESS on
>> > -                    INTERFACE. ADDRESS can include a '/' to represent
>> > network
>> > -                    prefix length. e.g.:
>> > +                    in Open vSwitch BRIDGE. If BRIDGE is a fake bridge,
>> > you
>> > +                    have to specify its PARENT and VLAN. Optionally,
>> > sets
>> > +                    ADDRESS on INTERFACE. ADDRESS can include a '/' to
>> > +                    represent network prefix length. e.g.:
>> >                      ${UTIL} add-port br-int eth1 c474a0e2830e
>> > 192.168.1.2/24
>> >    del-port BRIDGE INTERFACE CONTAINER
>> >                      Deletes INTERFACE inside CONTAINER and removes its
>> > --
>> > 1.9.3
>> >
>> >
>> > _______________________________________________
>> > dev mailing list
>> > dev@openvswitch.org
>> > http://openvswitch.org/mailman/listinfo/dev
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to