restplugin

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

README

REST API Plugin

The restplugin is a core Agent Plugin used of exposing 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/

Exposing existing Northbound objects

curl http://0.0.0.0:9191/interfaces
curl http://0.0.0.0:9191/bridgedomainids
curl http://0.0.0.0:9191/bridgedomains
curl http://0.0.0.0:9191/fibs
curl http://0.0.0.0:9191/xconnectpairs
curl http://0.0.0.0:9191/staticroutes
curl http://0.0.0.0:9191/acl/interface/<if-sw-index>    // Get ACLs for interface <if-sw-index>
curl http://0.0.0.0:9191/acl/ip                         // Get all IP ACLs  
curl http://0.0.0.0:9191/acl/ip/example                 // Get an example ACL 

Configure an IP ACL:

curl -H "Content-Type: application/json" -X POST -d '<acl-json>' http://0.0.0.0:9191/interface/acl/ip

For example:

curl -H "Content-Type: application/json" -X POST -d '{
    "acl_name": "example"
    "rules": [
        {
            "rule_name": "acl1_rule1",                                                                                                        {                                                                                                                     "actions": {
            "acl_action": 1,
            "match": {
                "ip_rule": {
                    "ip": {
                        "destination_network": "1.2.3.4/24",
                        "source_network": "5.6.7.8/24"
                    },
                    "tcp": {
                        "destination_port_range": {
                            "lower_port": 80,
                            "upper_port": 8080
                        },
                        "source_port_range": {
                            "lower_port": 10,
                            "upper_port": 1010
                        },
                        "tcp_flags_mask": 255,
                        "tcp_flags_value": 9
                    }
                }
            }
        }
    ]
}' http://0.0.0.0:9191/interface/acl/ip

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

This section is empty.

Variables

This section is empty.

Functions

func Asset added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset added in v1.4.0

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 added in v1.4.0

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v1.4.0

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Deps added in v1.4.0

type Deps struct {
	local.PluginInfraDeps
	HTTPHandlers rest.HTTPHandlers
	GoVppmux     govppmux.API
}

Deps represents dependencies of Rest Plugin

type Plugin added in v1.4.0

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

Plugin registers Rest Plugin

func (*Plugin) AfterInit added in v1.4.0

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

AfterInit is used to register HTTP handlers

func (*Plugin) Close added in v1.4.0

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

Close is used to clean up resources used by Plugin

func (*Plugin) Init added in v1.4.0

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

Init initializes the Rest Plugin

Jump to

Keyboard shortcuts

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