Skip to content

Commit

Permalink
resolve network instance type switch creation problem
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Fedchenkov <[email protected]>
  • Loading branch information
giggsoff committed Apr 21, 2021
1 parent a4a2af6 commit 74c38fe
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 56 deletions.
21 changes: 8 additions & 13 deletions pkg/expect/networkInstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand All @@ -63,25 +61,22 @@ 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()},
DhcpRange: &config.IpRange{
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())
Expand Down
1 change: 0 additions & 1 deletion pkg/models/devModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions pkg/models/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 0 additions & 8 deletions pkg/models/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 0 additions & 5 deletions pkg/models/parallels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 0 additions & 8 deletions pkg/models/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 0 additions & 5 deletions pkg/models/rpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 0 additions & 8 deletions pkg/models/vbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 74c38fe

Please sign in to comment.