[VOL-1503] Add a GetMembership API to the core
This API is used by the Affinity Router to query the Go Core
for its membership info, it any.
Change-Id: I46aac8579a0452b665175cbd379876a702cce102
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index 46382c2..0bbe5de 100644
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -206,12 +206,21 @@
func (handler *APIHandler) UpdateMembership(ctx context.Context, membership *voltha.Membership) (*empty.Empty, error) {
log.Debugw("UpdateMembership-request", log.Fields{"membership": membership})
out := new(empty.Empty)
- if err := handler.core.registerCoreTopic(ctx, membership.GroupName); err != nil {
+ if err := handler.core.updateCoreMembership(ctx, membership); err != nil {
return out, err
}
return out, nil
}
+func (handler *APIHandler) GetMembership(ctx context.Context, empty *empty.Empty) (*voltha.Membership, error) {
+ log.Debug("GetMembership-request")
+ if membership := handler.core.getCoreMembership(ctx); membership != nil {
+ return membership, nil
+ }
+ return &voltha.Membership{}, nil
+}
+
+
func (handler *APIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
log.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
if isTestMode(ctx) {