summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-08-31 11:29:22 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-08-31 11:31:28 -0700
commitce99856834a225f6f68b6eda725ae7122a2f8185 (patch)
tree5f0d0d155e36122ad8ad4fc251e2a97b545a341a /src
parent49c839f48994a394ed5004e4e4446b46833c7014 (diff)
Add rsync registration changes to ncm too
Changes made to remove dependency of rsyn registraion from orchestrator need to be added to ncm as well. Issue-ID: MULTICLOUD-1196 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: Ie572a127fd87cf50a1bb03163d98d3ebe901437e
Diffstat (limited to 'src')
-rw-r--r--src/ncm/pkg/scheduler/scheduler.go68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/ncm/pkg/scheduler/scheduler.go b/src/ncm/pkg/scheduler/scheduler.go
index 131113db..f2135974 100644
--- a/src/ncm/pkg/scheduler/scheduler.go
+++ b/src/ncm/pkg/scheduler/scheduler.go
@@ -18,6 +18,7 @@ package scheduler
import (
"encoding/json"
+ "fmt"
"time"
clusterPkg "github.com/onap/multicloud-k8s/src/clm/pkg/cluster"
@@ -28,11 +29,15 @@ import (
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/grpc/installappclient"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/controller"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/state"
pkgerrors "github.com/pkg/errors"
)
+// rsyncName denotes the name of the rsync controller
+const rsyncName = "rsync"
+
// ClusterManager is an interface exposes the Cluster functionality
type SchedulerManager interface {
ApplyNetworkIntents(clusterProvider, cluster string) error
@@ -65,6 +70,65 @@ func deleteAppContext(ac appcontext.AppContext) {
}
}
+/*
+queryDBAndSetRsyncInfo queries the MCO db to find the record the sync controller
+and then sets the RsyncInfo global variable.
+*/
+func queryDBAndSetRsyncInfo() (installappclient.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 := installappclient.NewRsyncInfo(v.Metadata.Name, v.Spec.Host, v.Spec.Port)
+ return rsyncInfo, nil
+ }
+ }
+ return installappclient.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 = installappclient.InvokeInstallApp(appContextID)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+/*
+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 = installappclient.InvokeUninstallApp(appContextID)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
// Apply Network Intents associated with a cluster
func (v *SchedulerClient) ApplyNetworkIntents(clusterProvider, cluster string) error {
@@ -162,7 +226,7 @@ func (v *SchedulerClient) ApplyNetworkIntents(clusterProvider, cluster string) e
}
// call resource synchronizer to instantiate the CRs in the cluster
- err = installappclient.InvokeInstallApp(ctxVal.(string))
+ err = callRsyncInstall(ctxVal)
if err != nil {
deleteAppContext(ac)
return err
@@ -216,7 +280,7 @@ func (v *SchedulerClient) TerminateNetworkIntents(clusterProvider, cluster strin
// call resource synchronizer to terminate the CRs in the cluster
contextId := state.GetLastContextIdFromStateInfo(s)
- err = installappclient.InvokeUninstallApp(contextId)
+ err = callRsyncUninstall(contextId)
if err != nil {
return err
}