Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: vppcalls and handler version registration #1572

Merged
merged 21 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,11 @@ checknodiffgenerated: ## Check no diff generated

generate: generate-proto generate-binapi generate-desc-adapters ## Generate all
go fmt ./...
go mod tidy -v

generate-proto: protocgengo ## Generate Protobuf files

get-binapi-generators:
go install git.fd.io/govpp.git/cmd/binapi-generator
go install -mod=readonly git.fd.io/govpp.git/cmd/binapi-generator

generate-binapi: get-binapi-generators ## Generate Go code for VPP binary API
@echo "# generating VPP binapi"
Expand Down Expand Up @@ -234,13 +233,13 @@ dep-install:

dep-update:
@echo "# updating all dependencies"
@echo "Warning: 'go get' desired new modules by hand"
@echo go mod tidy -v

# FIXME: 'go mod verify' might be used here, but tidy and verify disagree.
dep-check:
@echo "# checking dependencies"
go mod verify
go mod tidy -v
@if ! git diff --quiet go.mod go.sum ; then \
@if ! git diff --quiet go.mod ; then \
echo "go mod tidy check failed"; \
exit 1 ; \
fi
Expand Down
2 changes: 1 addition & 1 deletion cmd/agentctl/commands/models.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package commands

import (
_ "go.ligato.io/vpp-agent/v2/plugins/govppmux"
_ "go.ligato.io/vpp-agent/v2/proto/ligato/govppmux"
_ "go.ligato.io/vpp-agent/v2/proto/ligato/linux"
_ "go.ligato.io/vpp-agent/v2/proto/ligato/netalloc"
_ "go.ligato.io/vpp-agent/v2/proto/ligato/vpp"
Expand Down
34 changes: 34 additions & 0 deletions cmd/vpp-agent/app/app_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package app

import (
"log"
"strings"
"testing"

"go.ligato.io/vpp-agent/v2/plugins/vpp"
)

func TestHandlers(t *testing.T) {
handlers := vpp.GetHandlers()

log.Printf("listing %d handlers:", len(handlers))

for h, handler := range handlers {
versions := strings.Join(handler.Versions(), ", ")
log.Printf(" - %s (%v)", h, versions)
}
}
3 changes: 1 addition & 2 deletions examples/kvscheduler/mock_plugins/ifplugin/ifplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
package ifplugin

import (
"github.com/pkg/errors"

"github.com/ligato/cn-infra/infra"
"github.com/pkg/errors"

"go.ligato.io/vpp-agent/v2/examples/kvscheduler/mock_plugins/ifplugin/descriptor"
"go.ligato.io/vpp-agent/v2/examples/kvscheduler/mock_plugins/ifplugin/mockcalls"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package mockcalls

import (
"github.com/ligato/cn-infra/logging"

"go.ligato.io/vpp-agent/v2/examples/kvscheduler/mock_plugins/ifplugin/model"
)

Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module go.ligato.io/vpp-agent/v2
go 1.12

require (
git.fd.io/govpp.git v0.1.1-0.20191017045426-cc80dbcaaaca
git.fd.io/govpp.git v0.2.1-0.20191115113328-e45d8802fd8d
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/DataDog/zstd v1.3.5 // indirect
github.com/Microsoft/go-winio v0.4.7 // indirect
Expand Down Expand Up @@ -54,8 +54,7 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jhump/protoreflect v1.5.0
github.com/ligato/cn-infra v2.2.1-0.20191030081411-42c7431fdca1+incompatible
github.com/lunixbochs/struc v0.0.0-20180408203800-02e4c2afbb2a
github.com/mattn/goveralls v0.0.3
github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42
github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9 // indirect
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
git.fd.io/govpp.git v0.1.1-0.20191017045426-cc80dbcaaaca h1:BKr2iuczYUKDrfEbxMcaNDw0hP/h7EM0MwQ3W/oBrj4=
git.fd.io/govpp.git v0.1.1-0.20191017045426-cc80dbcaaaca/go.mod h1:eW8f/z6ki4GL3Yl8cjGAdoZ+R0lTEHny11PxVFLYfsI=
git.fd.io/govpp.git v0.2.1-0.20191115113328-e45d8802fd8d h1:fyfPeiO3NHRkBAo7JsX1O+rxJkWun9RXoM3qvZRvi78=
git.fd.io/govpp.git v0.2.1-0.20191115113328-e45d8802fd8d/go.mod h1:cJ7XSNm8O4jeU1dLgOacRoHt5MxlL+XPgas1yBC53gc=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
Expand Down Expand Up @@ -197,12 +197,10 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/ligato/cn-infra v2.2.1-0.20191030081411-42c7431fdca1+incompatible h1:o4bJ+B9h9JvoF94T2zY3amXuR1Mryjkkfnvey8FOicg=
github.com/ligato/cn-infra v2.2.1-0.20191030081411-42c7431fdca1+incompatible/go.mod h1:wBXHMbKAlgOc/MkJMy/25284ri77duvS0XlIImme7z0=
github.com/lunixbochs/struc v0.0.0-20180408203800-02e4c2afbb2a h1:axFx97V2Lyke5LbeygrJlzc07mwVhHt2ZHeI/Nv8Aq4=
github.com/lunixbochs/struc v0.0.0-20180408203800-02e4c2afbb2a/go.mod h1:iOJu9pApjjmEmNq7PqlA5R9mDu/HMF5EM3llWKX/TyA=
github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42 h1:PzBD7QuxXSgSu61TKXxRwVGzWO5d9QZ0HxFFpndZMCg=
github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/goveralls v0.0.3 h1:GnFhBAK0wJmxZBum88FqDzcDPLjAk9sL0HzhmW+9bo8=
github.com/mattn/goveralls v0.0.3/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA=
Expand Down
13 changes: 6 additions & 7 deletions plugins/configurator/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
package configurator

import (
"context"
"errors"

linux_l3 "go.ligato.io/vpp-agent/v2/proto/ligato/linux/l3"

"github.com/ligato/cn-infra/logging"
"golang.org/x/net/context"

iflinuxcalls "go.ligato.io/vpp-agent/v2/plugins/linux/ifplugin/linuxcalls"
l3linuxcalls "go.ligato.io/vpp-agent/v2/plugins/linux/l3plugin/linuxcalls"
Expand All @@ -34,6 +32,7 @@ import (
"go.ligato.io/vpp-agent/v2/plugins/vpp/puntplugin/vppcalls"
rpc "go.ligato.io/vpp-agent/v2/proto/ligato/configurator"
linux_interfaces "go.ligato.io/vpp-agent/v2/proto/ligato/linux/interfaces"
linux_l3 "go.ligato.io/vpp-agent/v2/proto/ligato/linux/l3"
vpp_abf "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/abf"
vpp_acl "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/acl"
vpp_interfaces "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/interfaces"
Expand Down Expand Up @@ -66,7 +65,7 @@ type dumpService struct {
}

// Dump implements Dump method for Configurator
func (svc *dumpService) Dump(context.Context, *rpc.DumpRequest) (*rpc.DumpResponse, error) {
func (svc *dumpService) Dump(ctx context.Context, req *rpc.DumpRequest) (*rpc.DumpResponse, error) {
defer trackOperation("Dump")()

svc.log.Debugf("Received Dump request..")
Expand All @@ -76,7 +75,7 @@ func (svc *dumpService) Dump(context.Context, *rpc.DumpRequest) (*rpc.DumpRespon
var err error

// core
dump.VppConfig.Interfaces, err = svc.DumpInterfaces()
dump.VppConfig.Interfaces, err = svc.DumpInterfaces(ctx)
if err != nil {
svc.log.Errorf("DumpInterfaces failed: %v", err)
return nil, err
Expand Down Expand Up @@ -172,13 +171,13 @@ func (svc *dumpService) Dump(context.Context, *rpc.DumpRequest) (*rpc.DumpRespon

// DumpInterfaces reads interfaces and returns them as an *InterfaceResponse. If reading ends up with error,
// only error is send back in response
func (svc *dumpService) DumpInterfaces() (ifs []*vpp_interfaces.Interface, err error) {
func (svc *dumpService) DumpInterfaces(ctx context.Context) (ifs []*vpp_interfaces.Interface, err error) {
if svc.ifHandler == nil {
// handler is not available
return nil, nil
}

ifDetails, err := svc.ifHandler.DumpInterfaces()
ifDetails, err := svc.ifHandler.DumpInterfaces(ctx)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/configurator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewPlugin(opts ...Option) *Plugin {
p.PluginName = "configurator"
p.GRPCServer = &grpc.DefaultPlugin
p.Dispatch = &orchestrator.DefaultPlugin
p.GoVppmux = &govppmux.DefaultPlugin
p.VPP = &govppmux.DefaultPlugin
p.ServiceLabel = &servicelabel.DefaultPlugin
p.AddrAlloc = &netalloc.DefaultPlugin
p.VPPACLPlugin = &aclplugin.DefaultPlugin
Expand Down
12 changes: 6 additions & 6 deletions plugins/configurator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Deps struct {
infra.PluginDeps
GRPCServer grpc.Server
Dispatch orchestrator.Dispatcher
GoVppmux govppmux.StatsAPI
VPP govppmux.API
ServiceLabel servicelabel.ReaderAPI
AddrAlloc netalloc.AddressAllocator
VPPACLPlugin aclplugin.API
Expand Down Expand Up @@ -113,7 +113,7 @@ func (p *Plugin) Close() error {
// helper method initializes all VPP/Linux plugin handlers
func (p *Plugin) initHandlers() (err error) {
// VPP channels
if p.vppChan, err = p.GoVppmux.NewAPIChannel(); err != nil {
if p.vppChan, err = p.VPP.NewAPIChannel(); err != nil {
return err
}

Expand All @@ -130,7 +130,7 @@ func (p *Plugin) initHandlers() (err error) {
// VPP handlers

// core
p.configurator.ifHandler = ifvppcalls.CompatibleInterfaceVppHandler(p.vppChan, p.Log)
p.configurator.ifHandler = ifvppcalls.CompatibleInterfaceVppHandler(p.VPP, p.Log)
if p.configurator.ifHandler == nil {
p.Log.Info("VPP Interface handler is not available, it will be skipped")
}
Expand All @@ -148,15 +148,15 @@ func (p *Plugin) initHandlers() (err error) {
}

// plugins
p.configurator.abfHandler = abfvppcalls.CompatibleABFVppHandler(p.vppChan, aclIndexes, ifIndexes, p.Log)
p.configurator.abfHandler = abfvppcalls.CompatibleABFHandler(p.VPP, aclIndexes, ifIndexes, p.Log)
if p.configurator.abfHandler == nil {
p.Log.Info("VPP ABF handler is not available, it will be skipped")
}
p.configurator.aclHandler = aclvppcalls.CompatibleACLVppHandler(p.vppChan, ifIndexes, p.Log)
p.configurator.aclHandler = aclvppcalls.CompatibleACLHandler(p.VPP, ifIndexes)
if p.configurator.aclHandler == nil {
p.Log.Info("VPP ACL handler is not available, it will be skipped")
}
p.configurator.natHandler = natvppcalls.CompatibleNatVppHandler(p.vppChan, ifIndexes, dhcpIndexes, p.Log)
p.configurator.natHandler = natvppcalls.CompatibleNatVppHandler(p.VPP, ifIndexes, dhcpIndexes, p.Log)
if p.configurator.natHandler == nil {
p.Log.Info("VPP NAT handler is not available, it will be skipped")
}
Expand Down
20 changes: 10 additions & 10 deletions plugins/govppmux/adapter_stubs.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2017 Cisco and/or its affiliates.
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build mockvpp

Expand Down
20 changes: 10 additions & 10 deletions plugins/govppmux/adapter_vppapiclient.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2017 Cisco and/or its affiliates.
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !mockvpp,vppapiclient

Expand Down
Loading