Skip to content

Commit

Permalink
Merge pull request #63 from linkernetworks/alex/AddVlanTagOption
Browse files Browse the repository at this point in the history
Add vlan tag option for port
  • Loading branch information
John-Lin authored Jul 6, 2018
2 parents 78187da + 1bf26f9 commit f586a31
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ notifications:
before_install:
- go get -u github.com/kardianos/govendor
- sudo apt-get install -y git build-essential openvswitch-switch
- docker run -d -v /run/openvswitch/db.sock:/var/run/openvswitch/db.sock -p 50051:50051 sdnvortex/network-controller:v0.1.1 /go/bin/server -tcp=0.0.0.0:50051
- docker run -d -v /run/openvswitch/db.sock:/var/run/openvswitch/db.sock -p 50051:50051 sdnvortex/network-controller:v0.2.1 /go/bin/server -tcp=0.0.0.0:50051

install:
- make pre-build
Expand Down
6 changes: 3 additions & 3 deletions src/entity/network_ovs.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package entity

type PhysicalPort struct {
Name string `bson:"name" json:"name"`
MTU int `bson:"MTU" json:"MTU"`
VlanTags []int `bson:"vlanTag" json:"vlanTag"`
Name string `bson:"name" json:"name"`
MTU int `bson:"MTU" json:"MTU"`
VlanTags []int32 `bson:"vlanTags" MTC:"vlanTags"`
}

type OVSNetwork struct {
Expand Down
18 changes: 17 additions & 1 deletion src/networkcontroller/network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func (nc *NetworkController) CreateOVSNetwork(bridgeName string, ports []entity.
if _, err := nc.ClientCtl.CreateBridge(
nc.Context,
&pb.CreateBridgeRequest{
BridgeName: bridgeName,
BridgeName: bridgeName,
DatapathType: "system",
}); err != nil {
return err
}
Expand All @@ -50,6 +51,21 @@ func (nc *NetworkController) CreateOVSNetwork(bridgeName string, ports []entity.
if err != nil {
return err
}

if len(port.VlanTags) > 0 {
_, err := nc.ClientCtl.SetPort(
nc.Context,
&pb.SetPortRequest{
IfaceName: port.Name,
Options: &pb.PortOptions{
VLANMode: "trunk",
Trunk: port.VlanTags,
},
})
if err != nil {
return err
}
}
}
return nil
}
Expand Down
13 changes: 7 additions & 6 deletions src/networkcontroller/network_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ package networkcontroller
import (
"bytes"
"fmt"
"github.com/linkernetworks/vortex/src/entity"
"github.com/linkernetworks/vortex/src/kubernetes"
"github.com/moby/moby/pkg/namesgenerator"
"github.com/stretchr/testify/suite"
"math/rand"
"net"
"os"
Expand All @@ -15,6 +11,11 @@ import (
"testing"
"time"

"github.com/linkernetworks/vortex/src/entity"
"github.com/linkernetworks/vortex/src/kubernetes"
"github.com/moby/moby/pkg/namesgenerator"
"github.com/stretchr/testify/suite"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakeclientset "k8s.io/client-go/kubernetes/fake"
Expand Down Expand Up @@ -103,7 +104,7 @@ func (suite *NetworkControllerTestSuite) TestCreateNetwork() {
eth1 := entity.PhysicalPort{
Name: suite.ifName,
MTU: 1500,
VlanTags: []int{2043, 2143, 2243},
VlanTags: []int32{2043, 2143, 2243},
}

tName := namesgenerator.GetRandomName(0)
Expand Down Expand Up @@ -133,7 +134,7 @@ func (suite *NetworkControllerTestSuite) TestDeleteNetwork() {
eth1 := entity.PhysicalPort{
Name: suite.ifName,
MTU: 1500,
VlanTags: []int{2043, 2143, 2243},
VlanTags: []int32{2043, 2143, 2243},
}

tName := namesgenerator.GetRandomName(0)
Expand Down
4 changes: 2 additions & 2 deletions src/networkprovider/ovs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (suite *NetworkTestSuite) TestValidateBeforeCreating() {
eth1 := entity.PhysicalPort{
Name: namesgenerator.GetRandomName(0),
MTU: 1500,
VlanTags: []int{2043, 2143, 2243},
VlanTags: []int32{2043, 2143, 2243},
}

tName := namesgenerator.GetRandomName(0)
Expand Down Expand Up @@ -218,7 +218,7 @@ func (suite *NetworkTestSuite) TestValidateBeforeCreatingFail() {
eth1 := entity.PhysicalPort{
Name: namesgenerator.GetRandomName(0),
MTU: 1500,
VlanTags: []int{2043, 2143, 22435},
VlanTags: []int32{2043, 2143, 22435},
}

tName := namesgenerator.GetRandomName(0)
Expand Down
104 changes: 5 additions & 99 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,12 @@
"revisionTime": "2018-05-24T10:14:37Z"
},
{
"checksumSHA1": "LW/1Uv+eMT9YqO/xqieFOeUZaBI=",
"checksumSHA1": "yn+Mnhby5jor32R9p/Oi2mhBXS8=",
"path": "github.com/linkernetworks/network-controller/messages",
"revision": "45433e3247ddcc3455ab5cfeb870d69ba0024774",
"revisionTime": "2018-06-25T08:54:22Z"
},
{
"checksumSHA1": "6xm1f1JNGEKoELwN4GXy/9/0HoM=",
"path": "github.com/linkernetworks/oauth/app/config",
"revision": "a7fe484fc0cf65696dd9479eb8bad1b2dd416ca9",
"revisionTime": "2018-05-31T10:18:20Z"
"revision": "6732f1138d000319d734c9f1d0bb27a7c7bb05a3",
"revisionTime": "2018-07-06T02:29:06Z",
"version": "=v0.2.1",
"versionExact": "v0.2.1"
},
{
"checksumSHA1": "V89FgGKA+7A70mAedEvmhDSCIyQ=",
Expand Down Expand Up @@ -648,36 +644,6 @@
"revision": "afe8f62b1d6bbd81f31868121a50b06d8188e1f9",
"revisionTime": "2018-06-20T20:20:43Z"
},
{
"checksumSHA1": "j0z/2h06wsvTkGiLaZ5XFLbMKfo=",
"path": "golang.org/x/oauth2",
"revision": "088f8e1d436e8d636f13cd83a345b3d6ff2f04ae",
"revisionTime": "2018-05-04T20:45:12Z"
},
{
"checksumSHA1": "z7mSaGccufg15ki2YPd+M5PlsUc=",
"path": "golang.org/x/oauth2/google",
"revision": "088f8e1d436e8d636f13cd83a345b3d6ff2f04ae",
"revisionTime": "2018-05-04T20:45:12Z"
},
{
"checksumSHA1": "3mJjldg4HJZppC5scDKEFgJ2z48=",
"path": "golang.org/x/oauth2/internal",
"revision": "088f8e1d436e8d636f13cd83a345b3d6ff2f04ae",
"revisionTime": "2018-05-04T20:45:12Z"
},
{
"checksumSHA1": "huVltYnXdRFDJLgp/ZP9IALzG7g=",
"path": "golang.org/x/oauth2/jws",
"revision": "088f8e1d436e8d636f13cd83a345b3d6ff2f04ae",
"revisionTime": "2018-05-04T20:45:12Z"
},
{
"checksumSHA1": "QPndO4ODVdEBILRhJ6869UDAoHc=",
"path": "golang.org/x/oauth2/jwt",
"revision": "088f8e1d436e8d636f13cd83a345b3d6ff2f04ae",
"revisionTime": "2018-05-04T20:45:12Z"
},
{
"checksumSHA1": "g0ElG8ZOLLoSol7KoLtx9o7WFgg=",
"path": "golang.org/x/sys/unix",
Expand Down Expand Up @@ -732,66 +698,6 @@
"revision": "fbb02b2291d28baffd63558aa44b4b56f178d650",
"revisionTime": "2018-04-12T16:56:04Z"
},
{
"checksumSHA1": "QoM8iwt2FVbTHR+Lav3dXmEu/7o=",
"path": "google.golang.org/appengine",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "x2UMjnBCqXdCFcKF4U925pCxmxQ=",
"path": "google.golang.org/appengine/internal",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "YI9+yxvbfgIihM3UXZfFwioAc88=",
"path": "google.golang.org/appengine/internal/app_identity",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "PJ+aP3+eOZn+ckAb4NZPHNAxESk=",
"path": "google.golang.org/appengine/internal/base",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "2JYgCZVGTTsBIhh29M5ItZGXQ7E=",
"path": "google.golang.org/appengine/internal/datastore",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "Tmunm9UyiE/Bs+JDU2ej2jTsFoY=",
"path": "google.golang.org/appengine/internal/log",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "0WONGA6dPWAV2Kex8qSXiID4Zxs=",
"path": "google.golang.org/appengine/internal/modules",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "ZZYm/rh5ssupiYTO/dazGw/IWZM=",
"path": "google.golang.org/appengine/internal/remote_api",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "bTGqlontu6VG532l5otdWy6f6m4=",
"path": "google.golang.org/appengine/internal/urlfetch",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "akOV9pYnCbcPA8wJUutSQVibdyg=",
"path": "google.golang.org/appengine/urlfetch",
"revision": "b1f26356af11148e710935ed1ac8a7f5702c7612",
"revisionTime": "2018-05-21T22:34:13Z"
},
{
"checksumSHA1": "AubR8T/clx04wAEJlXwpwxI4uTM=",
"path": "google.golang.org/genproto/googleapis/rpc/status",
Expand Down

0 comments on commit f586a31

Please sign in to comment.