diff --git a/pkg/expect/networkInstance.go b/pkg/expect/networkInstance.go index a3d20c504..1b3988c45 100644 --- a/pkg/expect/networkInstance.go +++ b/pkg/expect/networkInstance.go @@ -7,7 +7,6 @@ import ( "time" "github.com/docker/docker/pkg/namesgenerator" - "github.com/lf-edge/eden/pkg/models" "github.com/lf-edge/eden/pkg/utils" "github.com/lf-edge/eve/api/go/config" "github.com/lf-edge/eve/api/go/evecommon" @@ -45,7 +44,6 @@ func (exp *AppExpectation) createNetworkInstance(instanceExpect *NetInstanceExpe if err != nil { return nil, err } - subentIPs := utils.GetSubnetIPs(instanceExpect.subnet) adapter := exp.uplinkAdapter if instanceExpect.uplinkAdapter != "" { adapter = &config.Adapter{ @@ -63,7 +61,14 @@ func (exp *AppExpectation) createNetworkInstance(instanceExpect *NetInstanceExpe Port: adapter, Cfg: &config.NetworkInstanceOpaqueConfig{}, IpType: config.AddressType_IPV4, - Ip: &config.Ipspec{ + Ip: &config.Ipspec{}, + Dns: nil, + } + if instanceExpect.netInstType == "switch" { + netInst.InstType = config.ZNetworkInstType_ZnetInstSwitch + } else { + subentIPs := utils.GetSubnetIPs(instanceExpect.subnet) + netInst.Ip = &config.Ipspec{ Subnet: instanceExpect.subnet, Gateway: subentIPs[1].String(), Dns: []string{subentIPs[1].String()}, @@ -71,17 +76,7 @@ func (exp *AppExpectation) createNetworkInstance(instanceExpect *NetInstanceExpe Start: subentIPs[2].String(), End: subentIPs[len(subentIPs)-2].String(), }, - }, - Dns: nil, - } - if instanceExpect.netInstType == "switch" { - netInst.InstType = config.ZNetworkInstType_ZnetInstSwitch - devModel, err := models.GetDevModelByName(exp.ctrl.GetVars().DevModel) - if err != nil { - log.Fatal(err) } - netInst.Port = &config.Adapter{Name: devModel.GetFirstAdapterForSwitches()} - netInst.Ip = &config.Ipspec{} } if instanceExpect.name == "" { rand.Seed(time.Now().UnixNano()) diff --git a/pkg/models/devModel.go b/pkg/models/devModel.go index d7d88c03d..c9fb5c50a 100644 --- a/pkg/models/devModel.go +++ b/pkg/models/devModel.go @@ -68,7 +68,6 @@ type DevModel interface { SetPhysicalIOs([]*config.PhysicalIO) AdapterForSwitches() []string DevModelType() string - GetFirstAdapterForSwitches() string SetWiFiParams(ssid string, psk string) GetPortConfig(ssid string, psk string) string DiskFormat() string diff --git a/pkg/models/gcp.go b/pkg/models/gcp.go index 79ac36fbd..c348fd2d8 100644 --- a/pkg/models/gcp.go +++ b/pkg/models/gcp.go @@ -82,14 +82,6 @@ func (ctx *DevModelGCP) DevModelType() string { return string(devModelTypeGCP) } -//GetFirstAdapterForSwitches return first adapter available for switch networkInstance -func (ctx *DevModelGCP) GetFirstAdapterForSwitches() string { - if len(ctx.adapterForSwitches) > 0 { - return ctx.adapterForSwitches[0] - } - return "uplink" -} - func createGCP() (DevModel, error) { return &DevModelGCP{ physicalIOs: generatePhysicalIOs(1, 0, 0), diff --git a/pkg/models/general.go b/pkg/models/general.go index cb2990e7d..fbd62b1e5 100644 --- a/pkg/models/general.go +++ b/pkg/models/general.go @@ -82,14 +82,6 @@ func (ctx *DevModelGeneral) DevModelType() string { return string(devModelTypeGeneral) } -//GetFirstAdapterForSwitches return first adapter available for switch networkInstance -func (ctx *DevModelGeneral) GetFirstAdapterForSwitches() string { - if len(ctx.adapterForSwitches) > 0 { - return ctx.adapterForSwitches[0] - } - return "uplink" -} - func createGeneral() (DevModel, error) { return &DevModelGeneral{ physicalIOs: generatePhysicalIOs(2, 0, 0), diff --git a/pkg/models/parallels.go b/pkg/models/parallels.go index 6f9f4324b..2be994290 100644 --- a/pkg/models/parallels.go +++ b/pkg/models/parallels.go @@ -78,11 +78,6 @@ func (ctx *DevModelParallels) DevModelType() string { return string(devModelTypeParallels) } -//GetFirstAdapterForSwitches return first adapter available for switch networkInstance -func (ctx *DevModelParallels) GetFirstAdapterForSwitches() string { - return "uplink" -} - func createParallels() (DevModel, error) { return &DevModelParallels{ physicalIOs: generatePhysicalIOs(2, 0, 4), diff --git a/pkg/models/qemu.go b/pkg/models/qemu.go index cab47cbf2..24af2b62a 100644 --- a/pkg/models/qemu.go +++ b/pkg/models/qemu.go @@ -76,14 +76,6 @@ func (ctx *DevModelQemu) DevModelType() string { return string(devModelTypeQemu) } -//GetFirstAdapterForSwitches return first adapter available for switch networkInstance -func (ctx *DevModelQemu) GetFirstAdapterForSwitches() string { - if len(ctx.adapterForSwitches) > 0 { - return ctx.adapterForSwitches[0] - } - return "uplink" -} - func createQemu() (DevModel, error) { return &DevModelQemu{ physicalIOs: generatePhysicalIOs(2, 0, 4), diff --git a/pkg/models/rpi.go b/pkg/models/rpi.go index 238352af4..4f5561fec 100644 --- a/pkg/models/rpi.go +++ b/pkg/models/rpi.go @@ -146,11 +146,6 @@ func (ctx *DevModelRpi) DevModelType() string { return string(devModelTypeRaspberry) } -//GetFirstAdapterForSwitches return first adapter available for switch networkInstance -func (ctx *DevModelRpi) GetFirstAdapterForSwitches() string { - return "uplink" -} - func createRpi() (DevModel, error) { return &DevModelRpi{ physicalIOs: generatePhysicalIOs(1, 1, 0), diff --git a/pkg/models/vbox.go b/pkg/models/vbox.go index 63bf57d00..32870324d 100644 --- a/pkg/models/vbox.go +++ b/pkg/models/vbox.go @@ -79,14 +79,6 @@ func (ctx *DevModelVBox) DevModelType() string { return string(devModelTypeVBox) } -//GetFirstAdapterForSwitches return first adapter available for switch networkInstance -func (ctx *DevModelVBox) GetFirstAdapterForSwitches() string { - if len(ctx.adapterForSwitches) > 0 { - return ctx.adapterForSwitches[0] - } - return "uplink" -} - func createVBox() (DevModel, error) { return &DevModelVBox{ physicalIOs: generatePhysicalIOs(2, 0, 4),