aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitu Sood <Ritu.Sood@intel.com>2020-04-22 17:06:05 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-22 17:06:05 +0000
commit1909efb0d919c3932065d6a7fad47b825a157ef7 (patch)
treed4f3e87124e2c0e4e5bb89f87c8d23b07b3f9b14 /src
parentbad55d7f0156789799029bb6d27de2824786accd (diff)
parent223e6b9e99951d9ee364861c8d35109531dada09 (diff)
Merge "Orchestrator support for network intent updates"
Diffstat (limited to 'src')
-rw-r--r--src/orchestrator/pkg/appcontext/appcontext.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/appcontext/appcontext.go b/src/orchestrator/pkg/appcontext/appcontext.go
index bad5fa47..17afda9e 100644
--- a/src/orchestrator/pkg/appcontext/appcontext.go
+++ b/src/orchestrator/pkg/appcontext/appcontext.go
@@ -18,6 +18,8 @@ package appcontext
import (
"fmt"
+ "strings"
+
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/rtcontext"
pkgerrors "github.com/pkg/errors"
)
@@ -160,6 +162,36 @@ func (ac *AppContext) GetClusterHandle(appname string, clustername string) (inte
return nil, pkgerrors.Errorf("No handle was found for the given cluster")
}
+//Returns a list of all clusters for a given app
+func (ac *AppContext) GetClusterNames(appname string) ([]string, error) {
+ if appname == "" {
+ return nil, pkgerrors.Errorf("Not a valid run time context app name")
+ }
+
+ rh, err := ac.rtc.RtcGet()
+ if err != nil {
+ return nil, err
+ }
+
+ prefix := fmt.Sprintf("%v", rh) + "app/" + appname + "/cluster/"
+ hs, err := ac.rtc.RtcGetHandles(prefix)
+ if err != nil {
+ return nil, pkgerrors.Errorf("Error getting handles for %v", prefix)
+ }
+ var cs []string
+ for _, h := range hs {
+ hstr := fmt.Sprintf("%v", h)
+ ks := strings.Split(hstr, prefix)
+ for _, k := range ks {
+ ck := strings.Split(k, "/")
+ if len(ck) == 2 && ck[1] == "" {
+ cs = append(cs, ck[0])
+ }
+ }
+ }
+ return cs, nil
+}
+
//Add resource under app and cluster
func (ac *AppContext) AddResource(handle interface{}, resname string, value interface{}) (interface{}, error) {
h, err := ac.rtc.RtcAddResource(handle, resname, value)