aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/module/instantiation_scheduler_helper.go
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-08-19 00:32:30 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-08-27 22:14:23 +0000
commit49c839f48994a394ed5004e4e4446b46833c7014 (patch)
treeb0e09cbcfb3f232ad6c037ecc4a05d76605ca8ca /src/orchestrator/pkg/module/instantiation_scheduler_helper.go
parent9c942a11c14836630ba528b75bdcb2790045b91f (diff)
Remove the need for rysnc registration in orchestrator
Removed dependency of rsync registration from orchestrator.RSYNC shall have a function NewRsyncInfo to initiate a new rsync independent of the orchestrator and make gRPC calls. Issue-ID: MULTICLOUD-1196 Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com> Change-Id: I16bbac6a6865cf3c4ee7b763dac72abe2ed1ad0a
Diffstat (limited to 'src/orchestrator/pkg/module/instantiation_scheduler_helper.go')
-rw-r--r--src/orchestrator/pkg/module/instantiation_scheduler_helper.go43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/orchestrator/pkg/module/instantiation_scheduler_helper.go b/src/orchestrator/pkg/module/instantiation_scheduler_helper.go
index 184d6972..9f29dc38 100644
--- a/src/orchestrator/pkg/module/instantiation_scheduler_helper.go
+++ b/src/orchestrator/pkg/module/instantiation_scheduler_helper.go
@@ -27,6 +27,7 @@ import (
log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/controller"
mtypes "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/types"
+ pkgerrors "github.com/pkg/errors"
)
// ControllerTypePlacement denotes "placement" Controller Type
@@ -35,6 +36,9 @@ const ControllerTypePlacement string = "placement"
// ControllerTypeAction denotes "action" Controller Type
const ControllerTypeAction string = "action"
+// rsyncName denotes the name of the rsync controller
+const rsyncName = "rsync"
+
// ControllerElement consists of controller and an internal field - index
type ControllerElement struct {
controller controller.Controller
@@ -192,11 +196,38 @@ func callGrpcForControllerList(cl []controller.Controller, mc map[string]string,
}
/*
+queryDBAndSetRsyncInfo queries the MCO db to find the record the sync controller
+and then sets the RsyncInfo global variable.
+*/
+func queryDBAndSetRsyncInfo() (rsyncclient.RsyncInfo, error) {
+ client := controller.NewControllerClient()
+ vals, _ := client.GetControllers()
+ for _, v := range vals {
+ if v.Metadata.Name == rsyncName {
+ log.Info("Initializing RPC connection to resource synchronizer", log.Fields{
+ "Controller": v.Metadata.Name,
+ })
+ rsyncInfo := rsyncclient.NewRsyncInfo(v.Metadata.Name, v.Spec.Host, v.Spec.Port)
+ return rsyncInfo, nil
+ }
+ }
+ return rsyncclient.RsyncInfo{}, pkgerrors.Errorf("queryRsyncInfoInMCODB Failed - Could not get find rsync by name : %v", rsyncName)
+}
+
+/*
callRsyncInstall method shall take in the app context id and invokes the rsync service via grpc
*/
func callRsyncInstall(contextid interface{}) error {
+ rsyncInfo, err := queryDBAndSetRsyncInfo()
+ log.Info("Calling the Rsync ", log.Fields{
+ "RsyncName": rsyncInfo.RsyncName,
+ })
+ if err != nil {
+ return err
+ }
+
appContextID := fmt.Sprintf("%v", contextid)
- err := rsyncclient.InvokeInstallApp(appContextID)
+ err = rsyncclient.InvokeInstallApp(appContextID)
if err != nil {
return err
}
@@ -207,8 +238,16 @@ func callRsyncInstall(contextid interface{}) error {
callRsyncUninstall method shall take in the app context id and invokes the rsync service via grpc
*/
func callRsyncUninstall(contextid interface{}) error {
+ rsyncInfo, err := queryDBAndSetRsyncInfo()
+ log.Info("Calling the Rsync ", log.Fields{
+ "RsyncName": rsyncInfo.RsyncName,
+ })
+ if err != nil {
+ return err
+ }
+
appContextID := fmt.Sprintf("%v", contextid)
- err := rsyncclient.InvokeUninstallApp(appContextID)
+ err = rsyncclient.InvokeUninstallApp(appContextID)
if err != nil {
return err
}