Skip to content

Commit 64bb3e0

Browse files
committed
Support arbitrary bridge config options
1 parent 1a494c8 commit 64bb3e0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

ovs/vswitch.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ type BridgeOptions struct {
211211
// STP defines if the spanning tree protocol is to be enabled on the bridge. A
212212
// nil value here will not change the STP config of the bridge.
213213
STP *bool
214+
215+
// Other defines bridge config options not otherwise present in this package
216+
// but available in ovs such as rstp options (e.g. `rstp_enable=false`).
217+
Other []string
214218
}
215219

216220
// slice creates a string slice containing any non-zero option values from the
@@ -230,7 +234,7 @@ func (o BridgeOptions) slice() []string {
230234
s = append(s, fmt.Sprintf("stp_enable=%s", strconv.FormatBool(*o.STP)))
231235
}
232236

233-
return s
237+
return append(s, o.Other...)
234238
}
235239

236240
// Interface sets configuration for an interface using the values from an

ovs/vswitch_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ func TestClientVSwitchSetBridgeOptionsOK(t *testing.T) {
474474
}
475475
hwaddr := "55:84:a3:2f:d3:20"
476476
stp := true
477+
other := []string{"rstp_enable=false"}
477478

478479
c := testClient([]OptionFunc{Timeout(1)}, func(cmd string, args ...string) ([]byte, error) {
479480
if want, got := "ovs-vsctl", cmd; want != got {
@@ -490,6 +491,7 @@ func TestClientVSwitchSetBridgeOptionsOK(t *testing.T) {
490491
fmt.Sprintf("other-config:hwaddr=%s", hwaddr),
491492
fmt.Sprintf("stp_enable=%s", strconv.FormatBool(stp)),
492493
}
494+
wantArgs = append(wantArgs, other...)
493495
if want, got := wantArgs, args; !reflect.DeepEqual(want, got) {
494496
t.Fatalf("incorrect arguments\n- want: %v\n- got: %v",
495497
want, got)
@@ -502,6 +504,7 @@ func TestClientVSwitchSetBridgeOptionsOK(t *testing.T) {
502504
Protocols: protocols,
503505
HWAddr: hwaddr,
504506
STP: &stp,
507+
Other: other,
505508
})
506509
if err != nil {
507510
t.Fatalf("unexpected error for Client.VSwitch.Set.Bridge: %v", err)

0 commit comments

Comments
 (0)