diff options
author | Eric Multanen <eric.w.multanen@intel.com> | 2020-04-14 20:47:35 -0700 |
---|---|---|
committer | Eric Multanen <eric.w.multanen@intel.com> | 2020-04-21 10:44:46 -0700 |
commit | 223e6b9e99951d9ee364861c8d35109531dada09 (patch) | |
tree | fd0fbe47230cb8eb236376189e35b84316e81cdb /src/orchestrator/pkg | |
parent | 41e63a840a08cba73b4d606e162bb71d042a4e95 (diff) |
Orchestrator support for network intent updates
Adds support code in orchestrator for handling
updates to app context resources when ncm
handles network intents.
Add a get cluster names call to the app context
Issue-ID: MULTICLOUD-1029
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Change-Id: Ifdc78488a1e86f43d6fe656c59675862c4818af5
Diffstat (limited to 'src/orchestrator/pkg')
-rw-r--r-- | src/orchestrator/pkg/appcontext/appcontext.go | 32 |
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) |