diff options
author | Rajamohan Raj <rajamohan.raj@intel.com> | 2020-04-15 18:45:47 +0000 |
---|---|---|
committer | Rajamohan Raj <rajamohan.raj@intel.com> | 2020-04-17 23:33:04 +0000 |
commit | 6e0b4df46f51f9793f2d88626234edaaf9992403 (patch) | |
tree | 1c91022afe63ee3643ff5a1246a28236e5d33c32 /src/orchestrator/pkg/module/instantiation.go | |
parent | 1c3a22e3de0dd24b4161ae8b34794627620a208b (diff) |
Added intentResolver
IntentResolver shall collect the clusterdetails for each of the app
where it needs to be deployed. This shall be called by
the instantiation code.
Issue-ID: MULTICLOUD-1041
Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com>
Change-Id: I7d29901e46a5349ef502786c187c1c88bea61a12
Diffstat (limited to 'src/orchestrator/pkg/module/instantiation.go')
-rw-r--r-- | src/orchestrator/pkg/module/instantiation.go | 50 |
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 |