rest

package
v1.9.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 35 Imported by: 0

README

REST API Plugin

The restplugin is a core Agent Plugin used to expose REST API for the following:

Index page

Open http://0.0.0.0:9191/ in the browser to see index page containing list of all exposed data. Configuration items are sorted by type (ifplugin, telemetry, etc.)

Execute VPP CLI commands

curl -H "Content-Type: application/json" -X POST -d '{"vppclicommand":"show interface"}' http://0.0.0.0:9191/vpp/command

Dump NB objects

Here is the list of supported REST URLs. If configuration dump URL is used, the output is based on proto model structure for given data type together with VPP-specific data which are not a part of the model (indexes for interfaces or ACLs, internal names, etc.). Those data are in separate section labeled as Meta.

Access lists

URLs to obtain ACL IP/MACIP configuration are as follows.

curl GET http://0.0.0.0:9191/vpp/dump/v1/acl/ip
curl GET http://0.0.0.0:9191/vpp/dump/v1/acl/macip 

VPP Interfaces

REST plugin exposes configured VPP interfaces, which can be show all together, or only interfaces of specific type.

curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces
curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces/loopback
curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces/ethernet
curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces/memif
curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces/tap
curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces/vxlan
curl GET http://0.0.0.0:9191/vpp/dump/v1/interfaces/afpacket

Linux Interfaces

REST plugin exposes configured Linux interfaces. All configured interfaces are dumped, together with all interfaces in default namespace

curl GET https://0.0.0.0:9191/linux/dump/v1/interfaces

BFD

REST plugin allows to dump bidirectional forwarding detection sessions, authentication keys, or the whole configuration.

curl GET http://0.0.0.0:9191/vpp/dump/v1/bfd
curl GET http://0.0.0.0:9191/vpp/dump/v1/bfd/sessions
curl GET http://0.0.0.0:9191/vpp/dump/v1/bfd/authkeys

NAT

REST plugin allows to dump NAT44 global configuration, DNAT configuration or both of them together. SNAT is currently not supported in the model, so REST dump is not available as well.

curl GET http://0.0.0.0:9191/vpp/dump/v1/nat
curl GET http://0.0.0.0:9191/vpp/dump/v1/nat/global
curl GET http://0.0.0.0:9191/vpp/dump/v1/nat/dnat

STN

Steal the NIC feature REST API contains one uri returning the list of STN rules.

curl GET http://0.0.0.0:9191/vpp/dump/v1/stn

L2 plugin

Support for bridge domains, FIBs and cross connects. It is also possible to get all the bridge domain IDs.

curl GET http://0.0.0.0:9191/vpp/dump/v1/bdid
curl GET http://0.0.0.0:9191/vpp/dump/v1/bd
curl GET http://0.0.0.0:9191/vpp/dump/v1/fib
curl GET http://0.0.0.0:9191/vpp/dump/v1/xc

L3 plugin

ARPs, proxy ARP interfaces/ranges and static routes exposed via REST:

curl GET http://0.0.0.0:9191/vpp/dump/v1/arps
curl GET http://0.0.0.0:9191/vpp/dump/v1/proxyarp/interfaces
curl GET http://0.0.0.0:9191/vpp/dump/v1/proxyarp/ranges
curl GET http://0.0.0.0:9191/vpp/dump/v1/routes

Linux L3 plugin

Linux ARP and linux routes exposed via REST:

curl GET http://0.0.0.0:9191/linux/dump/v1/arps
curl GET http://0.0.0.0:9191/linux/dump/v1/routes

L4 plugin

L4 plugin exposes session configuration:

curl GET http://0.0.0.0:9191/vpp/dump/v1/sessions

Telemetry

REST allows to get all the telemetry data, or selective using specific key:

curl GET http://0.0.0.0:9191/vpp/dump/v1/telemetry
curl GET http://0.0.0.0:9191/vpp/dump/v1/telemetry/memory
curl GET http://0.0.0.0:9191/vpp/dump/v1/telemetry/runtime
curl GET http://0.0.0.0:9191/vpp/dump/v1/telemetry/nodecount

Logging mechanism

The REST API request is logged to stdout. The log contains VPPCLI command and VPPCLI response. It is searchable in elastic search using "VPPCLI".

Documentation

Index

Constants

View Source
const (
	GET  = "GET"
	POST = "POST"
)

REST api methods

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Deps

type Deps struct {
	infra.PluginDeps
	HTTPHandlers rest.HTTPHandlers
	GoVppmux     govppmux.TraceAPI
	VPP          vpp.API
	Linux        linux.API
}

Deps represents dependencies of Rest Plugin

type Option

type Option func(*Plugin)

Option is a function that acts on a Plugin to inject Dependencies or configuration

func UseDeps

func UseDeps(cb func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

type Plugin

type Plugin struct {
	Deps
	// contains filtered or unexported fields
}

Plugin registers Rest Plugin

func NewPlugin

func NewPlugin(opts ...Option) *Plugin

NewPlugin creates a new Plugin with the provides Options

func (*Plugin) AfterInit

func (plugin *Plugin) AfterInit() (err error)

AfterInit is used to register HTTP handlers

func (*Plugin) Close

func (plugin *Plugin) Close() (err error)

Close is used to clean up resources used by Plugin

func (*Plugin) Init

func (plugin *Plugin) Init() (err error)

Init initializes the Rest Plugin

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL