diff --git a/controller/api/initialise_test.go b/controller/api/initialise_test.go index f5623392d679c39e9b4ae136535b2e159a8c13c3..cb092b8f4deb3c14d07ab4e3f6242cd72336874f 100644 --- a/controller/api/initialise_test.go +++ b/controller/api/initialise_test.go @@ -25,6 +25,7 @@ import ( "code.fbi.h-da.de/danet/gosdn/controller/mocks" nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/server" "code.fbi.h-da.de/danet/gosdn/controller/nucleus" + "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/util/proto" rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac" "code.fbi.h-da.de/danet/gosdn/controller/store" @@ -233,7 +234,7 @@ func bootstrapUnitTest() { pluginService, rpb.NewPluginRegistryServiceClient(&grpc.ClientConn{}), csbi.NewCsbiServiceClient(&grpc.ClientConn{}), - func(u uuid.UUID, c chan networkelement.Details) {}, + func(u uuid.UUID, c chan model.Details) {}, ) ppb.RegisterPndServiceServer(s, northbound.Pnd) diff --git a/controller/controller.go b/controller/controller.go index 2cf210ac348fd359bc71076744a5073ffe39a223..8737c07ed754ffd80d9bd723594b37584b268ab6 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -38,7 +38,6 @@ import ( "code.fbi.h-da.de/danet/gosdn/controller/config" "code.fbi.h-da.de/danet/gosdn/controller/conflict" eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" "code.fbi.h-da.de/danet/gosdn/controller/northbound/server" nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/server" @@ -410,7 +409,7 @@ func shutdown() error { return stopHttpServer() } -func callback(id uuid.UUID, ch chan networkelement.Details) { +func callback(id uuid.UUID, ch chan model.Details) { if ch != nil { c.pndStore.AddPendingChannel(id, ch) log.Infof("pending channel %v added", id) diff --git a/controller/interfaces/networkdomain/pndService.go b/controller/interfaces/networkdomain/pndService.go index df05d183e472cfaf3c61a2ada2e3959496ca7b9e..4945f247d89b7817ae4cbc44c339d06b34101d95 100644 --- a/controller/interfaces/networkdomain/pndService.go +++ b/controller/interfaces/networkdomain/pndService.go @@ -7,7 +7,7 @@ package networkdomain // Get(model.Query) (NetworkDomain, error) // GetAll() ([]NetworkDomain, error) // // Note: Implement these in case we want to use cSBI again. -// // PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) -// // AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) +// // PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) +// // AddPendingChannel(id uuid.UUID, ch chan model.Details) // // RemovePendingChannel(id uuid.UUID) // } diff --git a/controller/interfaces/networkelement/networkElement.go b/controller/interfaces/networkelement/networkElement.go deleted file mode 100644 index 295e7b784af48b6d66636024685c12763cbbfc21..0000000000000000000000000000000000000000 --- a/controller/interfaces/networkelement/networkElement.go +++ /dev/null @@ -1,100 +0,0 @@ -package networkelement - -import ( - "context" - - tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport" - "code.fbi.h-da.de/danet/gosdn/controller/conflict" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" - "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" - - "github.com/google/uuid" - gpb "github.com/openconfig/gnmi/proto/gnmi" - "github.com/openconfig/ygot/ygot" - log "github.com/sirupsen/logrus" - "google.golang.org/protobuf/proto" -) - -// NetworkElement represents an Managed Network Element (MNE) which is managed by -// nucleus. -type NetworkElement interface { - ID() uuid.UUID - GetModel() ([]byte, error) - GetPlugin() plugin.Plugin - GetModelAsFilteredCopy() ([]byte, error) - Transport() model.Transport - Name() string - ProcessResponse(proto.Message) error - IsTransportValid() bool - GetModelAsString() (string, error) - TransportAddress() string - GetMetadata() conflict.Metadata - PndID() uuid.UUID -} - -// Details contains details of a network element used by the cSBI mechanism. -type Details struct { - ID string - Address string - TransportOption *tpb.TransportOption -} - -// LoadedNetworkElement represents a Managed Network Element that was loaeded -// by using the Load() method of the NetworkElementStore. -type LoadedNetworkElement struct { - // ID represents the UUID of the LoadedNetworkElement. - ID string `json:"id" bson:"_id"` - // Name represents the name of the LoadedNetworkElement. - Name string `json:"name,omitempty"` - // TransportType represent the type of the transport in use of the LoadedNetworkElement. - TransportType string `json:"transport_type,omitempty" bson:"transport_type,omitempty"` - // TransportAddress represents the address from which the network element can be reached via the transport method. - TransportAddress string `json:"transport_address,omitempty" bson:"transport_address,omitempty"` - // TransportUsername is used for authentication via the transport method in use. - TransportUsername string `json:"transport_username,omitempty" bson:"transport_username,omitempty"` - // TransportPassword is used for authentication via the transport method in use. - TransportPassword string `json:"transport_password,omitempty" bson:"transport_password,omitempty"` - // Note: deprecated, should be removed. - TransportOptionCsbi bool `json:"transport_option_csbi,omitempty" bson:"transport_option_csbi,omitempty"` - // TransportTLS uses TLS from the client side when if true. - TransportTLS bool `json:"transport_tls,omitempty" bson:"transport_tls,omitempty"` - - // SBI indicates the southbound interface, which is used by this network element as UUID. - Plugin string `json:"plugin"` - Model string `json:"model,omitempty" bson:"model,omitempty"` - - Metadata conflict.Metadata `json:"metadata" bson:"metadata"` - - PndID string `json:"pnd_id" bson:"pnd_id"` -} - -// EnsureIntendedConfigurationIsAppliedOnNetworkElement pushes the stored -// configuration to a network element. -// TODO: find a better place for this function. -func EnsureIntendedConfigurationIsAppliedOnNetworkElement(mne NetworkElement) error { - model, err := mne.GetModelAsFilteredCopy() - if err != nil { - return err - } - - req := &gpb.SetRequest{} - path, err := ygot.StringToStructuredPath("/") - if err != nil { - return err - } - - req.Update = []*gpb.Update{{ - Path: path, - Val: &gpb.TypedValue{ - Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(model)}, - }, - }} - - response, err := mne.Transport().CustomSet(context.Background(), req) - if err != nil { - log.Errorf("Failed to apply model of network element err=%+v, response=%+v", err, response) - return err - } - - return nil -} diff --git a/controller/interfaces/networkelement/networkElementService.go b/controller/interfaces/networkelement/networkElementService.go deleted file mode 100644 index 8e1b149ba92349b207031533d44c4e34948966a0..0000000000000000000000000000000000000000 --- a/controller/interfaces/networkelement/networkElementService.go +++ /dev/null @@ -1,12 +0,0 @@ -package networkelement - -// // Service describes an interface for network element service implementations. -// type Service interface { -// Add(NetworkElement) error -// Update(NetworkElement) error -// UpdateModel(uuid.UUID, string) error -// Delete(NetworkElement) error -// Get(model.Query) (NetworkElement, error) -// GetAll() ([]NetworkElement, error) -// GetAllAsLoaded() ([]LoadedNetworkElement, error) -// } diff --git a/controller/mocks/PndStore.go b/controller/mocks/PndStore.go index 657dff27f886e3574faf6ab337612636f5ec89cb..ec35a9c7845db64a72d79187898b1afdb4229755 100644 --- a/controller/mocks/PndStore.go +++ b/controller/mocks/PndStore.go @@ -32,7 +32,7 @@ func (_m *PndStore) Add(_a0 networkdomain.NetworkDomain) error { } // AddPendingChannel provides a mock function with given fields: id, ch -func (_m *PndStore) AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) { +func (_m *PndStore) AddPendingChannel(id uuid.UUID, ch chan model.Details) { _m.Called(id, ch) } @@ -101,7 +101,7 @@ func (_m *PndStore) GetAll() ([]networkdomain.LoadedPnd, error) { } // PendingChannels provides a mock function with given fields: id, parseErrors -func (_m *PndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) { +func (_m *PndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) { _va := make([]interface{}, len(parseErrors)) for _i := range parseErrors { _va[_i] = parseErrors[_i] @@ -111,16 +111,16 @@ func (_m *PndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan ne _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 chan networkelement.Details + var r0 chan model.Details var r1 error - if rf, ok := ret.Get(0).(func(uuid.UUID, ...error) (chan networkelement.Details, error)); ok { + if rf, ok := ret.Get(0).(func(uuid.UUID, ...error) (chan model.Details, error)); ok { return rf(id, parseErrors...) } - if rf, ok := ret.Get(0).(func(uuid.UUID, ...error) chan networkelement.Details); ok { + if rf, ok := ret.Get(0).(func(uuid.UUID, ...error) chan model.Details); ok { r0 = rf(id, parseErrors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(chan networkelement.Details) + r0 = ret.Get(0).(chan model.Details) } } diff --git a/controller/northbound/server/csbi.go b/controller/northbound/server/csbi.go index 8fe870d9519d3d44ea6b5e6c0f9c521688a5bc77..1b5b95301047752d398697e21cd9ff9042d0bbfb 100644 --- a/controller/northbound/server/csbi.go +++ b/controller/northbound/server/csbi.go @@ -11,8 +11,8 @@ import ( log "github.com/sirupsen/logrus" cpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/metrics" + "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" "code.fbi.h-da.de/danet/gosdn/controller/store" "google.golang.org/grpc/codes" @@ -59,7 +59,7 @@ func (s CsbiServer) Hello(ctx context.Context, syn *cpb.Syn) (*cpb.Ack, error) { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } - ch <- networkelement.Details{ + ch <- model.Details{ ID: syn.Id, Address: net.JoinHostPort(csbiAddress, syn.Address), } diff --git a/controller/northbound/server/nbi.go b/controller/northbound/server/nbi.go index f0e09bd7beba7dd5d6eeb2cb899aa12dee1468d0..6b4c95af7fb63886736c85d1219e3eb3232b5fbb 100644 --- a/controller/northbound/server/nbi.go +++ b/controller/northbound/server/nbi.go @@ -4,8 +4,8 @@ import ( cpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi" rpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-registry" "code.fbi.h-da.de/danet/gosdn/controller/app" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" rbacInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" + "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" "code.fbi.h-da.de/danet/gosdn/controller/rbac" "code.fbi.h-da.de/danet/gosdn/controller/store" @@ -56,7 +56,7 @@ func NewNBI( pluginService ports.PluginService, pluginRegistryClient rpb.PluginRegistryServiceClient, csbiClient cpb.CsbiServiceClient, - pndCallbackFn func(uuid.UUID, chan networkelement.Details), + pndCallbackFn func(uuid.UUID, chan model.Details), ) *NorthboundInterface { protoValidator, err := protovalidate.New() if err != nil { diff --git a/controller/northbound/server/pnd.go b/controller/northbound/server/pnd.go index 5f1ebd2cba7e9f73287fbeb63f66f499db0fb19d..2d0d6ec8dfcb8a7f14385cc1d9852318b89ae8c2 100644 --- a/controller/northbound/server/pnd.go +++ b/controller/northbound/server/pnd.go @@ -6,7 +6,6 @@ import ( cpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi" ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/metrics" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" @@ -23,7 +22,7 @@ type PndServer struct { pndService ports.PndService pluginService ports.PluginService csbiClient cpb.CsbiServiceClient - pndCallbackFn func(uuid.UUID, chan networkelement.Details) + pndCallbackFn func(uuid.UUID, chan model.Details) protoValidator *protovalidate.Validator } @@ -32,7 +31,7 @@ func NewPndServer( pndService ports.PndService, pluginService ports.PluginService, pndCallbackFn func(uuid.UUID, - chan networkelement.Details), + chan model.Details), csbiClient cpb.CsbiServiceClient, protoValidator *protovalidate.Validator, ) *PndServer { diff --git a/controller/northbound/server/pnd_test.go b/controller/northbound/server/pnd_test.go index dda4256fff3fa68806605957245c7f07f80070b6..662ed4810d26699b978bda7121c9ea41a6a4f48b 100644 --- a/controller/northbound/server/pnd_test.go +++ b/controller/northbound/server/pnd_test.go @@ -14,7 +14,6 @@ import ( rpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-registry" ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/mocks" "code.fbi.h-da.de/danet/gosdn/controller/nucleus" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" @@ -101,7 +100,7 @@ func getTestPndServer(t *testing.T) *PndServer { c := NewPndServer( pndService, nucleus.NewPluginService(pluginStore, eventService, model.NewPluginThroughReattachConfig, regsitryClient), - func(u uuid.UUID, c chan networkelement.Details) {}, + func(u uuid.UUID, c chan model.Details) {}, cpb.NewCsbiServiceClient(&grpc.ClientConn{}), protoValidator, ) diff --git a/controller/nucleus/domain/model/networkElement.go b/controller/nucleus/domain/model/networkElement.go index ec4164815d43f029dac2b15e4718b1fb3e81fd1b..9725179dca935df1599e8a82a8e5b4a48cfeedaf 100644 --- a/controller/nucleus/domain/model/networkElement.go +++ b/controller/nucleus/domain/model/networkElement.go @@ -60,6 +60,13 @@ type LoadedNetworkElement struct { PndID string `json:"pnd_id" bson:"pnd_id"` } +// Details contains details of a network element used by the cSBI mechanism. +type Details struct { + ID string + Address string + TransportOption *tpb.TransportOption +} + // NewNetworkElement creates a network element. func NewNetworkElement( name string, diff --git a/controller/nucleus/domain/model/principalNetworkDomain.go b/controller/nucleus/domain/model/principalNetworkDomain.go index 27c501f3c42efe3f49330c5a9bd99734e6ad090b..e5e3f53167720c85089654ccbc3c05eaa220496a 100644 --- a/controller/nucleus/domain/model/principalNetworkDomain.go +++ b/controller/nucleus/domain/model/principalNetworkDomain.go @@ -42,7 +42,7 @@ type pndImplementation struct { Id uuid.UUID `json:"id,omitempty"` // csbiClient cpb.CsbiServiceClient - // callback func(uuid.UUID, chan networkelement.Details) + // callback func(uuid.UUID, chan model.Details) } func (pnd *pndImplementation) ID() uuid.UUID { @@ -132,7 +132,7 @@ func handleRollbackError(id uuid.UUID, err error) { // //if err != nil { // // return uuid.Nil, err // //} -// //ch := make(chan networkelement.Details, 1) +// //ch := make(chan model.Details, 1) // //pnd.callback(id, ch) // //defer pnd.callback(id, nil) // //defer close(ch) @@ -203,7 +203,7 @@ func handleRollbackError(id uuid.UUID, err error) { // // return uuid.Nil, err // // } // // mne.(*CsbiNetworkElement).UUID = id -// // ch <- networkelement.Details{TransportOption: opt} +// // ch <- model.Details{TransportOption: opt} // // if err := pnd.networkElementService.Add(mne); err != nil { // // return uuid.Nil, err // // } diff --git a/controller/nucleus/domain/ports/service.go b/controller/nucleus/domain/ports/service.go index e89d9cf154ad64a1dcbbe8fb4e60f20baef5b80e..b059e4a0cd3133718987985c7a1039b0b49fa473 100644 --- a/controller/nucleus/domain/ports/service.go +++ b/controller/nucleus/domain/ports/service.go @@ -33,12 +33,11 @@ type PndService interface { Get(model.Query) (model.NetworkDomain, error) GetAll() ([]model.NetworkDomain, error) // Note: Implement these in case we want to use cSBI again. - // PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) - // AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) + // PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) + // AddPendingChannel(id uuid.UUID, ch chan model.Details) // RemovePendingChannel(id uuid.UUID) } - type EventService interface { PublishEvent(topic string, event event.Event) error CloseConnection() diff --git a/controller/nucleus/domain/ports/store.go b/controller/nucleus/domain/ports/store.go index f88c2a1ad136a0fe3918139ea83aec9a73a5632c..d220dd8a960c7f57790d6da3f7e68a9b8d13318d 100644 --- a/controller/nucleus/domain/ports/store.go +++ b/controller/nucleus/domain/ports/store.go @@ -1,7 +1,6 @@ package ports import ( - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "github.com/google/uuid" ) @@ -30,7 +29,7 @@ type PndStore interface { Delete(model.NetworkDomain) error Get(model.Query) (model.LoadedPnd, error) GetAll() ([]model.LoadedPnd, error) - PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) - AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) + PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) + AddPendingChannel(id uuid.UUID, ch chan model.Details) RemovePendingChannel(id uuid.UUID) } diff --git a/controller/nucleus/pkg/persistence/filesystem/pndFilesystemStore.go b/controller/nucleus/pkg/persistence/filesystem/pndFilesystemStore.go index 634be0fb38d4990846a141223dada27d09a10bb8..4cc00cd2d14c88f4b298a15175feeb1dc857a144 100644 --- a/controller/nucleus/pkg/persistence/filesystem/pndFilesystemStore.go +++ b/controller/nucleus/pkg/persistence/filesystem/pndFilesystemStore.go @@ -6,7 +6,6 @@ import ( "sync" "code.fbi.h-da.de/danet/gosdn/controller/customerrs" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" "code.fbi.h-da.de/danet/gosdn/controller/store" @@ -16,7 +15,7 @@ import ( // FilesystemPndStore provides a filesystem implementation for a pnd store. type FilesystemPndStore struct { - pendingChannels map[uuid.UUID]chan networkelement.Details + pendingChannels map[uuid.UUID]chan model.Details pluginService ports.PluginService // csbiClient cpb.CsbiServiceClient pathToPndFile string @@ -30,7 +29,7 @@ func NewFilesystemPndStore(pluginService ports.PluginService) ports.PndStore { } return &FilesystemPndStore{ - pendingChannels: make(map[uuid.UUID]chan networkelement.Details), + pendingChannels: make(map[uuid.UUID]chan model.Details), pathToPndFile: store.GetCompletePathToFileStore(store.PndFilename), fileMutex: sync.Mutex{}, pluginService: pluginService, @@ -173,7 +172,7 @@ func (t *FilesystemPndStore) GetAll() ([]model.LoadedPnd, error) { // PendingChannels holds channels used communicate with pending // cSBI deployments. -func (t *FilesystemPndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) { +func (t *FilesystemPndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) { ch, ok := t.pendingChannels[id] if !ok { return nil, &customerrs.CouldNotFindError{ID: id} @@ -182,7 +181,7 @@ func (t *FilesystemPndStore) PendingChannels(id uuid.UUID, parseErrors ...error) } // AddPendingChannel adds a pending channel to the map. -func (t *FilesystemPndStore) AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) { +func (t *FilesystemPndStore) AddPendingChannel(id uuid.UUID, ch chan model.Details) { t.pendingChannels[id] = ch } @@ -191,7 +190,7 @@ func (t *FilesystemPndStore) RemovePendingChannel(id uuid.UUID) { delete(t.pendingChannels, id) } -// func (t *FilesystemPndStore) callback(id uuid.UUID, ch chan networkelement.Details) { +// func (t *FilesystemPndStore) callback(id uuid.UUID, ch chan model.Details) { // if ch != nil { // t.AddPendingChannel(id, ch) // log.Infof("pending channel %v added", id) diff --git a/controller/nucleus/pkg/persistence/memory/memoryPndStore.go b/controller/nucleus/pkg/persistence/memory/memoryPndStore.go index 5d69f3db5f5a5c081aa20e77362017d4baf9a000..6673d49f1545ea760ac28c9cda1d7f908669c680 100644 --- a/controller/nucleus/pkg/persistence/memory/memoryPndStore.go +++ b/controller/nucleus/pkg/persistence/memory/memoryPndStore.go @@ -4,7 +4,6 @@ import ( "encoding/json" "code.fbi.h-da.de/danet/gosdn/controller/customerrs" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" "github.com/google/uuid" @@ -13,14 +12,14 @@ import ( // MemoryPndStore provides a in-memory implementation for a pnd store. type MemoryPndStore struct { Store map[uuid.UUID]model.LoadedPnd - pendingChannels map[uuid.UUID]chan networkelement.Details + pendingChannels map[uuid.UUID]chan model.Details } // NewMemoryPndStore returns a in-memory implementation for a pnd store. func NewMemoryPndStore() ports.PndStore { return &MemoryPndStore{ Store: make(map[uuid.UUID]model.LoadedPnd), - pendingChannels: make(map[uuid.UUID]chan networkelement.Details), + pendingChannels: make(map[uuid.UUID]chan model.Details), } } @@ -79,7 +78,7 @@ func (t *MemoryPndStore) GetAll() ([]model.LoadedPnd, error) { // PendingChannels holds channels used communicate with pending // cSBI deployments. -func (t *MemoryPndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) { +func (t *MemoryPndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) { ch, ok := t.pendingChannels[id] if !ok { return nil, &customerrs.CouldNotFindError{ID: id} @@ -88,7 +87,7 @@ func (t *MemoryPndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (ch } // AddPendingChannel adds a pending channel to the map. -func (t *MemoryPndStore) AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) { +func (t *MemoryPndStore) AddPendingChannel(id uuid.UUID, ch chan model.Details) { t.pendingChannels[id] = ch } diff --git a/controller/nucleus/pkg/persistence/mongodb/databasePndStore.go b/controller/nucleus/pkg/persistence/mongodb/databasePndStore.go index e1e8cbffc710204d86ee4b4fdb1a4c8367c40552..0520398d38219601a4e30f5f0048580d8a141ed4 100644 --- a/controller/nucleus/pkg/persistence/mongodb/databasePndStore.go +++ b/controller/nucleus/pkg/persistence/mongodb/databasePndStore.go @@ -3,7 +3,6 @@ package mongodb import ( "fmt" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" @@ -17,7 +16,7 @@ import ( // DatabasePndStore is used to store PrincipalNetworkDomains. type DatabasePndStore struct { PndStoreName string - InternalPendingChannels map[uuid.UUID]chan networkelement.Details + InternalPendingChannels map[uuid.UUID]chan model.Details PluginService ports.PluginService } @@ -211,7 +210,7 @@ func (s *DatabasePndStore) Delete(pndToDelete model.NetworkDomain) (err error) { // PendingChannels holds channels used communicate with pending // cSBI deployments. -func (s *DatabasePndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan networkelement.Details, error) { +func (s *DatabasePndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan model.Details, error) { ch, ok := s.InternalPendingChannels[id] if !ok { return nil, &customerrs.CouldNotFindError{ID: id} @@ -220,7 +219,7 @@ func (s *DatabasePndStore) PendingChannels(id uuid.UUID, parseErrors ...error) ( } // AddPendingChannel adds a pending channel to the map. -func (s *DatabasePndStore) AddPendingChannel(id uuid.UUID, ch chan networkelement.Details) { +func (s *DatabasePndStore) AddPendingChannel(id uuid.UUID, ch chan model.Details) { s.InternalPendingChannels[id] = ch } @@ -229,7 +228,7 @@ func (s *DatabasePndStore) RemovePendingChannel(id uuid.UUID) { delete(s.InternalPendingChannels, id) } -// func (s *DatabasePndStore) callback(id uuid.UUID, ch chan networkelement.Details) { +// func (s *DatabasePndStore) callback(id uuid.UUID, ch chan model.Details) { // if ch != nil { // s.AddPendingChannel(id, ch) // log.Infof("pending channel %v added", id) diff --git a/controller/nucleus/pkg/persistence/pndStore.go b/controller/nucleus/pkg/persistence/pndStore.go index e690c626aa9ba04f0f2b682501b830cb19eadd34..12351f433f545af4c62005f28c5bd15d55fc80be 100644 --- a/controller/nucleus/pkg/persistence/pndStore.go +++ b/controller/nucleus/pkg/persistence/pndStore.go @@ -1,7 +1,7 @@ package persistence import ( - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" + "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/ports" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/pkg/persistence/filesystem" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/pkg/persistence/mongodb" @@ -30,7 +30,7 @@ func NewPndStore(pluginService ports.PluginService) ports.PndStore { switch storeMode { case store.Database: return &mongodb.DatabasePndStore{ - InternalPendingChannels: make(map[uuid.UUID]chan networkelement.Details), + InternalPendingChannels: make(map[uuid.UUID]chan model.Details), PndStoreName: "pnd-store.json", PluginService: pluginService, } diff --git a/controller/topology/ports/portStore.go b/controller/topology/ports/portStore.go index 5990f300c086a0f706bff29a49c07c94e81976c2..6af51d87af5b8d14215d506b0964f48c6b449809 100644 --- a/controller/topology/ports/portStore.go +++ b/controller/topology/ports/portStore.go @@ -4,7 +4,6 @@ import ( "fmt" "code.fbi.h-da.de/danet/gosdn/controller/customerrs" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/pkg/persistence/mongodb" @@ -164,7 +163,7 @@ func (s *DatabasePortStore) Add(port Port) (err error) { // Update updates a existing port. func (s *DatabasePortStore) Update(port Port) (err error) { - var updatedLoadedNetworkElement networkelement.LoadedNetworkElement + var updatedLoadedNetworkElement model.LoadedNetworkElement client, ctx, cancel := mongodb.GetMongoConnection() defer cancel()