From 65630a13e402a647543ff7312bd44e481e152629 Mon Sep 17 00:00:00 2001 From: Fabian Seidl <fabian.seidl@h-da.de> Date: Wed, 13 Mar 2024 10:44:37 +0100 Subject: [PATCH] add getAllMne and getAllPnd --- controller/api/managedNetworkElement.go | 32 +++++++++++++++++++++++++ controller/api/pnd.go | 15 ++++++++++++ 2 files changed, 47 insertions(+) diff --git a/controller/api/managedNetworkElement.go b/controller/api/managedNetworkElement.go index b07ad58e0..f9b5eb57a 100644 --- a/controller/api/managedNetworkElement.go +++ b/controller/api/managedNetworkElement.go @@ -50,6 +50,23 @@ func AddNetworkElement(ctx context.Context, addr, mneName, mneUUID string, opt * return client.AddList(ctx, req) } +// AddNetworkElementList adds all the network elements to the controller. The name of each network element is optional. +// If no name is provided a name will be generated upon network element creation. +func AddNetworkElementList(ctx context.Context, addr, pid string, mneList []*mnepb.SetMne) (*mnepb.AddListResponse, error) { + client, err := nbi.NetworkElementClient(addr, dialOptions...) + if err != nil { + return nil, err + } + + req := &mnepb.AddListRequest{ + Timestamp: time.Now().UnixNano(), + Mne: mneList, + Pid: pid, + } + + return client.AddList(ctx, req) +} + // GetNetworkElement requests one network element belonging to a given // PrincipalNetworkDomain from the controller. If no network element identifier // is provided, an error is thrown. @@ -72,6 +89,21 @@ func GetNetworkElement(ctx context.Context, addr, pid string, mneid string) (*mn return client.Get(ctx, req) } +// GetNetworkElements requests all available network elements related to one PND. +func GetNetworkElements(ctx context.Context, addr, pid string) (*mnepb.GetAllResponse, error) { + client, err := nbi.NetworkElementClient(addr, dialOptions...) + if err != nil { + return nil, err + } + + req := &mnepb.GetAllRequest{ + Timestamp: time.Now().UnixNano(), + Pid: pid, + } + + return client.GetAll(ctx, req) +} + // GetPluginSchemaTree gets the schema tree for a plugin. func GetPluginSchemaTree(ctx context.Context, addr string, pluginID uuid.UUID) (map[string]*yang.Entry, error) { pluginClient, err := nbi.PluginClient(addr, dialOptions...) diff --git a/controller/api/pnd.go b/controller/api/pnd.go index d547807ba..b8ab4d66b 100644 --- a/controller/api/pnd.go +++ b/controller/api/pnd.go @@ -30,6 +30,21 @@ func CreatePnd(ctx context.Context, addr, name, description string) (*ppb.Create return pndClient.CreatePndList(ctx, req) } +// CreatePndList uses the provided creation properties to add all the PNDs to the controller. +func CreatePndList(ctx context.Context, addr string, pnds []*ppb.PndCreateProperties) (*ppb.CreatePndListResponse, error) { + pndClient, err := nbi.PndClient(addr, dialOptions...) + if err != nil { + return nil, err + } + + req := &ppb.CreatePndListRequest{ + Timestamp: time.Now().UnixNano(), + Pnd: pnds, + } + + return pndClient.CreatePndList(ctx, req) +} + // GetPnd requests one PrincipalNetworkDomain from the // controller. func GetPnd(ctx context.Context, addr string, args string) (*ppb.GetPndResponse, error) { -- GitLab