Skip to content

Commit

Permalink
Support the vlan tag for client
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchiu committed Jul 19, 2018
1 parent d7b6858 commit 42ba7e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/entity/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Container struct {
type PodNetwork struct {
Name string `bson:"name" json:"name"`
IfName string `bson:"ifName" json:"ifName"`
VlanTag int `bson:"vlanTag" json:"vlanTag"`
VlanTag *int32 `bson:"vlanTag" json:"vlanTag"`
IPAddress string `bson:"ipAddress json:"ipAddress"`
Netmask string `bson:"netmask" json:"netmask"`
BridgeName string `bson:"bridgeName" json:"bridgeName"` //its from the entity.Network entity
Expand Down
10 changes: 8 additions & 2 deletions src/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pod
import (
"fmt"
"regexp"
"strconv"

"github.com/linkernetworks/mongo"
"github.com/linkernetworks/vortex/src/entity"
Expand Down Expand Up @@ -106,15 +107,20 @@ func generateNodeLabels(networks []entity.Network) []string {
return utils.Intersections(totalNames)
}

func generateClientCommand(network entity.PodNetwork) []string {
func generateClientCommand(network entity.PodNetwork) (command []string) {
ip := utils.IPToCIDR(network.IPAddress, network.Netmask)

return []string{
command = []string{
"-s=unix:///tmp/vortex.sock",
"-b=" + network.BridgeName,
"-n=" + network.IfName,
"-i=" + ip,
}

if network.VlanTag != nil {
command = append(command, "-v="+strconv.Itoa(*network.VlanTag))
}
return
}

func generateInitContainer(networks []entity.PodNetwork) ([]corev1.Container, error) {
Expand Down

0 comments on commit 42ba7e2

Please sign in to comment.