plugin

package
v0.0.0-...-c4de470 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

README

Plugin

plugin implements a runtime for OpenBaton plugins.

Currently, only vim-drivers are supported; see go-vimdriver-test for a sample implementation.

Implementing a VIM driver

A new plugin can be created by using the plugin.New(interface{}, *plugin.Params) (plugin.Plugin, error) function together with a plugin.Driver instance:

var driver plugin.Driver = &myDriver{}

params := &plugin.Params{ /* your configuration here */ }

plug, err := plugin.New(driver, params)
if err != nil {
    panic("error: " + err.Error())
}

(Ensure that your VIMDriver implements the plugin.Driver interface!)

The new plugin.Plugin can then be started using its Serve() method, blocking the current goroutine. Use Stop() to stop the service and quit.

if err := plug.Serve(); err != nil {
    panic("error while setting up plugin: " + err.Error())
}

For further informations

Check out the GoDoc.

Documentation

Overview

Package plugin implements a runtime for OpenBaton plugins.

Currently, only vim-drivers are supported; see the go-vimdriver-test repo for a sample implementation.

A new vim-driver plugin can be created by using the New() function together with a Driver instance:

var driver plugin.Driver = &myDriver{}

params := &plugin.Params{
    // insert your config here
}

plug, err := plugin.New(driver, params)
if err != nil {
    panic("error: " + err.Error())
}

Ensure that your VIMDriver implements the plugin.Driver interface.

The new plugin.Plugin can then be started using its Serve() method, blocking the current goroutine. Use Stop() to stop the service and quit.

if err := plug.Serve(); err != nil {
    panic("error while setting up plugin: " + err.Error())
}

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInitialised = errors.New("not connected yet. Retry later")
)
View Source
var (
	ErrProtocolFail error = plugError{"protocol error, NFVO and plugin are out of sync"}
)

Functions

This section is empty.

Types

type Driver

type Driver interface {
	AddFlavour(vimInstance *catalogue.VIMInstance, deploymentFlavour *catalogue.DeploymentFlavour) (*catalogue.DeploymentFlavour, error)

	AddImage(vimInstance *catalogue.VIMInstance, image *catalogue.NFVImage, imageFile []byte) (*catalogue.NFVImage, error)

	AddImageFromURL(vimInstance *catalogue.VIMInstance, image *catalogue.NFVImage, imageURL string) (*catalogue.NFVImage, error)

	CopyImage(vimInstance *catalogue.VIMInstance, image *catalogue.NFVImage, imageFile []byte) (*catalogue.NFVImage, error)

	CreateNetwork(vimInstance *catalogue.VIMInstance, network *catalogue.Network) (*catalogue.Network, error)

	CreateSubnet(vimInstance *catalogue.VIMInstance, createdNetwork *catalogue.Network, subnet *catalogue.Subnet) (*catalogue.Subnet, error)

	DeleteFlavour(vimInstance *catalogue.VIMInstance, extID string) (bool, error)

	DeleteImage(vimInstance *catalogue.VIMInstance, image *catalogue.NFVImage) (bool, error)

	DeleteNetwork(vimInstance *catalogue.VIMInstance, extID string) (bool, error)

	DeleteServerByIDAndWait(vimInstance *catalogue.VIMInstance, id string) error

	DeleteSubnet(vimInstance *catalogue.VIMInstance, existingSubnetExtID string) (bool, error)

	LaunchInstance(
		vimInstance *catalogue.VIMInstance,
		name, image, Flavour, keypair string,
		network, secGroup []string,
		userData string) (*catalogue.Server, error)

	LaunchInstanceAndWait(
		vimInstance *catalogue.VIMInstance,
		hostname, image, extID, keyPair string,
		networks, securityGroups []string,
		s string) (*catalogue.Server, error)

	LaunchInstanceAndWaitWithIPs(
		vimInstance *catalogue.VIMInstance,
		hostname, image, extID, keyPair string,
		networks, securityGroups []string,
		s string,
		floatingIps map[string]string,
		keys []*catalogue.Key) (*catalogue.Server, error)

	ListFlavours(vimInstance *catalogue.VIMInstance) ([]*catalogue.DeploymentFlavour, error)

	ListImages(vimInstance *catalogue.VIMInstance) ([]*catalogue.NFVImage, error)

	ListNetworks(vimInstance *catalogue.VIMInstance) ([]*catalogue.Network, error)

	ListServer(vimInstance *catalogue.VIMInstance) ([]*catalogue.Server, error)

	NetworkByID(vimInstance *catalogue.VIMInstance, id string) (*catalogue.Network, error)

	Quota(vimInstance *catalogue.VIMInstance) (*catalogue.Quota, error)

	SubnetsExtIDs(vimInstance *catalogue.VIMInstance, networkExtID string) ([]string, error)

	Type(vimInstance *catalogue.VIMInstance) (string, error)

	UpdateFlavour(vimInstance *catalogue.VIMInstance, deploymentFlavour *catalogue.DeploymentFlavour) (*catalogue.DeploymentFlavour, error)

	UpdateImage(vimInstance *catalogue.VIMInstance, image *catalogue.NFVImage) (*catalogue.NFVImage, error)

	UpdateNetwork(vimInstance *catalogue.VIMInstance, network *catalogue.Network) (*catalogue.Network, error)

	UpdateSubnet(vimInstance *catalogue.VIMInstance, createdNetwork *catalogue.Network, subnet *catalogue.Subnet) (*catalogue.Subnet, error)
}

Driver describes a VIMDriver. Every driver implementation must adhere to this interface and implements its methods.

type DriverError

type DriverError struct {
	Message           string `json:"detailMessage"`
	*catalogue.Server `json:"server"`
}

DriverError is a special error type that also specifies a catalogue.Server to be returned to the NFVO.

func (DriverError) Error

func (e DriverError) Error() string

Error returns a description of the error.

type Params

type Params struct {
	// BrokerAddress is the address at which the broker AMQP server can be reached.
	BrokerAddress string

	// Port of the AMQP broker.
	Port int

	// Username, Password for the AMQP broker.
	Username, Password string

	// LogFile contains the path to the log file.
	// Use "" to use defaults, or "-" to use stderr.
	LogFile string

	// Name is a parameter provided by the NFVO, usually "openbaton"
	Name string

	// Type is a string that identifies the type of this plugin.
	Type string

	// Workers determines how many workers the plugin will spawn.
	// Set this number according to your needs.
	Workers int

	// LogLevel sets the minimum logging level for the internal instance of logrus.Logger.
	LogLevel log.Level
}

Params is a struct containing the plugin's configuration.

type Plugin

type Plugin interface {
	// ChannelAccessor returns a closure that returns the underlying *amqp.Channel of this Plugin.
	ChannelAccessor() func() (*amqp.Channel, error)

	// Logger returns the internal logger of this Plugin.
	Logger() *log.Logger

	// Serve spawns the Plugin, blocking the current goroutine.
	// Serve only returns non-nil errors during the initialisation phase.
	// Check the log and the return value of Stop() for runtime and on-closing errors respectively.
	Serve() error

	// Stop() signals the event loop of the plugin to quit, and waits until either it shuts down or
	// it times out.
	Stop() error

	// Type() returns the type of this plugin, as specified by its parameters during construction.
	Type() string
}

Plugin represents a plugin instance.

func New

func New(impl interface{}, p *Params) (Plugin, error)

New creates a plugin from an implementation and plugin.Params. impl must be of a valid Plugin implementation type, like plugin.Driver.

Jump to

Keyboard shortcuts

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