From d82c8260bf51e1924fb39c2dc35f2e0f9186d6c0 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Thu, 6 Jun 2024 19:33:45 +0530 Subject: [PATCH] Add client side code for rpc calls Signed-off-by: Rewant Soni --- services/provider/client/client.go | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/services/provider/client/client.go b/services/provider/client/client.go index c9093c4236..cfe9ed7159 100644 --- a/services/provider/client/client.go +++ b/services/provider/client/client.go @@ -207,3 +207,65 @@ func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID stri return cc.Client.ReportStatus(apiCtx, req) } + +func (cc *OCSProviderClient) OnboardStorageClusterPeer(ctx context.Context, onboardingTicket, storageClusterPeerUID string) (*pb.OnboardStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.OnboardStorageClusterPeerRequest{ + OnboardingTicket: onboardingTicket, + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.OnboardStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) OffboardStorageClusterPeer(ctx context.Context, storageClusterPeerUID string) (*pb.OffboardStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.OffboardStorageClusterPeerRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.OffboardStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) AcknowledgeOnboardingStorageClusterPeer(ctx context.Context, storageClusterPeerUID string) (*pb.AcknowledgeOnboardingStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("provider client is closed") + } + + req := &pb.AcknowledgeOnboardingStorageClusterPeerRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.AcknowledgeOnboardingStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) GetMirroringInfo(ctx context.Context, storageClusterPeerUID string, blockPoolNames []string) (*pb.MirroringInfoResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.MirroringInfoRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + BlockPoolNames: blockPoolNames, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.GetMirroringInfo(apiCtx, req) +}