Skip to content

Commit

Permalink
changes for create slice test
Browse files Browse the repository at this point in the history
  • Loading branch information
mthgcosta committed Apr 22, 2024
1 parent dda4201 commit cc983bb
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 44 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/onosproject/onos-e2-sm/servicemodels/e2sm_rsm v0.8.43
github.com/onosproject/onos-lib-go v0.10.24
github.com/onosproject/onos-ric-sdk-go v0.8.12
github.com/onosproject/onos-rsm v0.2.5
google.golang.org/grpc v1.62.0
google.golang.org/protobuf v1.33.0
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ github.com/onosproject/onos-lib-go v0.10.24 h1:CX/6a0U2ZAhHeYiZnmO+kOIoLv8V+aim0
github.com/onosproject/onos-lib-go v0.10.24/go.mod h1:xprZr/FtQ8YhDxA3WI7AqMUzK97QJvrsrrmY5KiX46I=
github.com/onosproject/onos-ric-sdk-go v0.8.12 h1:aT6gevAeJ58/mkxzY/LDceyfKsik3DwIstsrVqyMEuY=
github.com/onosproject/onos-ric-sdk-go v0.8.12/go.mod h1:/UMaxqFFzwxG7iBNquZKKM7o5mCNMppAoIkvjCQh0mE=
github.com/onosproject/onos-rsm v0.2.5 h1:21LSicrnpu4cP8bSJ7KUcY09wHdb+6JwGcwvjK0u2eo=
github.com/onosproject/onos-rsm v0.2.5/go.mod h1:m6FlTFuRBy5pDmDhTZ40rY55JpUEjzM9n7Uf/NUMong=
github.com/openconfig/gnmi v0.9.1 h1:hVOdLTaRjdy68oCGJbkf2vrmnUoQ5xbINqBOAMix4xM=
github.com/openconfig/gnmi v0.9.1/go.mod h1:Y9os75GmSkhHw2wX8sMsxfI7qRGAEcDh8NTa5a8vj6E=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down
59 changes: 53 additions & 6 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
appConfig "github.com/gercom-ufpa/iqos-xapp/pkg/config"
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/rnib"
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/uenib"
nbi "github.com/gercom-ufpa/iqos-xapp/pkg/northbound"
"github.com/gercom-ufpa/iqos-xapp/pkg/slicing"
"github.com/gercom-ufpa/iqos-xapp/pkg/southbound/e2"
"github.com/onosproject/onos-lib-go/pkg/logging"
"github.com/onosproject/onos-lib-go/pkg/northbound"
)

// log initialize
Expand Down Expand Up @@ -45,6 +48,8 @@ func NewManager(config Config) *Manager {
log.Warn(err)
}

rsmReqCh := make(chan *nbi.RsmMsg)

// Control messages used by the e2 and slicemgr packages
slicingCtrlMsgs := e2.SlicingCtrlMsgs{
CtrlReqChsSliceCreate: make(map[string]chan *e2.CtrlMsg),
Expand All @@ -53,6 +58,13 @@ func NewManager(config Config) *Manager {
CtrlReqChsUeAssociate: make(map[string]chan *e2.CtrlMsg),
}

slicingManager := slicing.NewManager(
slicing.WithRnibClient(rnibClient),
slicing.WithUenibClient(uenibClient),
slicing.WithCtrlReqChs(slicingCtrlMsgs.CtrlReqChsSliceCreate, slicingCtrlMsgs.CtrlReqChsSliceUpdate, slicingCtrlMsgs.CtrlReqChsSliceDelete, slicingCtrlMsgs.CtrlReqChsUeAssociate),
slicing.WithNbiReqChs(rsmReqCh),
slicing.WithAckTimer(config.AckTimer),
)
// Creates App Managers

// A1 Manager (or client?? - TODO)
Expand Down Expand Up @@ -87,11 +99,13 @@ func NewManager(config Config) *Manager {

// App Manager
manager := &Manager{
appConfig: appCfg,
config: config,
E2Manager: e2Manager,
UenibClient: uenibClient,
RnibClient: rnibClient,
appConfig: appCfg,
config: config,
E2Manager: e2Manager,
SlicingManager: slicingManager,
UenibClient: uenibClient,
RnibClient: rnibClient,
RsmReqCh: rsmReqCh,
}

return manager
Expand All @@ -106,14 +120,23 @@ func (mgr *Manager) Run() {

// starts xAPP processes
func (mgr *Manager) start() error {

// starts Northbound server
err := mgr.startNorthboundServer()
if err != nil {
log.Warn(err)
return err
}

// starts E2 subscriptions
err := mgr.E2Manager.Start() // TODO
err = mgr.E2Manager.Start() // TODO
if err != nil {
log.Warnf("Fail to start E2 Manager: %v", err)
return err
}

// starts Slice Module (TODO)
go mgr.SlicingManager.Run(context.Background())

return nil
}
Expand All @@ -123,3 +146,27 @@ func (m *Manager) Close() {
// TODO
// syscall.Kill(syscall.Getpid(), syscall.SIGINT)
}

func (mgr *Manager) startNorthboundServer() error {
s := northbound.NewServer(northbound.NewServerCfg(
mgr.config.CAPath,
mgr.config.KeyPath,
mgr.config.CertPath,
int16(mgr.config.GRPCPort),
true,
northbound.SecurityConfig{}))

s.AddService(nbi.NewService(mgr.RnibClient, mgr.UenibClient, mgr.RsmReqCh))

doneCh := make(chan error)
go func() {
err := s.Serve(func(started string) {
log.Info("Started NBI on ", started)
close(doneCh)
})
if err != nil {
doneCh <- err
}
}()
return <-doneCh
}
16 changes: 11 additions & 5 deletions pkg/manager/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
appConfig "github.com/gercom-ufpa/iqos-xapp/pkg/config"
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/rnib"
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/uenib"
nbi "github.com/gercom-ufpa/iqos-xapp/pkg/northbound"
"github.com/gercom-ufpa/iqos-xapp/pkg/slicing"
"github.com/gercom-ufpa/iqos-xapp/pkg/southbound/e2"
)

Expand All @@ -15,6 +17,7 @@ type Config struct {
CertPath string
E2tEndpoint string
E2tPort int
GRPCPort int
TopoEndpoint string
TopoPort int
UeNibEndpoint string
Expand All @@ -24,13 +27,16 @@ type Config struct {
KpmSMVersion string
RsmSMName string
RsmSMVersion string
AckTimer int
}

// Manager is an abstract struct for manager
type Manager struct {
appConfig appConfig.Config
config Config
E2Manager e2.Manager
UenibClient uenib.Client
RnibClient rnib.Client
appConfig appConfig.Config
config Config
E2Manager e2.Manager
UenibClient uenib.Client
RnibClient rnib.Client
SlicingManager slicing.Manager
RsmReqCh chan *nbi.RsmMsg
}
12 changes: 12 additions & 0 deletions pkg/nib/rnib/rnib.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ func (c *Client) GetRsmSliceItemAspects(ctx context.Context, nodeID topoapi.ID)
return rsmSliceList.GetRsmSliceList(), nil
}

func (t *Client) UpdateRsmSliceItemAspect(ctx context.Context, nodeID topoapi.ID, msg *topoapi.RSMSlicingItem) error {
err := t.DeleteRsmSliceItemAspect(ctx, nodeID, msg.GetID())
if err != nil {
return err
}
err = t.AddRsmSliceItemAspect(ctx, nodeID, msg)
if err != nil {
return err
}
return nil
}

// Gets RsmSliceItemList aspect on Node | return RsmSliceItemList aspect per slice
func (c *Client) GetRsmSliceListAspect(ctx context.Context, nodeID topoapi.ID) (*topoapi.RSMSliceItemList, error) {
// gets a topo object by ID
Expand Down
18 changes: 11 additions & 7 deletions pkg/northbound/rsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ package northbound

import (
"context"

"github.com/gercom-ufpa/iqos-xapp/pkg/nib/rnib"
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/uenib"
rsmapi "github.com/onosproject/onos-api/go/onos/rsm"
topoapi "github.com/onosproject/onos-api/go/onos/topo"
"github.com/onosproject/onos-lib-go/pkg/logging/service"
"github.com/onosproject/onos-rsm/pkg/nib/rnib"
"github.com/onosproject/onos-rsm/pkg/nib/uenib"
"google.golang.org/grpc"
)
//Creates a new service with the provided clients and the RSM messaging channel.
func NewService(rnibClient rnib.TopoClient, uenibClient uenib.Client, rsmReqCh chan *RsmMsg) service.Service {

// Creates a new service with the provided clients and the RSM messaging channel.
func NewService(rnibClient rnib.Client, uenibClient uenib.Client, rsmReqCh chan *RsmMsg) service.Service {
return &Service{
rnibClient: rnibClient,
uenibClient: uenibClient,
rsmReqCh: rsmReqCh,
}
}

// Register registers the service on the provided gRPC server.
func (s Service) Register(r *grpc.Server) {
server := &Server{
Expand All @@ -30,7 +33,8 @@ func (s Service) Register(r *grpc.Server) {
}
rsmapi.RegisterRsmServer(r, server)
}
//Creates a new slice using the given parameters.

// Creates a new slice using the given parameters.
func (s Server) CreateSlice(_ context.Context, request *rsmapi.CreateSliceRequest) (*rsmapi.CreateSliceResponse, error) {
// Create a confirmation channel.
ackCh := make(chan Ack)
Expand All @@ -44,7 +48,7 @@ func (s Server) CreateSlice(_ context.Context, request *rsmapi.CreateSliceReques
go func(msg *RsmMsg) {
s.rsmReqCh <- msg
}(msg)
// Wait for confirmation of the operation.
// Wait for confirmation of the operation.
ack := <-ackCh
// Returns the response.
return &rsmapi.CreateSliceResponse{
Expand Down Expand Up @@ -113,4 +117,4 @@ func (s Server) SetUeSliceAssociation(_ context.Context, request *rsmapi.SetUeSl
Cause: ack.Reason,
},
}, nil
}
}
8 changes: 4 additions & 4 deletions pkg/northbound/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package northbound

import (
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/rnib"
"github.com/gercom-ufpa/iqos-xapp/pkg/nib/uenib"
topoapi "github.com/onosproject/onos-api/go/onos/topo"
"github.com/onosproject/onos-rsm/pkg/nib/rnib"
"github.com/onosproject/onos-rsm/pkg/nib/uenib"
)

// Confirmation message for an operation, containing a boolean
Expand All @@ -29,14 +29,14 @@ type RsmMsg struct {
// This Service struct encapsulates the clients for rnib and uenib, as well as a channel
// for receiving RSM messages. It is intended to be used to provide RSM-related services.
type Service struct {
rnibClient rnib.TopoClient
rnibClient rnib.Client
uenibClient uenib.Client
rsmReqCh chan *RsmMsg
}

// Create a gRPC server to serve RPC requests
type Server struct {
rnibClient rnib.TopoClient
rnibClient rnib.Client
uenibClient uenib.Client
rsmReqCh chan *RsmMsg
}
24 changes: 12 additions & 12 deletions pkg/slicing/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"strconv"
"time"

"github.com/gercom-ufpa/iqos-xapp/pkg/northbound"
"github.com/gercom-ufpa/iqos-xapp/pkg/southbound/e2"
rsmapi "github.com/onosproject/onos-api/go/onos/rsm"
topoapi "github.com/onosproject/onos-api/go/onos/topo"
uenib_api "github.com/onosproject/onos-api/go/onos/uenib" // used by delete func
e2sm_rsm "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_rsm/v1/e2sm-rsm-ies"
e2sm_v2_ies "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_rsm/v1/e2sm-v2-ies"
"github.com/onosproject/onos-lib-go/pkg/logging"
"github.com/onosproject/onos-rsm/pkg/northbound" // TODO
"github.com/onosproject/onos-rsm/pkg/southbound/e2" // TODO
)

var log = logging.GetLogger("iqos-xapp", "slicemgr")
Expand Down Expand Up @@ -56,8 +56,8 @@ func (m *Manager) DispatchNbiMsg(ctx context.Context) {
err = m.handleNbiUpdateSliceRequest(ctx, msg.Message.(*rsmapi.UpdateSliceRequest), msg.NodeID)
case *rsmapi.DeleteSliceRequest:
err = m.handleNbiDeleteSliceRequest(ctx, msg.Message.(*rsmapi.DeleteSliceRequest), msg.NodeID)
//case *rsmapi.SetUeSliceAssociationRequest:
// err = m.handleNbiSetUeSliceAssociationRequest(ctx, msg.Message.(*rsmapi.SetUeSliceAssociationRequest), msg.NodeID)
case *rsmapi.SetUeSliceAssociationRequest:
err = m.handleNbiSetUeSliceAssociationRequest(ctx, msg.Message.(*rsmapi.SetUeSliceAssociationRequest), msg.NodeID)
default:
err = fmt.Errorf("unknown msg type: %v", msg)
}
Expand Down Expand Up @@ -240,7 +240,7 @@ func (m *Manager) handleNbiDeleteSliceRequest(ctx context.Context, req *rsmapi.D
return fmt.Errorf("failed to delete slice information to onos-topo although control message was sent: %v", err)
}

ues, err := m.uenibClient.GetUEs(ctx) // try get a list of UEs registered in UENIB
ues, err := m.uenibClient.GetRsmUEs(ctx) // try get a list of UEs registered in UENIB
if err != nil {
return fmt.Errorf("failed to get UEs in UENIB: %v", err) // error getting
}
Expand All @@ -255,7 +255,7 @@ func (m *Manager) handleNbiDeleteSliceRequest(ctx context.Context, req *rsmapi.D
}
}
if changed {
err = m.uenibClient.UpdateUE(ctx, ues[i]) // return a error if wasn't possible update UE's data
err = m.uenibClient.UpdateRsmUE(ctx, ues[i]) // return a error if wasn't possible update UE's data
if err != nil {
return fmt.Errorf("failed to update UENIB: %v", err)
}
Expand Down Expand Up @@ -372,7 +372,7 @@ func (m *Manager) handleNbiUpdateSliceRequest(ctx context.Context, req *rsmapi.U
return fmt.Errorf("failed to update slice information to onos-topo although control message was sent: %v", err)
}

ues, err := m.uenibClient.GetUEs(ctx) // try get a list of UEs registered in UENIB client
ues, err := m.uenibClient.GetRsmUEs(ctx) // try get a list of UEs registered in UENIB client
if err != nil {
return fmt.Errorf("failed to get UEs in UENIB: %v", err) // error getting
}
Expand All @@ -387,7 +387,7 @@ func (m *Manager) handleNbiUpdateSliceRequest(ctx context.Context, req *rsmapi.U
}
}
if changed {
err = m.uenibClient.UpdateUE(ctx, ues[i]) // return a error if wasn't possible update UE's data
err = m.uenibClient.UpdateRsmUE(ctx, ues[i]) // return a error if wasn't possible update UE's data
if err != nil {
return fmt.Errorf("failed to update UENIB: %v", err)
}
Expand Down Expand Up @@ -493,7 +493,7 @@ func (m *Manager) handleNbiSetUeSliceAssociationRequest(ctx context.Context, req
},
}

rsmUEInfo, err := m.uenibClient.GetUEWithPreferredID(ctx, string(cuNodeID), uenib_api.UeIdType_UE_ID_TYPE_DU_UE_F1_AP_ID, DuUeF1apID)
rsmUEInfo, err := m.uenibClient.GetRsmUEWithPreferredID(ctx, string(cuNodeID), uenib_api.UeIdType_UE_ID_TYPE_DU_UE_F1_AP_ID, DuUeF1apID)
if err != nil {
return fmt.Errorf("failed to get UENIB UE info (CuID %v DUID %v UEID %v): err: %v", cuNodeID, duNodeID, ueID, err)
}
Expand Down Expand Up @@ -622,7 +622,7 @@ func (m *Manager) handleNbiSetUeSliceAssociationRequest(ctx context.Context, req
}
}

err = m.uenibClient.UpdateUE(ctx, rsmUEInfo)
err = m.uenibClient.UpdateRsmUE(ctx, &rsmUEInfo)
if err != nil {
return fmt.Errorf("tried to update du e2node ID on uenib (because there was no du ID) but failed to update du id UENIB UE info (CuID %v DUID %v UEID %v uenib UE info %v): err: %v", cuNodeID, duNodeID, ueID, rsmUEInfo, err)
}
Expand Down Expand Up @@ -849,7 +849,7 @@ func (m *Manager) handleNbiSetUeSliceAssociationRequest(ctx context.Context, req

rsmUEInfo.SliceList = append(rsmUEInfo.SliceList, sliceInfo)
}
err = m.uenibClient.UpdateUE(ctx, rsmUEInfo)
err = m.uenibClient.UpdateRsmUE(ctx, &rsmUEInfo)
if err != nil {
return fmt.Errorf("Failed to update uenib: %v", err)
}
Expand Down Expand Up @@ -953,7 +953,7 @@ func (m *Manager) handleNbiSetUeSliceAssociationRequest(ctx context.Context, req

rsmUEInfo.SliceList = append(rsmUEInfo.SliceList, sliceInfo)

err = m.uenibClient.UpdateUE(ctx, rsmUEInfo)
err = m.uenibClient.UpdateRsmUE(ctx, &rsmUEInfo)
if err != nil {
return fmt.Errorf("Failed to update uenib: %v", err)
}
Expand Down
Loading

0 comments on commit cc983bb

Please sign in to comment.