aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/module/instantiation.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/orchestrator/pkg/module/instantiation.go')
-rw-r--r--src/orchestrator/pkg/module/instantiation.go50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/orchestrator/pkg/module/instantiation.go b/src/orchestrator/pkg/module/instantiation.go
index 5fabe81e..56021547 100644
--- a/src/orchestrator/pkg/module/instantiation.go
+++ b/src/orchestrator/pkg/module/instantiation.go
@@ -18,17 +18,22 @@ package module
import (
"fmt"
- "github.com/onap/multicloud-k8s/src/orchestrator/utils/helm"
- pkgerrors "github.com/pkg/errors"
+ gpic "github.com/onap/multicloud-k8s/src/orchestrator/pkg/gpic"
"encoding/base64"
+
+ "github.com/onap/multicloud-k8s/src/orchestrator/utils/helm"
+ pkgerrors "github.com/pkg/errors"
"log"
)
// ManifestFileName is the name given to the manifest file in the profile package
const ManifestFileName = "manifest.yaml"
+// GenericPlacementIntentName denotes the generic placement intent name
+const GenericPlacementIntentName = "generic-placement-intent"
+
// InstantiationClient implements the InstantiationManager
type InstantiationClient struct {
storeName string
@@ -64,6 +69,30 @@ func getOverrideValuesByAppName(ov []OverrideValues, a string) map[string]string
return map[string]string{}
}
+/*
+FindGenericPlacementIntent takes in projectName, CompositeAppName, CompositeAppVersion, DeploymentIntentName
+and returns the name of the genericPlacementIntentName. Returns empty value if string not found.
+*/
+func FindGenericPlacementIntent(p, ca, v, di string) (string, error) {
+ var gi string
+ var found bool
+ iList, err := NewIntentClient().GetAllIntents(p, ca, v, di)
+ if err != nil {
+ return gi, err
+ }
+ for _, eachMap := range iList.ListOfIntents {
+ if gi, found := eachMap[GenericPlacementIntentName]; found {
+ log.Printf("::Name of the generic-placement-intent:: %s", gi)
+ return gi, err
+ }
+ }
+ if found == false {
+ fmt.Println("generic-placement-intent not found !")
+ }
+ return gi, pkgerrors.New("Generic-placement-intent not found")
+
+}
+
// GetSortedTemplateForApp returns the sorted templates.
//It takes in arguments - appName, project, compositeAppName, releaseName, compositeProfileName, array of override values
func GetSortedTemplateForApp(appName, p, ca, v, rName, cp string, overrideValues []OverrideValues) ([]helm.KubernetesResourceTemplate, error) {
@@ -124,6 +153,12 @@ func (c InstantiationClient) Instantiate(p string, ca string, v string, di strin
overrideValues := dIGrp.Spec.OverrideValuesObj
cp := dIGrp.Spec.Profile
+ gIntent, err := FindGenericPlacementIntent(p, ca, v, di)
+ if err != nil {
+ return err
+ }
+ log.Printf("The name of the GenPlacIntent:: %s", gIntent)
+
log.Printf("dIGrp :: %s, releaseName :: %s and cp :: %s \n", dIGrp.MetaData.Name, rName, cp)
allApps, err := NewAppClient().GetApps(p, ca, v)
if err != nil {
@@ -136,6 +171,17 @@ func (c InstantiationClient) Instantiate(p string, ca string, v string, di strin
}
log.Printf("Resolved all the templates for app :: %s under the compositeApp...", eachApp.Metadata.Name)
log.Printf("sortedTemplates :: %v ", sortedTemplates)
+
+ specData, err := NewAppIntentClient().GetAllIntentsByApp(eachApp.Metadata.Name, p, ca, v, gIntent)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Unable to get the intents for app")
+ }
+ listOfClusters,err := gpic.IntentResolver(specData.Intent)
+ if err!=nil {
+ return pkgerrors.Wrap(err, "Unable to get the intents resolved for app")
+ }
+ log.Printf("::listOfClusters:: %v", listOfClusters)
+
}
log.Printf("Done with instantiation...")
return err