Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
2 files
+ 47
38
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -7,42 +7,49 @@ import (
// PrincipalNetworkDomain provides an
// interface for PND implementations
type PrincipalNetworkDomain interface {
GetName() string
Destroy() error
AddSbi() error
RemoveSbi() error
AddSbi(SouthboundInterface) error
RemoveSbi(string) error
AddDevice(Device) error
RemoveDevice(uuid uuid.UUID) error
}
type pndImplementation struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
Name string
Description string
Sbi map[string]SouthboundInterface
Devices map[uuid.UUID]Device
}
//NewPND creates a Principle Network Domain
func NewPND(name string, sbi SouthboundInterface) PrincipalNetworkDomain {
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,
sbi: sbic,
devices: devices,
Name: name,
Description: description,
Sbi: sbic,
Devices: devices,
}
}
func (pnd *pndImplementation) GetName() string {
return pnd.Name
}
// Interface satisfaction
func (pnd *pndImplementation) Destroy() error {
return destroy()
}
func (pnd *pndImplementation) AddSbi() error {
return addSbi()
func (pnd *pndImplementation) AddSbi(sbi SouthboundInterface) error {
return pnd.addSbi(sbi)
}
func (pnd *pndImplementation) RemoveSbi() error {
return removeSbi()
func (pnd *pndImplementation) RemoveSbi(sbiIdentifier string) error {
return pnd.removeSbi(sbiIdentifier)
}
func (pnd *pndImplementation) AddDevice(device Device) error {
@@ -59,20 +66,22 @@ func destroy() error {
return nil
}
func addSbi() error {
func (pnd *pndImplementation) addSbi(sbi SouthboundInterface) error {
pnd.Sbi[sbi.SbiIdentifier()] = sbi
return nil
}
func removeSbi() error {
func (pnd *pndImplementation) removeSbi(sbiIdentifier string) error {
delete(pnd.Sbi, sbiIdentifier)
return nil
}
func (pnd *pndImplementation) addDevice(device Device) error {
pnd.devices[device.Config.Uuid] = device
pnd.Devices[device.Config.Uuid] = device
return nil
}
func (pnd *pndImplementation) removeDevice(uuid uuid.UUID) error {
delete(pnd.devices, uuid)
delete(pnd.Devices, uuid)
return nil
}
Loading