From 081f77a1025d39f4dcfdb608bd43beb486ffcbb1 Mon Sep 17 00:00:00 2001 From: Sam Tresler Date: Tue, 23 Jun 2015 11:21:26 -0400 Subject: [PATCH] Persisting bond options to the netdev file, and updating the test. --- network/interface.go | 12 +++++++++++- network/interface_test.go | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/network/interface.go b/network/interface.go index 877cb9e..73a83cb 100644 --- a/network/interface.go +++ b/network/interface.go @@ -130,7 +130,17 @@ type bondInterface struct { } func (b *bondInterface) Netdev() string { - return fmt.Sprintf("[NetDev]\nKind=bond\nName=%s\n", b.name) + config := fmt.Sprintf("[NetDev]\nKind=bond\nName=%s\n", b.name) + if b.hwaddr != nil { + config += fmt.Sprintf("MACAddress=%s\n", b.hwaddr.String()) + } + + config += fmt.Sprintf("\n[Bond]\n") + for _, name := range sortedKeys(b.options) { + config += fmt.Sprintf("%s=%s\n", name, b.options[name]) + } + + return config } func (b *bondInterface) Type() string { diff --git a/network/interface_test.go b/network/interface_test.go index df6eea3..5cafc93 100644 --- a/network/interface_test.go +++ b/network/interface_test.go @@ -52,7 +52,7 @@ func TestInterfaceGenerators(t *testing.T) { }, { name: "testname", - netdev: "[NetDev]\nKind=bond\nName=testname\n", + netdev: "[NetDev]\nKind=bond\nName=testname\n\n[Bond]\n", network: "[Match]\nName=testname\n\n[Network]\nBond=testbond1\nVLAN=testvlan1\nVLAN=testvlan2\nDHCP=true\n", kind: "bond", iface: &bondInterface{logicalInterface: logicalInterface{