Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Lavor <[email protected]>
  • Loading branch information
VladoLavor committed Jun 6, 2019
1 parent 8715c96 commit e993d3b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 26 deletions.
54 changes: 37 additions & 17 deletions cmd/vpp-agent-ctl/data/ifplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
package data

import (
"context"
linuxIf "github.com/ligato/vpp-agent/api/models/linux/interfaces"
"github.com/ligato/vpp-agent/api/models/linux/namespace"
interfaces "github.com/ligato/vpp-agent/api/models/vpp/interfaces"
"strconv"
)

// InterfacesCtl interface plugin related methods for vpp-agent-ctl (interfaces including linux ones)
Expand Down Expand Up @@ -109,6 +111,7 @@ func (ctl *VppAgentCtlImpl) PutTap() error {
},
Link: &interfaces.Interface_Tap{
Tap: &interfaces.TapLink{
Version: 2,
HostIfName: "tap-host",
},
},
Expand Down Expand Up @@ -190,25 +193,42 @@ func (ctl *VppAgentCtlImpl) DeleteMemoryInterface() error {

// PutVxLan puts VxLAN type interface config to the ETCD
func (ctl *VppAgentCtlImpl) PutVxLan() error {
vxlan := &interfaces.Interface{

Name: "vxlan1",
Type: interfaces.Interface_VXLAN_TUNNEL,
Enabled: true,
IpAddresses: []string{
"172.125.40.1/24",
},
Link: &interfaces.Interface_Vxlan{
Vxlan: &interfaces.VxlanLink{
SrcAddress: "192.168.42.1",
DstAddress: "192.168.42.2",
Vni: 13,
txn := ctl.broker.NewTxn()

var first, last int
for i := 1; i <= 10000; i++ {
last++
if last == 255 {
last = 1
first++
}
srcAddr := "192.168." + strconv.Itoa(first) + "." + strconv.Itoa(last)
dstAddr := "192.168." + strconv.Itoa(first + 1) + "." + strconv.Itoa(last + 1)

vxlan := &interfaces.Interface{
Name: "vxlan" + strconv.Itoa(i),
Type: interfaces.Interface_VXLAN_TUNNEL,
Enabled: true,
Link: &interfaces.Interface_Vxlan{
Vxlan: &interfaces.VxlanLink{
SrcAddress: srcAddr,
DstAddress: dstAddr,
Vni: 13,
},
},
},
}
}

ctl.Log.Infof("Interface put: %v", vxlan)
return ctl.broker.Put(interfaces.InterfaceKey(vxlan.Name), vxlan)
ctl.Log.Infof("Interface put: %v", vxlan)
txn.Put(interfaces.InterfaceKey(vxlan.Name), vxlan)

if i%100 == 0 {
if err := txn.Commit(context.Background()); err != nil {
ctl.Log.Errorf("err: %v", err)
}
txn = ctl.broker.NewTxn()
}
}
return nil
}

// DeleteVxLan removes VxLAN type interface config from the ETCD
Expand Down
17 changes: 8 additions & 9 deletions cmd/vpp-agent/app/vpp_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import (
"github.com/ligato/cn-infra/datasync"
"github.com/ligato/cn-infra/datasync/kvdbsync"
"github.com/ligato/cn-infra/datasync/kvdbsync/local"
"github.com/ligato/cn-infra/datasync/msgsync"
"github.com/ligato/cn-infra/datasync/resync"
"github.com/ligato/cn-infra/db/keyval/consul"
"github.com/ligato/cn-infra/db/keyval/etcd"
"github.com/ligato/cn-infra/db/keyval/redis"
"github.com/ligato/cn-infra/health/probe"
"github.com/ligato/cn-infra/health/statuscheck"
"github.com/ligato/cn-infra/logging/logmanager"
"github.com/ligato/cn-infra/messaging/kafka"
"github.com/ligato/vpp-agent/plugins/vpp/srplugin"

"github.com/ligato/vpp-agent/plugins/configurator"
Expand Down Expand Up @@ -85,12 +83,12 @@ func New() *VPPAgent {
}
statuscheck.DefaultPlugin.Transport = writers

ifStatePub := msgsync.NewPlugin(
msgsync.UseMessaging(&kafka.DefaultPlugin),
msgsync.UseConf(msgsync.Config{
Topic: "if_state",
}),
)
//ifStatePub := msgsync.NewPlugin(
// msgsync.UseMessaging(&kafka.DefaultPlugin),
// msgsync.UseConf(msgsync.Config{
// Topic: "if_state",
// }),
//)

// Set watcher for KVScheduler.
watchers := datasync.KVProtoWatchers{
Expand All @@ -103,7 +101,8 @@ func New() *VPPAgent {
orchestrator.DefaultPlugin.StatusPublisher = writers

ifplugin.DefaultPlugin.Watcher = watchers
ifplugin.DefaultPlugin.NotifyStates = ifStatePub
// kafka temporary disabled
//ifplugin.DefaultPlugin.NotifyStates = ifStatePub
puntplugin.DefaultPlugin.PublishState = writers

// No stats publishers by default, use `vpp-ifplugin.conf` config
Expand Down

0 comments on commit e993d3b

Please sign in to comment.