Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Lin committed Jul 6, 2018
1 parent b6888de commit 9f43e25
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
18 changes: 9 additions & 9 deletions src/entity/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ const (
)

type Network struct {
ID bson.ObjectId `bson:"_id,omitempty" json:"id"`
Type NetworkType `bson:"type" json:"type"`
Name string `bson:"name" json:"name"`
Clusterwise bool `bson:"clusterwise" json:"clusterwise"`
NodeName string `bson:"nodeName,omitempty" json:"nodeName,omitempty"`
CreatedAt *time.Time `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
OVS OVSNetwork `bson:"ovs,omitempty" json:"ovs"`
OVSDPDK OVSDPDKNetwork `bson:"ovsdpdk,omitempty" json:"ovsdpdk"`
Fake FakeNetwork `json:"fake"` //FakeNetwork, for restful testing.
ID bson.ObjectId `bson:"_id,omitempty" json:"id"`
Type NetworkType `bson:"type" json:"type"`
Name string `bson:"name" json:"name"`
Clusterwise bool `bson:"clusterwise" json:"clusterwise"`
NodeName string `bson:"nodeName,omitempty" json:"nodeName,omitempty"`
CreatedAt *time.Time `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
OVS OVSNetwork `bson:"ovs,omitempty" json:"ovs"`
OVSUserspace OVSUserspaceNetwork `bson:"ovsUserspace,omitempty" json:"ovsUserspace"`
Fake FakeNetwork `json:"fake"` //FakeNetwork, for restful testing.
}

//GetCollection - get model mongo collection name.
Expand Down
8 changes: 5 additions & 3 deletions src/entity/network_dpdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ type DPDKPhysicalPort struct {
VlanTags []int32 `bson:"vlanTags" json:"vlanTags"`
}

type OVSDPDKNetwork struct {
BridgeName string `bson:"bridgeName" json:"bridgeName"`
DPDKPhysicalPorts []DPDKPhysicalPort `bson:"physicalPorts" json:"physicalPorts"`
type OVSUserspaceNetwork struct {
BridgeName string `bson:"bridgeName" json:"bridgeName"`
// exclusive fields
PhysicalPorts []PhysicalPort `bson:"physicalPorts" json:"physicalPorts"`
DPDKPhysicalPorts []DPDKPhysicalPort `bson:"dpdkPhysicalPorts" json:"dpdkPhysicalPorts"`
}
2 changes: 1 addition & 1 deletion src/networkprovider/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func GetNetworkProvider(network *entity.Network) (NetworkProvider, error) {
case entity.OVSKernelspaceNetworkType:
return OVSNetworkProvider{network.OVS}, nil
case entity.OVSUserspaceNetworkType:
return OVSUserspaceNetworkProvider{network.OVSDPDK}, nil
return OVSUserspaceNetworkProvider{network.OVSUserspace}, nil
case entity.FakeNetworkType:
return FakeNetworkProvider{network.Fake}, nil
default:
Expand Down
6 changes: 3 additions & 3 deletions src/networkprovider/ovs_netdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type OVSUserspaceNetworkProvider struct {
entity.OVSDPDKNetwork
entity.OVSUserspaceNetwork
}

func (ovsu OVSUserspaceNetworkProvider) ValidateBeforeCreating(sp *serviceprovider.Container, network *entity.Network) error {
Expand Down Expand Up @@ -53,7 +53,7 @@ func (ovsu OVSUserspaceNetworkProvider) CreateNetwork(sp *serviceprovider.Contai
return err
}
// TODO if dpdk==true
if err := createOVSDPDKNetwork(nodeIP, network.OVSDPDK.BridgeName, network.OVSDPDK.DPDKPhysicalPorts); err != nil {
if err := createOVSDPDKNetwork(nodeIP, network.OVSUserspace.BridgeName, network.OVSUserspace.DPDKPhysicalPorts); err != nil {
return err
}
// TODO else dpdk==false
Expand All @@ -68,7 +68,7 @@ func (ovsu OVSUserspaceNetworkProvider) CreateNetwork(sp *serviceprovider.Contai
return err
}
// TODO if dpdk==true
return createOVSDPDKNetwork(nodeIP, network.OVSDPDK.BridgeName, network.OVSDPDK.DPDKPhysicalPorts)
return createOVSDPDKNetwork(nodeIP, network.OVSUserspace.BridgeName, network.OVSUserspace.DPDKPhysicalPorts)
// TODO else dpdk==false
// return createOVSUserspaceNetwork(nodeIP, network.OVS.BridgeName, network.OVS.PhysicalPorts)
}
Expand Down
12 changes: 6 additions & 6 deletions src/networkprovider/ovs_netdev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (suite *DPDKNetworkTestSuite) SetupSuite() {
tName := namesgenerator.GetRandomName(0)
suite.singleNetwork = entity.Network{
Name: tName,
OVSDPDK: entity.OVSDPDKNetwork{
OVSUserspace: entity.OVSUserspaceNetwork{
BridgeName: tName,
DPDKPhysicalPorts: []entity.DPDKPhysicalPort{},
},
Expand All @@ -74,7 +74,7 @@ func (suite *DPDKNetworkTestSuite) SetupSuite() {

suite.clusterNetwork = entity.Network{
Name: tName,
OVSDPDK: entity.OVSDPDKNetwork{
OVSUserspace: entity.OVSUserspaceNetwork{
BridgeName: tName,
DPDKPhysicalPorts: []entity.DPDKPhysicalPort{},
},
Expand Down Expand Up @@ -133,7 +133,7 @@ func (suite *DPDKNetworkTestSuite) TestCreateNetwork() {
np = np.(OVSUserspaceNetworkProvider)
err = np.CreateNetwork(suite.sp, tc.network)
suite.NoError(err)
defer exec.Command("ovs-vsctl", "del-br", tc.network.OVSDPDK.BridgeName).Run()
defer exec.Command("ovs-vsctl", "del-br", tc.network.OVSUserspace.BridgeName).Run()
})
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func (suite *DPDKNetworkTestSuite) TestValidateBeforeCreating() {
tName := namesgenerator.GetRandomName(0)
network := entity.Network{
Name: tName,
OVSDPDK: entity.OVSDPDKNetwork{
OVSUserspace: entity.OVSUserspaceNetwork{
BridgeName: tName,
DPDKPhysicalPorts: []entity.DPDKPhysicalPort{eth1},
},
Expand Down Expand Up @@ -215,7 +215,7 @@ func (suite *DPDKNetworkTestSuite) TestValidateBeforeCreatingFail() {
tName := namesgenerator.GetRandomName(0)
network := entity.Network{
Name: tName,
OVSDPDK: entity.OVSDPDKNetwork{
OVSUserspace: entity.OVSUserspaceNetwork{
BridgeName: tName,
DPDKPhysicalPorts: []entity.DPDKPhysicalPort{eth1},
},
Expand Down Expand Up @@ -271,7 +271,7 @@ func (suite *DPDKNetworkTestSuite) TestDeleteNetwork() {
suite.NoError(err)

// ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
exec.Command("ovs-vsctl", "add-br", tc.network.OVSDPDK.BridgeName, "--", "set", "bridge", tc.network.OVSDPDK.BridgeName, "datapath_type=netdev").Run()
exec.Command("ovs-vsctl", "add-br", tc.network.OVSUserspace.BridgeName, "--", "set", "bridge", tc.network.OVSUserspace.BridgeName, "datapath_type=netdev").Run()
//FIXME we need a function to check the bridge is exist
err = np.DeleteNetwork(suite.sp, tc.network)
suite.NoError(err)
Expand Down

0 comments on commit 9f43e25

Please sign in to comment.