protocols

package
v0.0.0-...-27f9d38 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: BSD-3-Clause, GPL-2.0, MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTERFACES_KEY             = "interfaces"
	INTERFACES_LIST_KEY        = "tagnode"
	SWITCH_INTERFACES_LIST_KEY = "name"
	VIF_KEY                    = "vif"
)

Common JSON configuration object keys

Variables

This section is empty.

Functions

func AddErrorContext

func AddErrorContext(e error, ctx string) error

func CallVtysh

func CallVtysh(cmd string) []byte

* Call out to VTYSH executing a command, logs error and returns output.

func ConvertConfigToInternalJson

func ConvertConfigToInternalJson(cfg []byte) ([]byte, error)

* Convert JSON configuration received from the configuration system into * the internal format expected by the ProtocolsModelComponent set, get, and * check callbacks. * * The input JSON is converted from RFC 7951 format, and interface configuration * is restructured, then returned as a new byte array.

func ConvertFromRfc7951Json

func ConvertFromRfc7951Json(rfc7591_json []byte) ([]byte, error)

* Decodes the RFC 7951 encoded JSON from the rfc7951_json byte array * and returns this as a new byte array.

func ConvertInterfaceConfig

func ConvertInterfaceConfig(cfg_map map[string]interface{}) map[string]interface{}

* Modifies the configuration structure defined by cfg_map to remove the * interface type and move VIF configuration from beneath the respective * parent interface to the top level using the <parent>.<vif-num> name. * * If there is no INTERFACES_KEY entry in cfg_map then this function is a * no-op and cfg_map is simply returned.

func ConvertJsonInterfaceConfig

func ConvertJsonInterfaceConfig(cfg []byte) ([]byte, error)

* Translates any interface configuration into the expected format * * cfg should contain non-RFC 7951 encoded JSON

func EmptyConfig

func EmptyConfig() []byte

* Returns a byte array representing an empty configuration

func ExecCmd

func ExecCmd(cmd []string) []byte

* ExecCmd - Execute a command, log errors and returns output.

func FormatJson

func FormatJson(input_json []byte) []byte

* Pretty formats the input_json byte array into a new byte array

func GenerateVifName

func GenerateVifName(parent_name string, vif_num interface{}) string

* Returns a VIF interface name based on a parent interface name and VIF number

func IsEmptyConfig

func IsEmptyConfig(cfg []byte) bool

func MultiErrorBasicFormat

func MultiErrorBasicFormat(errors []error) string

func NewMultiError

func NewMultiError() *multierr.Error

func PrefixError

func PrefixError(e error, prefix string) error

func WriteJsonFile

func WriteJsonFile(json string, fileName string, owner string) error

Types

type CommonArgs

type CommonArgs struct {
	User string
}

func ParseCommonArgs

func ParseCommonArgs() *CommonArgs

type ProtocolsDaemon

type ProtocolsDaemon struct {
	// contains filtered or unexported fields
}

func NewProtocolsDaemon

func NewProtocolsDaemon(unit string) *ProtocolsDaemon

func (*ProtocolsDaemon) CancelStopAndDisable

func (pd *ProtocolsDaemon) CancelStopAndDisable() bool

func (*ProtocolsDaemon) Disable

func (pd *ProtocolsDaemon) Disable() error

func (*ProtocolsDaemon) Enable

func (pd *ProtocolsDaemon) Enable() error

func (*ProtocolsDaemon) GetUnitName

func (pd *ProtocolsDaemon) GetUnitName() string

func (*ProtocolsDaemon) LockControl

func (pd *ProtocolsDaemon) LockControl()

func (*ProtocolsDaemon) Restart

func (pd *ProtocolsDaemon) Restart() error

func (*ProtocolsDaemon) ScheduleStopAndDisable

func (pd *ProtocolsDaemon) ScheduleStopAndDisable()

func (*ProtocolsDaemon) Start

func (pd *ProtocolsDaemon) Start() error

func (*ProtocolsDaemon) Stop

func (pd *ProtocolsDaemon) Stop() error

func (*ProtocolsDaemon) StopAndDisableIfScheduled

func (pd *ProtocolsDaemon) StopAndDisableIfScheduled()

func (*ProtocolsDaemon) UnlockControl

func (pd *ProtocolsDaemon) UnlockControl()

type ProtocolsModelComponent

type ProtocolsModelComponent struct {
	// contains filtered or unexported fields
}

* The ProtocolsModelComponent structure is the building block of a * VCI component for a particular routing daemon. * * It implements utility functions for receiving and translating configuration, * writing configuration files, and more. * * A VCI component for a routing daemon should call NewProtocolsModelComponent() * to obtain a new instance, setting this as its VCI component model config.

func NewProtocolsModelComponent

func NewProtocolsModelComponent(
	componentName, modelName, configFileName string,
) *ProtocolsModelComponent

func (*ProtocolsModelComponent) AddDaemon

func (pmc *ProtocolsModelComponent) AddDaemon(pd *ProtocolsDaemon)

func (*ProtocolsModelComponent) Check

func (pmc *ProtocolsModelComponent) Check(cfg []byte) error

* VCI Check implementation * * This function checks (validates) the JSON configuration, after first * converting it to our internal format. * * If a check callback function has been set it is called and its result * returned. Otherwise this function is a no-op.

func (*ProtocolsModelComponent) CreateSubscription

func (pmc *ProtocolsModelComponent) CreateSubscription(namespace string, eventName string, callbackFunction func(in string))

* Create a subscription, run it, and add it to the Subscriptions map

func (*ProtocolsModelComponent) Get

func (pmc *ProtocolsModelComponent) Get() []byte

* VCI Get implementation * * If a get callback function has not been set, this function returns * the current contents of the system configuration file. Otherwise the * get callback is invoked.

func (*ProtocolsModelComponent) GetDaemon

func (pmc *ProtocolsModelComponent) GetDaemon(daemon string) *ProtocolsDaemon

func (*ProtocolsModelComponent) GetDaemonConfigFilePath

func (pmc *ProtocolsModelComponent) GetDaemonConfigFilePath() string

* Returns the path to the daemon configuration file

func (*ProtocolsModelComponent) GetDaemonNotificationFilePath

func (pmc *ProtocolsModelComponent) GetDaemonNotificationFilePath() string

* Returns the path to the watched daemon notification file

func (*ProtocolsModelComponent) GetModelName

func (pmc *ProtocolsModelComponent) GetModelName() string

* Returns the model name of this component

func (*ProtocolsModelComponent) GetSystemConfig

func (pmc *ProtocolsModelComponent) GetSystemConfig() ([]byte, error)

* Returns the currently cached system configuration as RFC 7951 encoded JSON

func (*ProtocolsModelComponent) GetSystemConfigFilePath

func (pmc *ProtocolsModelComponent) GetSystemConfigFilePath() string

* Returns the path to the system configuration file which contains the * pristine configuration received from the configuration system.

func (*ProtocolsModelComponent) NotifyDaemon

func (pmc *ProtocolsModelComponent) NotifyDaemon() error

* Notify the daemon to reload its configuration

func (*ProtocolsModelComponent) Run

func (pmc *ProtocolsModelComponent) Run() error

func (*ProtocolsModelComponent) Set

func (pmc *ProtocolsModelComponent) Set(cfg []byte) error

* VCI Set implementation * * This function receives and checks the RFC 7951 JSON configuration, * updates the cached system configuration file then decodes the config * into standard JSON. * * If a set function callback has been defined this is then invoked. This * callback is responsible for manipulating the configuration as required * and notifying its routing daemon of the new configuration. * * If a set callback is not defined the stripped configuration is simply * written to the daemon configuration file.

func (*ProtocolsModelComponent) SetCancelSubsFunction

func (pmc *ProtocolsModelComponent) SetCancelSubsFunction(cancelSubsFunc ProtocolsModelComponentCancelSubscriptionFunc)

func (*ProtocolsModelComponent) SetCheckFunction

func (pmc *ProtocolsModelComponent) SetCheckFunction(checkFunc ProtocolsModelComponentCheckFunc)

func (*ProtocolsModelComponent) SetGetFunction

func (pmc *ProtocolsModelComponent) SetGetFunction(getFunc ProtocolsModelComponentGetFunc)

func (*ProtocolsModelComponent) SetMeaningfulConfigFunction

func (pmc *ProtocolsModelComponent) SetMeaningfulConfigFunction(meanFunc ProtocolsModelComponentMeaningfulConfigFunc)

func (*ProtocolsModelComponent) SetRPC

func (pmc *ProtocolsModelComponent) SetRPC(rpcName string, rpc interface{})

func (*ProtocolsModelComponent) SetRegisterSubsFunction

func (pmc *ProtocolsModelComponent) SetRegisterSubsFunction(registerSubsFunc ProtocolsModelComponentRegisterSubscriptionFunc)

func (*ProtocolsModelComponent) SetSetFunction

func (pmc *ProtocolsModelComponent) SetSetFunction(setFunc ProtocolsModelComponentSetFunc)

func (*ProtocolsModelComponent) SetSystemConfig

func (pmc *ProtocolsModelComponent) SetSystemConfig(cfg []byte) error

* Write the RFC 7951 JSON contained in the cfg byte array to the cached * system configuration file

func (*ProtocolsModelComponent) WriteDaemonConfig

func (pmc *ProtocolsModelComponent) WriteDaemonConfig(cfg []byte) error

* Write the JSON contained in the cfg byte array to the daemon configuration file

func (*ProtocolsModelComponent) WriteJsonFile

func (pmc *ProtocolsModelComponent) WriteJsonFile(json []byte, path string) error

* Writes a JSON file in the context of a ProtocolsModelComponent

type ProtocolsModelComponentCancelSubscriptionFunc

type ProtocolsModelComponentCancelSubscriptionFunc func(*ProtocolsModelComponent)

type ProtocolsModelComponentCheckFunc

type ProtocolsModelComponentCheckFunc func(*ProtocolsModelComponent, []byte) error

type ProtocolsModelComponentConfig

type ProtocolsModelComponentConfig struct {
	Interfaces []struct {
		Tagnode string                 `json:"tagnode,omitempty"`
		Name    string                 `json:"name,omitempty"`
		Ip      map[string]interface{} `json:"ip,omitempty"`
		Ipv6    map[string]interface{} `json:"ipv6,omitempty"`
	} `json:"interfaces,omitempty"`
	Protocols map[string]interface{} `json:"protocols,omitempty"`
	Routing   struct {
		RoutingInstance []struct {
			InstanceName string                 `json:"instance-name,omitempty"`
			Protocols    map[string]interface{} `json:"protocols,omitempty"`
		} `json:"routing-instance,omitempty"`
	} `json:"routing,omitempty"`
}

func ParseJsonComponentConfig

func ParseJsonComponentConfig(cfg []byte) (*ProtocolsModelComponentConfig, error)

type ProtocolsModelComponentGetFunc

type ProtocolsModelComponentGetFunc func(*ProtocolsModelComponent) []byte

type ProtocolsModelComponentMeaningfulConfigFunc

type ProtocolsModelComponentMeaningfulConfigFunc func(*ProtocolsModelComponent, []byte) bool

type ProtocolsModelComponentRegisterSubscriptionFunc

type ProtocolsModelComponentRegisterSubscriptionFunc func(*ProtocolsModelComponent, []byte)

type ProtocolsModelComponentSetFunc

type ProtocolsModelComponentSetFunc func(*ProtocolsModelComponent, []byte) error

type ProtocolsSubscription

type ProtocolsSubscription struct {
	Namespace       string
	Event           string
	CallbackFunc    func(in string)
	SubscriptionObj *vci.Subscription
}

* ProtocolsSubscription defines everything needed to subscribe * and react to VCI event notifications. * When the event matching "Namespace:Event" is seen on * the VCI bus the CallbackFunc will be run.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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