diff --git a/controller/interfaces/networkelement/networkElement.go b/controller/interfaces/networkelement/networkElement.go index 18b5b6b4b248224e7f9b94708928a3d109efada1..f51d0e8a483eccef85ac89a0759b92283e67da79 100644 --- a/controller/interfaces/networkelement/networkElement.go +++ b/controller/interfaces/networkelement/networkElement.go @@ -25,6 +25,7 @@ type NetworkElement interface { GetModelAsString() (string, error) TransportAddress() string GetMetadata() conflict.Metadata + PndID() uuid.UUID } // Details contains details of a network element used by the cSBI mechanism. diff --git a/controller/nucleus/networkElement.go b/controller/nucleus/networkElement.go index 848260ae6fa6b3b6e67abd3480514106b8c85d0c..215714b78436cccbd641f3fe67c1a7ad15a99739 100644 --- a/controller/nucleus/networkElement.go +++ b/controller/nucleus/networkElement.go @@ -66,6 +66,7 @@ func NewNetworkElement( name: name, transportOptions: opt, Metadata: metadata, + pndID: pndID, }, }, nil } @@ -77,7 +78,7 @@ func NewNetworkElement( transport: t, name: name, transportOptions: opt, - PndID: pndID, + pndID: pndID, Metadata: metadata, }, nil } @@ -104,7 +105,7 @@ type CommonNetworkElement struct { Metadata conflict.Metadata // ID of the PND this network element is associated with. - PndID uuid.UUID + pndID uuid.UUID } // ID returns the UUID of the Network Element. @@ -176,6 +177,11 @@ func (n *CommonNetworkElement) GetMetadata() conflict.Metadata { return n.Metadata } +// PndID returns the ID of the associated PND. +func (n *CommonNetworkElement) PndID() uuid.UUID { + return n.pndID +} + // CsbiNetworkElement is used for the cSBI functionality. type CsbiNetworkElement struct { CommonNetworkElement @@ -216,6 +222,11 @@ func (n *CsbiNetworkElement) GetMetadata() conflict.Metadata { return n.Metadata } +// PndID returns the ID of the associated PND. +func (n *CsbiNetworkElement) PndID() uuid.UUID { + return n.pndID +} + // ProcessResponse processes a response for the Network Element. func (n *CsbiNetworkElement) ProcessResponse(resp proto.Message) error { // TODO: callback to send response to caller @@ -284,10 +295,10 @@ func (n *CommonNetworkElement) MarshalJSON() ([]byte, error) { var pndUUID uuid.UUID - if n.PndID == uuid.Nil { + if n.pndID == uuid.Nil { pndUUID = uuid.UUID{} } else { - pndUUID = n.PndID + pndUUID = n.pndID } modelAsString, err := ygot.EmitJSON(n.Model, n.getYgotEmitJSONConfig()) @@ -371,7 +382,7 @@ func (n *CommonNetworkElement) MarshalBSON() ([]byte, error) { TransportOptionType: transportOptionType, SBI: n.sbi.ID().String(), Model: modelAsString, - PndID: n.PndID.String(), + PndID: n.pndID.String(), }) } diff --git a/controller/nucleus/networkElementService_test.go b/controller/nucleus/networkElementService_test.go index 771b33f5940a0f26b912afb1a475a59416fafcde..49cc7e705b4efb0e82048dc12e2f0e67ec00bedb 100644 --- a/controller/nucleus/networkElementService_test.go +++ b/controller/nucleus/networkElementService_test.go @@ -19,7 +19,7 @@ func getMockNetworkElement(mneID uuid.UUID, sbi southbound.SouthboundInterface) Model: sbi.Schema().Root, sbi: sbi, transport: &mocks.Transport{}, - PndID: uuid.New(), + pndID: uuid.New(), } } diff --git a/controller/nucleus/networkElementWatcher.go b/controller/nucleus/networkElementWatcher.go index 19d12969acdef96b620b7a7b69d6f0ddcfe76c20..eaed87fcbda6a5e3967cfc69586173be0aba94a2 100644 --- a/controller/nucleus/networkElementWatcher.go +++ b/controller/nucleus/networkElementWatcher.go @@ -91,8 +91,7 @@ func (n *NetworkElementWatcher) callSubscribe(stopContext context.Context, mne n // SubscriptionInformation contains pnd ID, network element ID and name to be used in the internal subscribe to check // from which network element a response was sent if err := mne.Transport().ControlPlaneSubscribe(gNMIOptionsCtx, n.handleSubscribeResponse, &transport.SubscriptionInformation{ - //TODO(PND): add pndID here, when adding pndID as reference to MNE! - //PndID: pndID, + PndID: mne.PndID().String(), NetworkElementID: mne.ID().String(), NetworkElementName: mne.Name(), StopContext: stopContext,