summaryrefslogtreecommitdiffstats
path: root/src/orchestrator
diff options
context:
space:
mode:
Diffstat (limited to 'src/orchestrator')
-rw-r--r--src/orchestrator/pkg/appcontext/appcontext.go12
-rw-r--r--src/orchestrator/pkg/module/app_intent.go78
-rw-r--r--src/orchestrator/pkg/module/generic_placement_intent.go16
-rw-r--r--src/orchestrator/pkg/module/instantiation.go16
-rw-r--r--src/orchestrator/pkg/module/instantiation_appcontext_helper.go6
5 files changed, 63 insertions, 65 deletions
diff --git a/src/orchestrator/pkg/appcontext/appcontext.go b/src/orchestrator/pkg/appcontext/appcontext.go
index d77672db..d0935d82 100644
--- a/src/orchestrator/pkg/appcontext/appcontext.go
+++ b/src/orchestrator/pkg/appcontext/appcontext.go
@@ -67,10 +67,11 @@ var AppContextStatusEnum = &statuses{
// CompositeAppVersion, ReleaseName. This shall be used for
// instantiation of a compositeApp
type CompositeAppMeta struct {
- Project string `json:"Project"`
- CompositeApp string `json:"CompositeApp"`
- Version string `json:"Version"`
- Release string `json:"Release"`
+ Project string `json:"Project"`
+ CompositeApp string `json:"CompositeApp"`
+ Version string `json:"Version"`
+ Release string `json:"Release"`
+ DeploymentIntentGroup string `json:"DeploymentIntentGroup"`
}
// Init app context
@@ -565,6 +566,7 @@ func (ac *AppContext) GetCompositeAppMeta() (CompositeAppMeta, error) {
ca := fmt.Sprintf("%v", datamap["CompositeApp"])
v := fmt.Sprintf("%v", datamap["Version"])
rn := fmt.Sprintf("%v", datamap["Release"])
+ dig := fmt.Sprintf("%v", datamap["DeploymentIntentGroup"])
- return CompositeAppMeta{Project: p, CompositeApp: ca, Version: v, Release: rn}, nil
+ return CompositeAppMeta{Project: p, CompositeApp: ca, Version: v, Release: rn, DeploymentIntentGroup: dig}, nil
}
diff --git a/src/orchestrator/pkg/module/app_intent.go b/src/orchestrator/pkg/module/app_intent.go
index f2f4e070..6b394513 100644
--- a/src/orchestrator/pkg/module/app_intent.go
+++ b/src/orchestrator/pkg/module/app_intent.go
@@ -67,22 +67,22 @@ type AppIntentQueryKey struct {
// AppIntentKey is used as primary key
type AppIntentKey struct {
- Name string `json:"appintent"`
- Project string `json:"project"`
- CompositeApp string `json:"compositeapp"`
- Version string `json:"compositeappversion"`
- Intent string `json:"genericplacement"`
- DeploymentIntentGroupName string `json:"deploymentintentgroupname"`
+ Name string `json:"appintent"`
+ Project string `json:"project"`
+ CompositeApp string `json:"compositeapp"`
+ Version string `json:"compositeappversion"`
+ Intent string `json:"genericplacement"`
+ DeploymentIntentGroupName string `json:"deploymentintentgroup"`
}
// AppIntentFindByAppKey required for query
type AppIntentFindByAppKey struct {
- Project string `json:"project"`
- CompositeApp string `json:"compositeapp"`
- CompositeAppVersion string `json:"compositeappversion"`
- Intent string `json:"genericplacement"`
- DeploymentIntentGroupName string `json:"deploymentintentgroupname"`
- AppName string `json:"app-name"`
+ Project string `json:"project"`
+ CompositeApp string `json:"compositeapp"`
+ CompositeAppVersion string `json:"compositeappversion"`
+ Intent string `json:"genericplacement"`
+ DeploymentIntentGroupName string `json:"deploymentintentgroup"`
+ AppName string `json:"app-name"`
}
// ApplicationsAndClusterInfo type represents the list of
@@ -151,17 +151,17 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
}
// check if the deploymentIntentGrpName exists
- _, err = NewDeploymentIntentGroupClient().GetDeploymentIntentGroup(digName,p, ca, v)
+ _, err = NewDeploymentIntentGroupClient().GetDeploymentIntentGroup(digName, p, ca, v)
if err != nil {
return AppIntent{}, pkgerrors.New("Unable to find the deployment-intent-group-name")
}
akey := AppIntentKey{
- Name: a.MetaData.Name,
- Project: p,
- CompositeApp: ca,
- Version: v,
- Intent: i,
+ Name: a.MetaData.Name,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
DeploymentIntentGroupName: digName,
}
@@ -173,7 +173,7 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
if err != nil {
return AppIntent{}, pkgerrors.Wrap(err, "Create DB entry error")
}
-
+
return a, nil
}
@@ -181,11 +181,11 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
func (c *AppIntentClient) GetAppIntent(ai string, p string, ca string, v string, i string, digName string) (AppIntent, error) {
k := AppIntentKey{
- Name: ai,
- Project: p,
- CompositeApp: ca,
- Version: v,
- Intent: i,
+ Name: ai,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
DeploymentIntentGroupName: digName,
}
@@ -213,12 +213,12 @@ all the intents for the app.
*/
func (c *AppIntentClient) GetAllIntentsByApp(aN, p, ca, v, i, digName string) (SpecData, error) {
k := AppIntentFindByAppKey{
- Project: p,
- CompositeApp: ca,
- CompositeAppVersion: v,
- Intent: i,
+ Project: p,
+ CompositeApp: ca,
+ CompositeAppVersion: v,
+ Intent: i,
DeploymentIntentGroupName: digName,
- AppName: aN,
+ AppName: aN,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
if err != nil {
@@ -239,11 +239,11 @@ and GenericPlacementIntentName,DeploymentIntentGroupName. Returns the Applicatio
*/
func (c *AppIntentClient) GetAllAppIntents(p, ca, v, i, digName string) (ApplicationsAndClusterInfo, error) {
k := AppIntentKey{
- Name: "",
- Project: p,
- CompositeApp: ca,
- Version: v,
- Intent: i,
+ Name: "",
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
DeploymentIntentGroupName: digName,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
@@ -276,11 +276,11 @@ func (c *AppIntentClient) GetAllAppIntents(p, ca, v, i, digName string) (Applica
// DeleteAppIntent delete an AppIntent
func (c *AppIntentClient) DeleteAppIntent(ai string, p string, ca string, v string, i string, digName string) error {
k := AppIntentKey{
- Name: ai,
- Project: p,
- CompositeApp: ca,
- Version: v,
- Intent: i,
+ Name: ai,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
DeploymentIntentGroupName: digName,
}
diff --git a/src/orchestrator/pkg/module/generic_placement_intent.go b/src/orchestrator/pkg/module/generic_placement_intent.go
index eb9ed796..3ff1c7dc 100644
--- a/src/orchestrator/pkg/module/generic_placement_intent.go
+++ b/src/orchestrator/pkg/module/generic_placement_intent.go
@@ -18,6 +18,7 @@ package module
import (
"encoding/json"
+
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
pkgerrors "github.com/pkg/errors"
@@ -36,9 +37,6 @@ type GenIntentMetaData struct {
UserData2 string `json:"userData2"`
}
-
-
-
// GenericPlacementIntentManager is an interface which exposes the GenericPlacementIntentManager functionality
type GenericPlacementIntentManager interface {
CreateGenericPlacementIntent(g GenericPlacementIntent, p string, ca string,
@@ -57,7 +55,7 @@ type GenericPlacementIntentKey struct {
Project string `json:"project"`
CompositeApp string `json:"compositeapp"`
Version string `json:"compositeappversion"`
- DigName string `json:"deploymentintentgroupname"`
+ DigName string `json:"deploymentintentgroup"`
}
// We will use json marshalling to convert to string to
@@ -112,13 +110,12 @@ func (c *GenericPlacementIntentClient) CreateGenericPlacementIntent(g GenericPla
return GenericPlacementIntent{}, pkgerrors.New("Unable to find the deployment-intent-group-name")
}
-
gkey := GenericPlacementIntentKey{
Name: g.MetaData.Name,
Project: p,
CompositeApp: ca,
Version: v,
- DigName: digName,
+ DigName: digName,
}
err = db.DBconn.Insert(c.storeName, gkey, nil, c.tagMetaData, g)
@@ -136,7 +133,7 @@ func (c *GenericPlacementIntentClient) GetGenericPlacementIntent(i string, p str
Project: p,
CompositeApp: ca,
Version: v,
- DigName: digName,
+ DigName: digName,
}
result, err := db.DBconn.Find(c.storeName, key, c.tagMetaData)
@@ -177,8 +174,7 @@ func (c *GenericPlacementIntentClient) GetAllGenericPlacementIntents(p string, c
Project: p,
CompositeApp: ca,
Version: v,
- DigName: digName,
-
+ DigName: digName,
}
var gpList []GenericPlacementIntent
@@ -207,7 +203,7 @@ func (c *GenericPlacementIntentClient) DeleteGenericPlacementIntent(i string, p
Project: p,
CompositeApp: ca,
Version: v,
- DigName: digName,
+ DigName: digName,
}
err := db.DBconn.Remove(c.storeName, key)
diff --git a/src/orchestrator/pkg/module/instantiation.go b/src/orchestrator/pkg/module/instantiation.go
index 4375a90b..d703af7f 100644
--- a/src/orchestrator/pkg/module/instantiation.go
+++ b/src/orchestrator/pkg/module/instantiation.go
@@ -99,12 +99,12 @@ func NewInstantiationClient() *InstantiationClient {
func (c InstantiationClient) Approve(p string, ca string, v string, di string) error {
s, err := NewDeploymentIntentGroupClient().GetDeploymentIntentGroupState(di, p, ca, v)
if err != nil {
- log.Info("DeploymentIntentGroup has no state info ", log.Fields{"DeploymentIntentGroup: ":di})
+ log.Info("DeploymentIntentGroup has no state info ", log.Fields{"DeploymentIntentGroup: ": di})
return pkgerrors.Wrap(err, "DeploymentIntentGroup has no state info: "+di)
}
stateVal, err := state.GetCurrentStateFromStateInfo(s)
if err != nil {
- log.Info("Error getting current state from DeploymentIntentGroup stateInfo", log.Fields{"DeploymentIntentGroup ":di})
+ log.Info("Error getting current state from DeploymentIntentGroup stateInfo", log.Fields{"DeploymentIntentGroup ": di})
return pkgerrors.Errorf("Error getting current state from DeploymentIntentGroup stateInfo: " + di)
}
switch stateVal {
@@ -222,24 +222,24 @@ func GetSortedTemplateForApp(appName, p, ca, v, rName, cp string, overrideValues
return sortedTemplates, err
}
-func calculateDirPath(fp string) string {
+func calculateDirPath(fp string) string {
sa := strings.Split(fp, "/")
return "/" + sa[1] + "/" + sa[2] + "/"
}
func cleanTmpfiles(sortedTemplates []helm.KubernetesResourceTemplate) error {
dp := calculateDirPath(sortedTemplates[0].FilePath)
- for _, st := range sortedTemplates{
+ for _, st := range sortedTemplates {
log.Info("Clean up ::", log.Fields{"file: ": st.FilePath})
err := os.Remove(st.FilePath)
if err != nil {
- log.Error("Error while deleting file", log.Fields{"file: ":st.FilePath})
+ log.Error("Error while deleting file", log.Fields{"file: ": st.FilePath})
return err
}
}
err := os.RemoveAll(dp)
if err != nil {
- log.Error("Error while deleting dir", log.Fields{"Dir: ":dp})
+ log.Error("Error while deleting dir", log.Fields{"Dir: ": dp})
return err
}
log.Info("Clean up temp-dir::", log.Fields{"Dir: ": dp})
@@ -298,7 +298,7 @@ func (c InstantiationClient) Instantiate(p string, ca string, v string, di strin
return pkgerrors.Wrap(err, "Not finding the apps")
}
- cca, err := makeAppContextForCompositeApp(p, ca, v, rName)
+ cca, err := makeAppContextForCompositeApp(p, ca, v, rName, di)
if err != nil {
return err
}
@@ -369,7 +369,7 @@ func (c InstantiationClient) Instantiate(p string, ca string, v string, di strin
deleteAppContext(context)
return pkgerrors.Wrap(err, "Error while verifying resources in app: ")
}
-
+
}
jappOrderInstr, err := json.Marshal(appOrderInstr)
if err != nil {
diff --git a/src/orchestrator/pkg/module/instantiation_appcontext_helper.go b/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
index 692cdf1e..06e025c7 100644
--- a/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
+++ b/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
@@ -46,7 +46,7 @@ type contextForCompositeApp struct {
}
// makeAppContext creates an appContext for a compositeApp and returns the output as contextForCompositeApp
-func makeAppContextForCompositeApp(p, ca, v, rName string) (contextForCompositeApp, error) {
+func makeAppContextForCompositeApp(p, ca, v, rName, dig string) (contextForCompositeApp, error) {
context := appcontext.AppContext{}
ctxval, err := context.InitAppContext()
if err != nil {
@@ -56,14 +56,14 @@ func makeAppContextForCompositeApp(p, ca, v, rName string) (contextForCompositeA
if err != nil {
return contextForCompositeApp{}, pkgerrors.Wrap(err, "Error creating CompositeApp handle")
}
- err = context.AddCompositeAppMeta(appcontext.CompositeAppMeta{Project: p, CompositeApp: ca, Version: v, Release: rName})
+ err = context.AddCompositeAppMeta(appcontext.CompositeAppMeta{Project: p, CompositeApp: ca, Version: v, Release: rName, DeploymentIntentGroup: dig})
if err != nil {
return contextForCompositeApp{}, pkgerrors.Wrap(err, "Error Adding CompositeAppMeta")
}
m, err := context.GetCompositeAppMeta()
- log.Info(":: The meta data stored in the runtime context :: ", log.Fields{"Project": m.Project, "CompositeApp": m.CompositeApp, "Version": m.Version, "Release": m.Release})
+ log.Info(":: The meta data stored in the runtime context :: ", log.Fields{"Project": m.Project, "CompositeApp": m.CompositeApp, "Version": m.Version, "Release": m.Release, "DeploymentIntentGroup": m.DeploymentIntentGroup})
cca := contextForCompositeApp{context: context, ctxval: ctxval, compositeAppHandle: compositeHandle}