diff --git a/nucleus/interfaces/client.go b/nucleus/interfaces/client.go deleted file mode 100644 index 4d0b9e1ceaf68a23f8089fb0703efd219546a217..0000000000000000000000000000000000000000 --- a/nucleus/interfaces/client.go +++ /dev/null @@ -1,7 +0,0 @@ -package interfaces - -// Client provides an interface for -// SBI protocol clients -type Client interface { - GetConfig() ClientConfig -} diff --git a/nucleus/interfaces/interfaces.go b/nucleus/interfaces/interfaces.go new file mode 100644 index 0000000000000000000000000000000000000000..b1fab9242901d819e04198b2ebe2f355ad5ab326 --- /dev/null +++ b/nucleus/interfaces/interfaces.go @@ -0,0 +1,31 @@ +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 +} diff --git a/nucleus/principalNetworkDomain.go b/nucleus/principalNetworkDomain.go new file mode 100644 index 0000000000000000000000000000000000000000..f77f544dca7f7fe9813cbc53e88ecdb105a88179 --- /dev/null +++ b/nucleus/principalNetworkDomain.go @@ -0,0 +1,43 @@ +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 +} diff --git a/nucleus/sbi-general.go b/nucleus/sbi-general.go new file mode 100644 index 0000000000000000000000000000000000000000..0795a665354292cd1a09e2051b84658f3607d72e --- /dev/null +++ b/nucleus/sbi-general.go @@ -0,0 +1,41 @@ +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() +} + diff --git a/sbi/restconf/client/ciena/client.go b/sbi/restconf/client/ciena/client.go index 7b994496a17a145ce2b6ed5c207e0fb55b8b8435..853afbf12ff5d628f726300daff2738607d1163f 100644 --- a/sbi/restconf/client/ciena/client.go +++ b/sbi/restconf/client/ciena/client.go @@ -35,6 +35,18 @@ func (c MCPClient) GetConfig() interfaces.ClientConfig { 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 func NewMCPClient(endpoint, username, password string, database *database.Database, config *interfaces.ClientConfig) *MCPClient { // create the transport diff --git a/sbi/restconf/southboundInterface.go b/sbi/restconf/southboundInterface.go new file mode 100644 index 0000000000000000000000000000000000000000..1eae1e67bebe9b29aa969b4cf6fb7ae2b42de1a6 --- /dev/null +++ b/sbi/restconf/southboundInterface.go @@ -0,0 +1,51 @@ +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 +}