Skip to content

Commit

Permalink
Merge 3a42669 into 6cd31bd
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej-fabry committed Aug 28, 2020
2 parents 6cd31bd + 3a42669 commit 0691f1c
Show file tree
Hide file tree
Showing 192 changed files with 43,076 additions and 156 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Expand Up @@ -48,47 +48,47 @@ jobs:
- bash <(curl -s https://codecov.io/bash) -f /tmp/coverage.out -F unittests

- stage: Integration
env: VPP_VERSION=1904
env: VPP_VERSION=1908
script:
- make verify-binapi
- make integration-tests
- env: VPP_VERSION=1908
- env: VPP_VERSION=2001
script:
- make verify-binapi
- make integration-tests
- env: VPP_VERSION=2001
- env: VPP_VERSION=2005
script:
- make verify-binapi
- make integration-tests
- env: VPP_VERSION=2005
- env: VPP_VERSION=2009
script:
- make verify-binapi
- make integration-tests

- stage: E2E
env: VPP_VERSION=1904
env: VPP_VERSION=1908
script:
- make e2e-tests-cover
after_success:
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e
- env: VPP_VERSION=1908
- env: VPP_VERSION=2001
script:
- make e2e-tests-cover
after_success:
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e
- env: VPP_VERSION=2001
- env: VPP_VERSION=2005
script:
- make e2e-tests-cover
after_success:
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e
- env: VPP_VERSION=2005
- env: VPP_VERSION=2009
script:
- make e2e-tests-cover
after_success:
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e

allow_failures:
- env: VPP_VERSION=1904
- env: VPP_VERSION=2009

notifications:
slack:
Expand Down
1 change: 1 addition & 0 deletions plugins/govppmux/plugin_impl_govppmux.go
Expand Up @@ -43,6 +43,7 @@ import (
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp1908"
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001"
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2005"
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2009"
)

var (
Expand Down
146 changes: 146 additions & 0 deletions plugins/govppmux/vppcalls/vpp2009/vpe_vppcalls.go
@@ -0,0 +1,146 @@
// 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 vpp2009

import (
"context"
"fmt"
"strings"

"github.com/pkg/errors"

"go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/memclnt"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vpe"
)

// Ping sends VPP control ping.
func (h *VpeHandler) Ping(ctx context.Context) error {
_, err := h.vpe.ControlPing(ctx, new(vpe.ControlPing))
return err
}

// GetVersion retrieves version info from VPP.
func (h *VpeHandler) GetVersion(ctx context.Context) (*vppcalls.VersionInfo, error) {
version, err := h.vpe.ShowVersion(ctx, new(vpe.ShowVersion))
if err != nil {
return nil, err
}
info := &vppcalls.VersionInfo{
Program: strings.TrimRight(version.Program, "\x00"),
Version: strings.TrimRight(version.Version, "\x00"),
BuildDate: strings.TrimRight(version.BuildDate, "\x00"),
BuildDirectory: strings.TrimRight(version.BuildDirectory, "\x00"),
}
return info, nil
}

// GetSession retrieves session info from VPP.
func (h *VpeHandler) GetSession(ctx context.Context) (*vppcalls.SessionInfo, error) {
pong, err := h.vpe.ControlPing(ctx, new(vpe.ControlPing))
if err != nil {
return nil, err
}
info := &vppcalls.SessionInfo{
PID: pong.VpePID,
ClientIdx: pong.ClientIndex,
}

systime, err := h.vpe.ShowVpeSystemTime(ctx, new(vpe.ShowVpeSystemTime))
if err != nil {
// TODO: log returned error as warning?
} else {
info.Uptime = float64(systime.VpeSystemTime)
}
return info, nil
}

// GetModules retrieves module info from VPP.
func (h *VpeHandler) GetModules(ctx context.Context) ([]vppcalls.APIModule, error) {
versions, err := h.memclnt.APIVersions(ctx, new(memclnt.APIVersions))
if err != nil {
return nil, err
}
var modules []vppcalls.APIModule
for _, v := range versions.APIVersions {
modules = append(modules, vppcalls.APIModule{
Name: strings.TrimSuffix(strings.TrimRight(v.Name, "\x00"), ".api"),
Major: v.Major,
Minor: v.Minor,
Patch: v.Patch,
})
}
return modules, nil
}

func (h *VpeHandler) GetPlugins(ctx context.Context) ([]vppcalls.PluginInfo, error) {
const (
pluginPathPrefix = "Plugin path is:"
pluginNameSuffix = "_plugin.so"
)

out, err := h.RunCli(ctx, "show plugins")
if err != nil {
return nil, err
}

lines := strings.Split(out, "\n")
if len(lines) == 0 {
return nil, fmt.Errorf("empty output for 'show plugins'")
}
pluginPathLine := strings.TrimSpace(lines[0])
if !strings.HasPrefix(pluginPathLine, pluginPathPrefix) {
return nil, fmt.Errorf("unexpected output for 'show plugins'")
}
pluginPath := strings.TrimSpace(strings.TrimPrefix(pluginPathLine, pluginPathPrefix))
if len(pluginPath) == 0 {
return nil, fmt.Errorf("plugin path not found in output for 'show plugins'")
}

var plugins []vppcalls.PluginInfo
for _, line := range lines {
fields := strings.Fields(line)
if len(fields) < 3 {
continue
}
var i int
if _, err := fmt.Sscanf(fields[0], "%d.", &i); err != nil {
continue
}
if i <= 0 {
continue
}
plugin := vppcalls.PluginInfo{
Name: strings.TrimSuffix(fields[1], pluginNameSuffix),
Path: fields[1],
Version: fields[2],
Description: strings.Join(fields[3:], " "),
}
plugins = append(plugins, plugin)
}

return plugins, nil
}

// RunCli sends CLI command to VPP and returns response.
func (h *VpeHandler) RunCli(ctx context.Context, cmd string) (string, error) {
resp, err := h.vpe.CliInband(ctx, &vpe.CliInband{
Cmd: cmd,
})
if err != nil {
return "", errors.Wrapf(err, "VPP CLI command '%s' failed", cmd)
}
return resp.Reply, nil
}
45 changes: 45 additions & 0 deletions plugins/govppmux/vppcalls/vpp2009/vppcalls_handler.go
@@ -0,0 +1,45 @@
// 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 vpp2009

import (
govppapi "git.fd.io/govpp.git/api"

"go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls"
"go.ligato.io/vpp-agent/v3/plugins/vpp"
vpp2009 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/memclnt"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vpe"
)

func init() {
msgs := vpp.Messages(
vpe.AllMessages,
memclnt.AllMessages,
)
vppcalls.AddVersion(vpp2009.Version, msgs.AllMessages(), NewVpeHandler)
}

type VpeHandler struct {
memclnt memclnt.RPCService
vpe vpe.RPCService
}

func NewVpeHandler(ch govppapi.Channel) vppcalls.VppCoreAPI {
return &VpeHandler{
memclnt: memclnt.NewServiceClient(ch),
vpe: vpe.NewServiceClient(ch),
}
}
2 changes: 1 addition & 1 deletion plugins/telemetry/telemetry.go
Expand Up @@ -43,6 +43,7 @@ import (
_ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp1908"
_ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2001"
_ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2005"
_ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2009"
)

var debug = os.Getenv("DEBUG_TELEMETRY") != ""
Expand Down Expand Up @@ -168,7 +169,6 @@ func (p *Plugin) setupStatsPoller() error {
if p.GRPC != nil && p.GRPC.GetServer() != nil {
configurator.RegisterStatsPollerServiceServer(p.GRPC.GetServer(), &p.statsPollerServer)
}

return nil
}

Expand Down

0 comments on commit 0691f1c

Please sign in to comment.