-
Malte Bauch authored
- added initial sbis in controller - added getter/setter transport in southbound - added multiple geeter in principalNetworkDomain
Malte Bauch authored- added initial sbis in controller - added getter/setter transport in southbound - added multiple geeter in principalNetworkDomain
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
principalNetworkDomain.go 2.28 KiB
package nucleus
import (
"github.com/google/uuid"
)
// PrincipalNetworkDomain provides an
// interface for PND implementations
type PrincipalNetworkDomain interface {
GetName() string
GetDescription() string
GetDevices() map[uuid.UUID]Device
GetSBIs() map[string]SouthboundInterface
Destroy() error
AddSbi(SouthboundInterface) error
RemoveSbi(string) error
AddDevice(Device) error
RemoveDevice(uuid uuid.UUID) error
}
type pndImplementation struct {
Name string
Description string
Sbi map[string]SouthboundInterface
Devices map[uuid.UUID]Device
}
//NewPND creates a Principle Network Domain
func NewPND(name, description string, sbi SouthboundInterface) PrincipalNetworkDomain {
sbic := make(map[string]SouthboundInterface)
sbic["default"] = sbi
devices := make(map[uuid.UUID]Device)
return &pndImplementation{
Name: name,
Description: description,
Sbi: sbic,
Devices: devices,
}
}
func (pnd *pndImplementation) GetName() string {
return pnd.Name
}
func (pnd *pndImplementation) GetDevices() map[uuid.UUID]Device {
return pnd.Devices
}
func (pnd *pndImplementation) GetDescription() string {
return pnd.Description
}
func (pnd *pndImplementation) GetSBIs() map[string]SouthboundInterface {
return pnd.Sbi
}
// Interface satisfaction
func (pnd *pndImplementation) Destroy() error {
return destroy()
}
func (pnd *pndImplementation) AddSbi(sbi SouthboundInterface) error {
return pnd.addSbi(sbi)
}
func (pnd *pndImplementation) RemoveSbi(sbiIdentifier string) error {
return pnd.removeSbi(sbiIdentifier)
}
func (pnd *pndImplementation) AddDevice(device Device) error {
return pnd.addDevice(device)
}
func (pnd *pndImplementation) RemoveDevice(uuid uuid.UUID) error {
return pnd.removeDevice(uuid)
}
// Actual implementation, bind to struct if
// neccessary
func destroy() error {
return nil
}
func (pnd *pndImplementation) addSbi(sbi SouthboundInterface) error {
pnd.Sbi[sbi.SbiIdentifier()] = sbi
return nil
}
func (pnd *pndImplementation) removeSbi(sbiIdentifier string) error {
delete(pnd.Sbi, sbiIdentifier)
return nil
}
func (pnd *pndImplementation) addDevice(device Device) error {
pnd.Devices[device.Uuid] = device
return nil
}
func (pnd *pndImplementation) removeDevice(uuid uuid.UUID) error {
delete(pnd.Devices, uuid)
return nil
}