From a0a3477ea685b23d5f68e9e1a3ca51947ee772cb Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@stud.h-da.de> Date: Fri, 23 Dec 2022 14:38:49 +0100 Subject: [PATCH] Change pnd.Request to use UpdateModel method --- controller/interfaces/networkdomain/pnd.go | 1 - controller/nucleus/principalNetworkDomain.go | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/controller/interfaces/networkdomain/pnd.go b/controller/interfaces/networkdomain/pnd.go index 8aae436ef..20abc1687 100644 --- a/controller/interfaces/networkdomain/pnd.go +++ b/controller/interfaces/networkdomain/pnd.go @@ -37,5 +37,4 @@ type NetworkDomain interface { Commit(uuid.UUID) error Confirm(uuid.UUID) error SubscribePath(uuid.UUID, *ppb.SubscriptionList) error - UpdateNetworkElementAfterSubscribeResponse(networkelement.NetworkElement) error } diff --git a/controller/nucleus/principalNetworkDomain.go b/controller/nucleus/principalNetworkDomain.go index 6bdc01daa..b9ba3472b 100644 --- a/controller/nucleus/principalNetworkDomain.go +++ b/controller/nucleus/principalNetworkDomain.go @@ -310,6 +310,8 @@ func (pnd *pndImplementation) UpdateNetworkElement(networkElementID uuid.UUID, m return err } + //TODO: check if it could be worth to provide the method with a network + //element instead of an ID. err = pnd.ensureIntendedConfigurationIsAppliedOnNetworkElement(networkElementID) if err != nil { return err @@ -405,6 +407,8 @@ func (pnd *pndImplementation) MarshalNetworkElement(identifier string) (string, } // Request sends a get request to a specific network element. +// TODO: this method needs some heavy refactoring, especially in regards to the +// UpdateModel call func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) (proto.Message, error) { mne, err := pnd.networkElementService.Get(store.Query{ ID: uuid, @@ -433,8 +437,13 @@ func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) (proto.Messag return nil, err } + modelAsString, err := mne.GetModelAsString() + if err != nil { + return nil, err + } + // TODO(path): We probably have to remove this when we address path request handling. - err = pnd.networkElementService.Update(mne) + err = pnd.networkElementService.UpdateModel(uuid, modelAsString) if err != nil { return nil, err } @@ -950,12 +959,3 @@ func (pnd *pndImplementation) MarshalBSON() ([]byte, error) { Description: pnd.Description, }) } - -// UpdateMNEAfterSubscribeResponse takes a network element and forwards it to the network element service to handle the update. -func (pnd *pndImplementation) UpdateNetworkElementAfterSubscribeResponse(mne networkelement.NetworkElement) error { - if err := pnd.networkElementService.Update(mne); err != nil { - return err - } - - return nil -} -- GitLab