Newer
Older
// PrincipalNetworkDomain provides an
// interface for PND implementations
type PrincipalNetworkDomain interface {
Destroy() error
AddSbi(SouthboundInterface) error
RemoveSbi(string) error
Request(uuid.UUID, string) error
RequestAll(string) error
Malte Bauch
committed
GetName() string
GetDescription() string
GetDevices() map[uuid.UUID]*Device
GetSBIs() map[string]SouthboundInterface
Name string `json:"name"`
Description string `json:"description"`
Sbi SouthboundInterfaceMap `json:"sbis"`
Malte Bauch
committed
Devices map[uuid.UUID]*Device `json:"devices"`
func NewPND(name, description string, sbi SouthboundInterface) PrincipalNetworkDomain {
devices := make(map[uuid.UUID]*Device)
Name: name,
Description: description,
Sbi: sbic,
Devices: devices,
func (pnd *pndImplementation) GetName() string {
return pnd.Name
}
Malte Bauch
committed
func (pnd *pndImplementation) GetDevices() map[uuid.UUID]*Device {
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 {
}
func (pnd *pndImplementation) RemoveDevice(uuid uuid.UUID) error {
// Actual implementation, bind to struct if
// neccessary
func destroy() error {
return nil
}
func (pnd *pndImplementation) addSbi(sbi SouthboundInterface) error {
pnd.Sbi[sbi.SbiIdentifier()] = sbi
func (pnd *pndImplementation) removeSbi(sbiIdentifier string) error {
delete(pnd.Sbi, sbiIdentifier)
func (pnd *pndImplementation) addDevice(device *Device) error {
Malte Bauch
committed
pnd.Devices[device.Config.Uuid] = device
func (pnd *pndImplementation) removeDevice(uuid uuid.UUID) error {
func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) error {
Malte Bauch
committed
d := pnd.Devices[uuid]
ctx := context.Background()
_, err := d.Transport.Get(ctx, path)
if err != nil {
return err
}
return nil
}
func (pnd *pndImplementation) RequestAll(path string) error {
Malte Bauch
committed
for k := range pnd.Devices {
if err := pnd.Request(k, path); err != nil {
return err
}
}
return nil
}