Skip to content
Snippets Groups Projects
Commit 2b98902c authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Merge branch '64-openconfig-transport-to-core' into 67-overhaul-architecture

parents b55ca57f eefebce5
No related branches found
No related tags found
4 merge requests!90Develop,!88Use SPF Viper for configuration,!85Draft: Resolve "Overhaul Architecture",!53V.0.1.0 Codename Threadbare
package interfaces
// Client provides an interface for
// SBI protocol clients
type Client interface {
GetConfig() ClientConfig
}
package interfaces
// Port provides an interface for
// the device's ports
type Port interface {
}
// Client provides an interface for
// SBI client implementations
type Client interface {
GetConfig() ClientConfig
ListPorts() map[int]Port
PushReceiver() error
}
// PrincipalNetworkDomain provides an
// interface for PND implementations
type PrincipalNetworkDomain interface {
Destroy() error
AddSbi() error
RemoveSbi() error
}
// SouthboundInterface provides an
// interface for SBI implementations
type SouthboundInterface interface {
AddClient() error
RemoveClient() error
CollectHeartbeats() error
ListClients() map[int]Client
}
package nucleus
import "code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
type pndImplementation struct {
name string
sbiContainer []interfaces.SouthboundInterface
}
//NewPNDImplementation creates a Principle Network Domain
func NewPNDImplementation(name string, sbi ...interfaces.SouthboundInterface) interfaces.PrincipalNetworkDomain {
return &pndImplementation{
name: name,
sbiContainer: sbi,
}
}
// Interface satisfaction
func (pnd *pndImplementation) Destroy() error {
return destroy()
}
func (pnd *pndImplementation) AddSbi() error {
return addSbi()
}
func (pnd *pndImplementation) RemoveSbi() error {
return removeSbi()
}
// Actual implementation, bind to struct if
// neccessary
func destroy() error {
return nil
}
func addSbi() error {
return nil
}
func removeSbi() error {
return nil
}
package nucleus
import (
"fmt"
"os"
"plugin"
)
type SBIGreeter interface {
SBIHello()
}
func SBILoader () {
modPath := "/Users/mls/go/src/code.fbi.h-da.de/cocsn/byowsbi/byowsbi.o"
// open the so file that contains the SBI-plugin as step before loading the symbols
plug, err := plugin.Open(modPath)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// loading the symbols
sbiModule, err := plug.Lookup("SBIGreeter")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Assert the loaded symbol
var sbigreeter SBIGreeter
sbigreeter, ok := sbiModule.(SBIGreeter)
if !ok {
fmt.Println("unexpected type from module symbol")
os.Exit(1)
}
// use me!
sbigreeter.SBIHello()
}
...@@ -35,6 +35,18 @@ func (c MCPClient) GetConfig() interfaces.ClientConfig { ...@@ -35,6 +35,18 @@ func (c MCPClient) GetConfig() interfaces.ClientConfig {
return *c.config return *c.config
} }
// ListPorts is a stub to satisfy the interface
// TODO: Implement
func (c MCPClient) ListPorts() map[int]interfaces.Port {
return nil
}
// PushReceiver is a stub to satisfy the interface
// TODO: Implement
func (c MCPClient) PushReceiver() error {
return nil
}
//NewMCPClient creates a Ciena flavores TAPI client //NewMCPClient creates a Ciena flavores TAPI client
func NewMCPClient(endpoint, username, password string, database *database.Database, config *interfaces.ClientConfig) *MCPClient { func NewMCPClient(endpoint, username, password string, database *database.Database, config *interfaces.ClientConfig) *MCPClient {
// create the transport // create the transport
......
package restconf
import "code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
type southboundInterface struct {
name string
clientContainer []interfaces.Client
}
//NewSouthboundInterface creates a Southbound Interface
func NewSouthboundInterface(name string, clients ...interfaces.Client) interfaces.SouthboundInterface {
return &southboundInterface{
name: name,
clientContainer: clients,
}
}
// Interface satisfaction
func (sbi *southboundInterface) AddClient() error {
return addClient()
}
func (sbi *southboundInterface) RemoveClient() error {
return removeClient()
}
func (sbi *southboundInterface) CollectHeartbeats() error {
return collectHeartbeats()
}
func (sbi *southboundInterface) ListClients() map[int]interfaces.Client {
return listClients()
}
// Actual implementation, bind to struct if
// neccessary
func addClient() error {
return nil
}
func removeClient() error {
return nil
}
func collectHeartbeats() error {
return nil
}
func listClients() map[int]interfaces.Client {
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment