From 6ef4b49a72ba20fb469c243bde78834f3c9fc9a4 Mon Sep 17 00:00:00 2001 From: Patrick Dumais Date: Tue, 22 Aug 2023 07:12:31 -0400 Subject: [PATCH] List OVS bridges to allow for OF version >1.0 (#1539) * # This is a combination of 3 commits. # This is the 1st commit message: Listing bridges # This is the commit message #2: Listing bridges # This is the commit message #3: Listing bridges * listing ovs bridges Co-authored-by: pdumais --------- Co-authored-by: Pat Dumais Co-authored-by: Roman Dodin --- docs/rn/0.44.md | 1 + nodes/ovs/ovs.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/rn/0.44.md b/docs/rn/0.44.md index 8f0330b8c..7983e35fd 100644 --- a/docs/rn/0.44.md +++ b/docs/rn/0.44.md @@ -49,3 +49,4 @@ Read more about this feature in the [Certificates Management](../manual/cert.md# * fixing CLAB_INTFS env var #1547 * fixing node filtering functionality #1549 +* fixing ovs bridges and openflow 1.3 #1539 diff --git a/nodes/ovs/ovs.go b/nodes/ovs/ovs.go index d76791897..1f6efd45c 100644 --- a/nodes/ovs/ovs.go +++ b/nodes/ovs/ovs.go @@ -12,6 +12,7 @@ import ( goOvs "github.com/digitalocean/go-openvswitch/ovs" log "github.com/sirupsen/logrus" cExec "github.com/srl-labs/containerlab/clab/exec" + "github.com/srl-labs/containerlab/internal/slices" "github.com/srl-labs/containerlab/links" "github.com/srl-labs/containerlab/nodes" "github.com/srl-labs/containerlab/nodes/state" @@ -54,7 +55,14 @@ func (n *ovs) CheckDeploymentConditions(_ context.Context) error { goOvs.Sudo(), ) - if _, err := c.VSwitch.Get.Bridge(n.Cfg.ShortName); err != nil { + // We were previously doing c.VSwitch.Get.Bridge() but it doesn't work + // when the bridge has a protocol version higher than 1.0 + // So listing the bridges is safer + bridges, err := c.VSwitch.ListBridges() + if err != nil { + return fmt.Errorf("error while listing ovs bridges: %v", err) + } + if !slices.Contains(bridges, n.Cfg.ShortName) { return fmt.Errorf("could not find ovs bridge %q", n.Cfg.ShortName) }