summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/module
diff options
context:
space:
mode:
Diffstat (limited to 'src/orchestrator/pkg/module')
-rw-r--r--src/orchestrator/pkg/module/controller.go31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/orchestrator/pkg/module/controller.go b/src/orchestrator/pkg/module/controller.go
index 976b8988..6827af87 100644
--- a/src/orchestrator/pkg/module/controller.go
+++ b/src/orchestrator/pkg/module/controller.go
@@ -20,7 +20,8 @@ import (
"encoding/json"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
-
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ rpc "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/rpc"
pkgerrors "github.com/pkg/errors"
)
@@ -66,6 +67,7 @@ type ControllerManager interface {
CreateController(ms Controller, mayExist bool) (Controller, error)
GetController(name string) (Controller, error)
GetControllers() ([]Controller, error)
+ InitControllers()
DeleteController(name string) error
}
@@ -104,6 +106,9 @@ func (mc *ControllerClient) CreateController(m Controller, mayExist bool) (Contr
return Controller{}, pkgerrors.Wrap(err, "Creating DB Entry")
}
+ // send message to create/update the rpc connection
+ rpc.UpdateRpcConn(m.Metadata.Name, m.Spec.Host, m.Spec.Port)
+
return m, nil
}
@@ -152,15 +157,6 @@ func (mc *ControllerClient) GetControllers() ([]Controller, error) {
return []Controller{}, pkgerrors.Wrap(err, "Unmarshaling Value")
}
- // run healthcheck
- /*
- err = mc.HealthCheck(microserv.Name)
- if err != nil {
- log.Warn("HealthCheck Failed", log.Fields{
- "Controller": microserv.Name,
- })
- }
- */
resp = append(resp, microserv)
}
@@ -178,5 +174,20 @@ func (mc *ControllerClient) DeleteController(name string) error {
if err != nil {
return pkgerrors.Wrap(err, "Delete Controller Entry;")
}
+
+ // send message to close rpc connection
+ rpc.RemoveRpcConn(name)
+
return nil
}
+
+// InitControllers initializes connctions for controllers in the DB
+func (mc *ControllerClient) InitControllers() {
+ vals, _ := mc.GetControllers()
+ for _, v := range vals {
+ log.Info("Initializing RPC connection for controller", log.Fields{
+ "Controller": v.Metadata.Name,
+ })
+ rpc.UpdateRpcConn(v.Metadata.Name, v.Spec.Host, v.Spec.Port)
+ }
+}