database

package module
v0.0.0-...-d53b600 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const EPELinkName = "EPELink"
View Source
const EPENodeName = "EPENode"
View Source
const EPEPrefixName = "EPEPrefix"
View Source
const L3VPNNodeName = "L3VPNNode"
View Source
const L3VPNPrefixName = "L3VPNPrefix"
View Source
const LSLinkName = "LSLink"
View Source
const LSNodeName = "LSNode"
View Source
const RouterName = "Routers"

Variables

View Source
var (
	ErrEmptyConfig = errors.New("ArangoDB Config has an empty field")
	ErrUpSafe      = errors.New("Failed to UpdateSafe. Requires *DBObjects")
	ErrNilObject   = errors.New("Failed to operate on NIL object")
	ErrNotFound    = errors.New("Document not found")
)
View Source
var (
	ErrKeyInvalid = errors.New("Error: Key value is invalid")
	ErrKeyChange  = errors.New("Error: Key value changed")
)
View Source
var (
	ErrCollectionNotFound = fmt.Errorf("Could not find collection")
)

Functions

func GetID

func GetID(i DBObject) (string, error)

Types

type ArangoConfig

type ArangoConfig struct {
	URL      string `desc:"Arangodb server URL (http://127.0.0.1:8529)"`
	User     string `desc:"Arangodb server username"`
	Password string `desc:"Arangodb server user password"`
	Database string `desc:"Arangodb database name"`
}

func NewConfig

func NewConfig() ArangoConfig

type ArangoConn

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

func NewArango

func NewArango(cfg ArangoConfig) (*ArangoConn, error)

func (*ArangoConn) CheckExistingEPENode

func (a *ArangoConn) CheckExistingEPENode(local_bgp_id string) bool

func (*ArangoConn) CheckExistingL3VPNNode

func (a *ArangoConn) CheckExistingL3VPNNode(router_ip string) bool

func (*ArangoConn) CheckExistingL3VPNRouter

func (a *ArangoConn) CheckExistingL3VPNRouter(router_ip string) bool

func (*ArangoConn) CreateAdjacencyList

func (a *ArangoConn) CreateAdjacencyList(key string, adjacency_sid string, flags string, weight string)

func (*ArangoConn) Delete

func (a *ArangoConn) Delete(i DBObject) error

func (*ArangoConn) GetExistingPeerIP

func (a *ArangoConn) GetExistingPeerIP(local_bgp_id string) []string

func (*ArangoConn) GetExistingVPNRDS

func (a *ArangoConn) GetExistingVPNRDS(router_ip string) []string

func (*ArangoConn) GetSIDIndex

func (a *ArangoConn) GetSIDIndex(ip string) string

func (*ArangoConn) Insert

func (a *ArangoConn) Insert(i DBObject) error

Interfaces must set their own key if they want to manage their own keys

func (*ArangoConn) Query

func (a *ArangoConn) Query(q string, bind map[string]interface{}, obj interface{}) ([]interface{}, error)

func (*ArangoConn) QueryOnObject

func (a *ArangoConn) QueryOnObject(obj DBObject, ret interface{}, operators map[string]string) ([]interface{}, error)

This function does not support complex types, []string does not work. Router.Interface specifically

func (*ArangoConn) Read

func (a *ArangoConn) Read(i DBObject) error

func (*ArangoConn) Update

func (a *ArangoConn) Update(i DBObject) error

func (*ArangoConn) UpdateExistingPeerIP

func (a *ArangoConn) UpdateExistingPeerIP(local_bgp_id string, peer_ip string)

func (*ArangoConn) UpdateExistingVPNRDS

func (a *ArangoConn) UpdateExistingVPNRDS(router_ip string, vpn_rd string)

func (*ArangoConn) Upsert

func (a *ArangoConn) Upsert(i DBObject) error

func (*ArangoConn) UpsertSafe

func (a *ArangoConn) UpsertSafe(i DBObject) error

type DBObject

type DBObject interface {
	GetKey() (string, error)
	SetKey() error

	GetType() string
	// contains filtered or unexported methods
}

type Database

type Database interface {
	Insert(DBObject) error
	Update(DBObject) error
	Upsert(DBObject) error
	UpsertSafe(DBObject) error
	Read(DBObject) error
	Delete(DBObject) error
	Query(string, map[string]interface{}, interface{}) ([]interface{}, error)
	QueryOnObject(DBObject, interface{}, map[string]string) ([]interface{}, error)
}

Database is the interface definition of a database object

type EPELink struct {
	Key              string `json:"_key,omitempty"`
	RouterID         string `json:"RouterID,omitempty"`
	ASN              string `json:"ASN,omitempty"`
	PeerRouterID     string `json:"PeerRouterID,omitempty"`
	LocalInterfaceIP string `json:"LocalInterfaceIP,omitempty"`
	PeerIP           string `json:"PeerIP,omitempty"`
	Protocol         string `json:"Protocol,omitempty"`
	LocalPref        string `json:"LocalPref,omitempty"`
	MED              string `json:"MED,omitempty"`
	Nexthop          string `json:"Nexthop,omitempty"`
	EPELabel         string `json:"EPELabel,omitempty"`
}

func (EPELink) GetKey

func (r EPELink) GetKey() (string, error)

func (EPELink) GetType

func (r EPELink) GetType() string

func (*EPELink) SetKey

func (r *EPELink) SetKey() error

type EPENode

type EPENode struct {
	Key      string   `json:"_key,omitempty"`
	Name     string   `json:"Name,omitempty"`
	RouterID string   `json:"RouterID,omitempty"`
	PeerIP   []string `json:"PeerIP,omitempty"`
	ASN      string   `json:"ASN,omitempty"`
}

func (EPENode) GetKey

func (r EPENode) GetKey() (string, error)

func (EPENode) GetType

func (r EPENode) GetType() string

func (*EPENode) SetKey

func (r *EPENode) SetKey() error

type EPEPrefix

type EPEPrefix struct {
	Key           string `json:"_key,omitempty"`
	Prefix        string `json:"Prefix,omitempty"`
	Length        string `json:"Length,omitempty"`
	PeerIP        string `json:"PeerIP,omitempty"`
	PeerASN       string `json:"PeerASN,omitempty"`
	Nexthop       string `json:"Nexthop,omitempty"`
	OriginASN     string `json:"OriginASN,omitempty"`
	ASPath        string `json:"ASPath,omitempty"`
	ASPathCount   string `json:"ASPathCount,omitempty"`
	MED           string `json:"MED,omitempty"`
	LocalPref     string `json:"LocalPref,omitempty"`
	CommunityList string `json:"CommunityList,omitempty"`
	ExtComm       string `json:"ExtComm,omitempty"`
	IsIPv4        string `json:"IsIPv4,omitempty"`
	IsNexthopIPv4 string `json:"IsNexthopIPv4,omitempty"`
	Labels        string `json:"Labels,omitempty"`
}

func (EPEPrefix) GetKey

func (r EPEPrefix) GetKey() (string, error)

func (EPEPrefix) GetType

func (r EPEPrefix) GetType() string

func (*EPEPrefix) SetKey

func (r *EPEPrefix) SetKey() error

type EdgeObject

type EdgeObject interface {
	//To, From
	SetEdge(DBObject, DBObject)
}

type L3VPNNode

type L3VPNNode struct {
	Key            string   `json:"_key,omitempty"`
	RD             []string `json:"RD,omitempty"`
	RouterID       string   `json:"RouterID,omitempty"`
	ControlPlaneID string   `json:"ControlPlaneID,omitempty"`
	ASN            string   `json:"ASN,omitempty"`
	Prefix_SID     string   `json:"Prefix_SID,omitempty"`
	ExtComm        string   `json:"ExtComm,omitempty"`
}

func (L3VPNNode) GetKey

func (r L3VPNNode) GetKey() (string, error)

func (L3VPNNode) GetType

func (r L3VPNNode) GetType() string

func (*L3VPNNode) SetKey

func (r *L3VPNNode) SetKey() error

type L3VPNPrefix

type L3VPNPrefix struct {
	Key            string `json:"_key,omitempty"`
	RD             string `json:"RD,omitempty"`
	Prefix         string `json:"Prefix,omitempty"`
	Length         int    `json:"Length,omitempty"`
	RouterID       string `json:"RouterID,omitempty"`
	ControlPlaneID string `json:"ControlPlaneID,omitempty"`
	ASN            string `json:"ASN,omitempty"`
	VPN_Label      int    `json:"VPN_Label,omitempty"`
	ExtComm        string `json:"ExtComm,omitempty"`
	IPv4           string `json:"IPv4,omitempty"`
}

func (L3VPNPrefix) GetKey

func (p L3VPNPrefix) GetKey() (string, error)

func (L3VPNPrefix) GetType

func (p L3VPNPrefix) GetType() string

func (*L3VPNPrefix) SetKey

func (p *L3VPNPrefix) SetKey() error
type LSLink struct {
	LocalRouterKey    string `json:"_from,omitempty"`
	RemoteRouterKey   string `json:"_to,omitempty"`
	Key               string `json:"_key,omitempty"`
	LocalRouterID     string `json:"LocalRouterID,omitempty"`
	RemoteRouterID    string `json:"RemoteRouterID,omitempty"`
	Protocol          string `json:"Protocol,omitempty"`
	IGPID             string `json:"IGPID,omitempty"`
	Level             string `json:"Level,omitempty"`
	RouterID          string `json:"RouterID,omitempty"`
	NodeName          string `json:"NodeName,omitempty"`
	ASN               string `json:"ASN,omitempty"`
	LocalInterfaceIP  string `json:"FromInterfaceIP,omitempty"`
	RemoteInterfaceIP string `json:"ToInterfaceIP,omitempty"`
	IGPMetric         string `json:"IGPMetric,omitempty"`
	TEMetric          string `json:"TEMetric,omitempty"`
	AdminGroup        string `json:"AdminGroup,omitempty"`
	MaxLinkBW         string `json:"MaxLinkBW,omitempty"`
	MaxResvBW         string `json:"MaxResvBW,omitempty"`
	UnResvBW          string `json:"UnResvBW,omitempty"`
	LinkProtection    string `json:"LinkProtection,omitempty"`
	LinkName          string `json:"LinkName,omitempty"`
	SRLG              string `json:"SRLG"`
	UniDirMinDelay    string `json:"UniDirMinDelay,omitempty"`
	AdjacencySID      string `json:"AdjacencySID,omitempty"`
}

func (LSLink) GetKey

func (l LSLink) GetKey() (string, error)

func (LSLink) GetType

func (l LSLink) GetType() string

func (*LSLink) SetEdge

func (l *LSLink) SetEdge(to DBObject, from DBObject) error

func (*LSLink) SetKey

func (l *LSLink) SetKey() error

type LSNode

type LSNode struct {
	Key      string `json:"_key,omitempty"`
	Name     string `json:"Name,omitempty"`
	RouterID string `json:"RouterID,omitempty"`
	//BGPID        string `json:"BGPID,omitempty"`
	ASN       string `json:"ASN,omitempty"`
	SRGB      string `json:"SRGB,omitempty"`
	SIDIndex  string `json:"SIDIndex,omitempty"`
	PrefixSID string `json:"PrefixSID,omitempty"`
	IGPID     string `json:"IGPID,omitempty"`
}

func (LSNode) GetKey

func (r LSNode) GetKey() (string, error)

func (LSNode) GetType

func (r LSNode) GetType() string

func (*LSNode) SetKey

func (r *LSNode) SetKey() error

type Router

type Router struct {
	Key          string `json:"_key,omitempty"`
	Name         string `json:"Name,omitempty"`
	RouterIP     string `json:"RouterIP,omitempty"`
	BGPID        string `json:"BGPID,omitempty"`
	ASN          string `json:"ASN,omitempty"`
	SRGB         string `json:"SRGB,omitempty"`
	NodeSIDIndex string `json:"NodeSIDIndex,omitempty"`
	SRNodeSID    string `json:"SRNodeSID,omitempty"`
	PeeringType  string `json:"PeerType,omitempty"`
}

func (Router) GetKey

func (r Router) GetKey() (string, error)

func (Router) GetType

func (r Router) GetType() string

func (*Router) SetKey

func (r *Router) SetKey() error

Jump to

Keyboard shortcuts

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