From d3e11d0616edf8c1bae54010e1cb822d0f49c2be Mon Sep 17 00:00:00 2001 From: Vladik Romanovsky Date: Fri, 25 May 2018 01:53:16 -0400 Subject: [PATCH] Pass vm object to the network setup Signed-off-by: Vladik Romanovsky --- pkg/virt-launcher/virtwrap/manager.go | 2 +- pkg/virt-launcher/virtwrap/manager_test.go | 2 +- .../virtwrap/network/network_test.go | 16 ---------------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/pkg/virt-launcher/virtwrap/manager.go b/pkg/virt-launcher/virtwrap/manager.go index ad5a66f40e62..a22e7434b9b5 100644 --- a/pkg/virt-launcher/virtwrap/manager.go +++ b/pkg/virt-launcher/virtwrap/manager.go @@ -97,7 +97,7 @@ func (l *LibvirtDomainManager) preStartHook(vm *v1.VirtualMachine, domain *api.D } // setup networking - err = network.SetupPodNetwork(domain) + err = network.SetupPodNetwork(vm, domain) if err != nil { return domain, err } diff --git a/pkg/virt-launcher/virtwrap/manager_test.go b/pkg/virt-launcher/virtwrap/manager_test.go index 10877d2b60ce..37cc255ecd4a 100644 --- a/pkg/virt-launcher/virtwrap/manager_test.go +++ b/pkg/virt-launcher/virtwrap/manager_test.go @@ -211,5 +211,5 @@ func newVM(namespace string, name string) *v1.VirtualMachine { } func StubOutNetworkForTest() { - network.SetupPodNetwork = func(domain *api.Domain) error { return nil } + network.SetupPodNetwork = func(vm *v1.VirtualMachine, domain *api.Domain) error { return nil } } diff --git a/pkg/virt-launcher/virtwrap/network/network_test.go b/pkg/virt-launcher/virtwrap/network/network_test.go index 2c0d9e1348b2..55860d6153bf 100644 --- a/pkg/virt-launcher/virtwrap/network/network_test.go +++ b/pkg/virt-launcher/virtwrap/network/network_test.go @@ -61,7 +61,6 @@ var _ = Describe("Network", func() { mockNetworkInterface.EXPECT().Plug(iface, defaultNet, domain) err := SetupNetworkInterfaces(vm, domain) Expect(err).To(BeNil()) - Expect(len(domain.Spec.Devices.Interfaces)).To(Equal(1)) }) It("should fail when no network is specified", func() { domain := &api.Domain{} @@ -74,18 +73,3 @@ var _ = Describe("Network", func() { }) }) }) - -func NewDomainWithPodNetwork() *api.Domain { - - domain := &api.Domain{} - domain.Spec.Devices.Interfaces = []api.Interface{{ - Model: &api.Model{ - Type: "virtio", - }, - Type: "bridge", - Source: api.InterfaceSource{ - Bridge: api.DefaultBridgeName, - }}, - } - return domain -}