Skip to content

Commit

Permalink
bump the version to 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
WIZARD-CXY committed Jul 18, 2015
1 parent ad7bc78 commit c20a6d0
Showing 10 changed files with 25 additions and 48 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,3 +3,5 @@

Using sdn tools and netAgent to offer advanced network management for container cloud platform.

Version 6.0 ready!

7 changes: 3 additions & 4 deletions agent/netAgent.go
Original file line number Diff line number Diff line change
@@ -51,12 +51,11 @@ func StartAgent(serverMode bool, bootstrap bool, bindInterface string, dataDir s

watchForExistingRegisteredUpdates()

//go RegisterForNodeUpdates()
go startConsul(serverMode, bootstrap, bindAddr, dataDir, errChan)

select {
case <-errChan:
return errors.New("Error start consul agent")
return errors.New("Error start net agent")
case <-time.After(time.Second * 5):
}
return nil
@@ -103,15 +102,15 @@ func Execute(args ...string) int {
return exitCode
}

const CONSUL_CATALOG_BASE_URL = "http://localhost:8500/v1/catalog/"

// Node operation related

type Node struct {
Name string `json:"Name,omitempty"`
Address string `json:"Addr,ommitempty"`
}

const CONSUL_CATALOG_BASE_URL = "http://localhost:8500/v1/catalog/"

func Join(addr string) error {
ret := Execute("join", addr)

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ func main() {
app := cli.NewApp()
app.Name = "cxy-sdn"
app.Usage = "sdn tool for container cloud platform"
app.Version = "0.1"
app.Version = "6.0"

app.Flags = []cli.Flag{
cli.StringFlag{
15 changes: 6 additions & 9 deletions server/api.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ type HttpErr struct {
message string
}

const version = "0.1"
const version = "6.0"

type HttpApiFunc func(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr

@@ -124,8 +124,7 @@ func setConf(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {

cfg := &BridgeConf{}

decoder := json.NewDecoder(r.Body)
err := decoder.Decode(cfg)
err := json.NewDecoder(r.Body).Decode(cfg)

if err != nil {
return &HttpErr{http.StatusInternalServerError, "setConf json decode failed"}
@@ -158,7 +157,7 @@ func getNet(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {
network, err := GetNetwork(name)

if err != nil {
return &HttpErr{http.StatusInternalServerError, err.Error()}
return &HttpErr{http.StatusNotFound, err.Error()}
}

data, err := json.Marshal(network)
@@ -180,8 +179,7 @@ func createNet(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {
}

network := &Network{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(network)
err := json.NewDecoder(r.Body).Decode(network)

if err != nil {
return &HttpErr{http.StatusInternalServerError, err.Error()}
@@ -298,15 +296,14 @@ func getConn(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {
return nil
}

// create a container to ovs-bridge connection
// create a container connection
func createConn(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {
if r.Body == nil {
return &HttpErr{http.StatusBadRequest, "request body is empty"}
}

con := &Connection{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(con)
err := json.NewDecoder(r.Body).Decode(con)

if err != nil {
return &HttpErr{http.StatusInternalServerError, err.Error()}
22 changes: 2 additions & 20 deletions server/api_test.go
Original file line number Diff line number Diff line change
@@ -598,7 +598,6 @@ func TestCreateQosApi(t *testing.T) {

}

/*
func TestUpdateQos(t *testing.T) {
d := NewDaemon()
connection := &Connection{
@@ -608,29 +607,12 @@ func TestUpdateQos(t *testing.T) {
Network: "default",
}
d.connections["abc123"] = connection
request, _ := http.NewRequest("DELETE", "/connection/abc123", nil)
request, _ := http.NewRequest("PUT", "/qos/abc123?bw=200&delay=20", nil)
response := httptest.NewRecorder()

go func() {
for {
context := <-d.connectionChan
if context == nil {
t.Fatalf("Object taken from channel is nil")
}
if context.Action != deleteConn {
t.Fatal("should be adding a new connection")
}
if !reflect.DeepEqual(context.Connection, connection) {
t.Fatal("payload is incorrect")
}
context.Result <- connection
}
}()
createRouter(d).ServeHTTP(response, request)

if response.Code != http.StatusOK {
t.Fatalf("Expected %v:\n\tReceived: %v", "200", response.Code)
}
}*/
}
4 changes: 2 additions & 2 deletions server/backend.go
Original file line number Diff line number Diff line change
@@ -30,12 +30,12 @@ func join(addr string) error {

func leave() error {
if err := netAgent.Leave(); err != nil {
//glog.Error(err)

return err
}
//clean the data storage
if err := os.RemoveAll(dataDir); err != nil {
// glog.Error(err)

return err
}
return nil
9 changes: 4 additions & 5 deletions server/ovs.go → server/connection.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ import (
"time"

"github.com/WIZARD-CXY/cxy-sdn/util"
// "github.com/golang/glog"
"github.com/socketplane/libovsdb"
"github.com/vishvananda/netns"
)
@@ -483,7 +482,7 @@ func addQos(d *Daemon, containerId, bw, delay string) error {
fmt.Println("install qos bw error in addQos")
return err
}
// magic number
// magic number just a large bw
con.BandWidth = "8000000"
}

@@ -580,11 +579,11 @@ func monitorNetworkTraffic(d *Daemon) {
con.(*Connection).TXTotal = tx
con.(*Connection).RXTotal = rx

con.(*Connection).RXRate = float64(rx-preRx) * 8 / 3
con.(*Connection).TXRate = float64(tx-preTx) * 8 / 3
con.(*Connection).RXRate = float64(rx-preRx) * 8 / 2
con.(*Connection).TXRate = float64(tx-preTx) * 8 / 2
}
d.connections.RUnlock()
time.Sleep(3 * time.Second)
time.Sleep(2 * time.Second)
}

}
3 changes: 2 additions & 1 deletion server/daemon.go
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ type Daemon struct {
clusterChan chan *NodeCtx
connectionChan chan *ConnectionCtx
readyChan chan bool
Gateways map[string]struct{}
Gateways map[string]struct{} //network set
}

type NodeCtx struct {
@@ -115,6 +115,7 @@ func (d *Daemon) Run(ctx *cli.Context) {
fmt.Println("error in Init netAgent")
}

// wait a while for agent to fully start
time.Sleep(3 * time.Second)
if d.isBootstrap {
d.readyChan <- true
3 changes: 0 additions & 3 deletions server/monitor.go

This file was deleted.

6 changes: 3 additions & 3 deletions server/network.go
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ func CreateNetwork(name string, subnet *net.IPNet) (*Network, error) {
}

// this function is used to create network from network datastore
// assume the network whose name is `name` is already exist but have no interface
// assume the network whose name is `name` is already exist but have no interface on the node
func CreateNetwork2(name string, subnet *net.IPNet) (*Network, error) {
network, err := GetNetwork(name)

@@ -242,8 +242,8 @@ func DeleteNetwork(name string) error {
return err
}

eccerror := netAgent.Delete(networkStore, name)
if eccerror != netAgent.OK {
errcode := netAgent.Delete(networkStore, name)
if errcode != netAgent.OK {
return errors.New("Error deleting network")
}
releaseVlan(network.VlanID)

0 comments on commit c20a6d0

Please sign in to comment.