Skip to content
Snippets Groups Projects
Commit e17e6adc authored by Fabian Seidl's avatar Fabian Seidl
Browse files

add mne update to API, needs some considerations after disccussion

parent 65630a13
No related branches found
No related tags found
1 merge request!790Resolve "Update gRPC abstraction API with missing calls and refactoring"
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"io" "io"
"time" "time"
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/conflict"
mnepb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement" mnepb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement"
pipb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-internal" pipb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-internal"
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound" spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
...@@ -250,3 +251,29 @@ func DeleteNetworkElement(ctx context.Context, addr, pid, mneid string) (*mnepb. ...@@ -250,3 +251,29 @@ func DeleteNetworkElement(ctx context.Context, addr, pid, mneid string) (*mnepb.
return client.Delete(ctx, req) return client.Delete(ctx, req)
} }
// UpdateNetworkElement changes the metadata of the network element which is stored in the controller storage.
// Correct resource version needs to be provided to allow a change of the object in the storage.
func UpdateNetworkElement(ctx context.Context, addr, mneid, updatedName, updatedTransportAddress, updatedPid string, resourceVersion *conflict.Metadata) (*mnepb.UpdateNetworkElementResponse, error) {
client, err := nbi.NetworkElementClient(addr, dialOptions...)
if err != nil {
return nil, err
}
// Note: Consider changing what to update. Some values are quite iffy to change.
req := &mnepb.UpdateNetworkElementRequest{
Timestamp: time.Now().UnixNano(),
NetworkElement: &mnepb.ManagedNetworkElement{
Id: mneid,
Name: updatedName,
TransportAddress: updatedTransportAddress,
TransportOption: &tpb.TransportOption{
Address: updatedTransportAddress,
},
Metadata: resourceVersion,
AssociatedPnd: updatedPid,
},
}
return client.Update(ctx, req)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment