restapi

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

README

REST API Plugin

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

  • Run VPP CLI commands
  • Exposes existing Northbound objects
  • Provides logging mechanism so that the VPPCLI command and response can be searched in elastic search

VPP CLI commands

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

Exposing existing Northbound 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/v2/acl/ip
curl GET http://0.0.0.0:9191/vpp/dump/v2/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/v2/interfaces
curl GET http://0.0.0.0:9191/vpp/dump/v2/interfaces/loopback
curl GET http://0.0.0.0:9191/vpp/dump/v2/interfaces/ethernet
curl GET http://0.0.0.0:9191/vpp/dump/v2/interfaces/memif
curl GET http://0.0.0.0:9191/vpp/dump/v2/interfaces/tap
curl GET http://0.0.0.0:9191/vpp/dump/v2/interfaces/vxlan
curl GET http://0.0.0.0:9191/vpp/dump/v2/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/v2/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/v2/bfd
curl GET http://0.0.0.0:9191/vpp/dump/v2/bfd/sessions
curl GET http://0.0.0.0:9191/vpp/dump/v2/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/v2/nat
curl GET http://0.0.0.0:9191/vpp/dump/v2/nat/global
curl GET http://0.0.0.0:9191/vpp/dump/v2/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/v2/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/v2/bdid
curl GET http://0.0.0.0:9191/vpp/dump/v2/bd
curl GET http://0.0.0.0:9191/vpp/dump/v2/fib
curl GET http://0.0.0.0:9191/vpp/dump/v2/xc

L3 plugin

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

curl GET http://0.0.0.0:9191/vpp/dump/v2/arps
curl GET http://0.0.0.0:9191/vpp/dump/v2/proxyarp/interfaces
curl GET http://0.0.0.0:9191/vpp/dump/v2/proxyarp/ranges
curl GET http://0.0.0.0:9191/vpp/dump/v2/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/v2/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/v2/telemetry
curl GET http://0.0.0.0:9191/vpp/dump/v2/telemetry/memory
curl GET http://0.0.0.0:9191/vpp/dump/v2/telemetry/runtime
curl GET http://0.0.0.0:9191/vpp/dump/v2/telemetry/nodecount

CLI command

Allows to use VPP CLI command via REST. Commands are defined as a map as following:

curl POST http://0.0.0.0:9191/vpp/command -d '{"vppclicommand":"<command>"}'

Index

REST to get index page. Configuration items are sorted by type (ifplugin, telemetry, etc.)

curl GET http://0.0.0.0:9191/

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  = http.MethodGet
	POST = http.MethodPost
)

REST api methods

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of Plugin.

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
	VPPIfPlugin  ifplugin.API
	VPPL2Plugin  *l2plugin.L2Plugin
}

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 (p *Plugin) AfterInit() (err error)

AfterInit is used to register HTTP handlers

func (*Plugin) Close

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

Close is used to clean up resources used by Plugin

func (*Plugin) Init

func (p *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