summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/ovnaction/api/api.go41
-rw-r--r--src/ovnaction/api/chainhandler.go16
-rw-r--r--src/ovnaction/api/netcontrolintenthandler.go62
-rw-r--r--src/ovnaction/api/workloadifintenthandler.go24
-rw-r--r--src/ovnaction/api/workloadintenthandler.go24
-rw-r--r--src/ovnaction/internal/action/action.go38
-rw-r--r--src/ovnaction/pkg/module/chaining.go25
-rw-r--r--src/ovnaction/pkg/module/netcontrolintent.go155
-rw-r--r--src/ovnaction/pkg/module/workloadifintent.go25
-rw-r--r--src/ovnaction/pkg/module/workloadintent.go25
-rw-r--r--src/tools/emcoctl/cmd/utils.go2
-rw-r--r--src/tools/emcoctl/examples/test.yaml73
-rw-r--r--src/tools/emcoctl/examples/vfw.yaml137
18 files changed, 320 insertions, 455 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}
diff --git a/src/ovnaction/api/api.go b/src/ovnaction/api/api.go
index bffab0a4..36744cb0 100644
--- a/src/ovnaction/api/api.go
+++ b/src/ovnaction/api/api.go
@@ -75,39 +75,38 @@ func NewRouter(testClient interface{}) *mux.Router {
netcontrolintentHandler := netcontrolintentHandler{
client: setClient(moduleClient.NetControlIntent, testClient).(moduleLib.NetControlIntentManager),
}
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent", netcontrolintentHandler.createHandler).Methods("POST")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent", netcontrolintentHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.putHandler).Methods("PUT")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.deleteHandler).Methods("DELETE")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}/apply", netcontrolintentHandler.applyHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent", netcontrolintentHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent", netcontrolintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{name}", netcontrolintentHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{name}", netcontrolintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{name}", netcontrolintentHandler.deleteHandler).Methods("DELETE")
workloadintentHandler := workloadintentHandler{
client: setClient(moduleClient.WorkloadIntent, testClient).(moduleLib.WorkloadIntentManager),
}
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.createHandler).Methods("POST")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.putHandler).Methods("PUT")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.deleteHandler).Methods("DELETE")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.deleteHandler).Methods("DELETE")
workloadifintentHandler := workloadifintentHandler{
client: setClient(moduleClient.WorkloadIfIntent, testClient).(moduleLib.WorkloadIfIntentManager),
}
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.createHandler).Methods("POST")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.putHandler).Methods("PUT")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.deleteHandler).Methods("DELETE")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.deleteHandler).Methods("DELETE")
chainHandler := chainHandler{
client: setClient(moduleClient.Chain, testClient).(moduleLib.ChainManager),
}
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.createHandler).Methods("POST")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.putHandler).Methods("PUT")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.getHandler).Methods("GET")
- router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.deleteHandler).Methods("DELETE")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.deleteHandler).Methods("DELETE")
return router
}
diff --git a/src/ovnaction/api/chainhandler.go b/src/ovnaction/api/chainhandler.go
index 52ed18e5..daf5b2eb 100644
--- a/src/ovnaction/api/chainhandler.go
+++ b/src/ovnaction/api/chainhandler.go
@@ -23,8 +23,8 @@ import (
"net/http"
"strings"
- moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
pkgerrors "github.com/pkg/errors"
"github.com/gorilla/mux"
@@ -141,6 +141,7 @@ func (h chainHandler) createHandler(w http.ResponseWriter, r *http.Request) {
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
err := json.NewDecoder(r.Body).Decode(&ch)
@@ -166,7 +167,7 @@ func (h chainHandler) createHandler(w http.ResponseWriter, r *http.Request) {
return
}
- ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, netControlIntent, false)
+ ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, false)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -189,6 +190,7 @@ func (h chainHandler) putHandler(w http.ResponseWriter, r *http.Request) {
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
err := json.NewDecoder(r.Body).Decode(&ch)
@@ -221,7 +223,7 @@ func (h chainHandler) putHandler(w http.ResponseWriter, r *http.Request) {
return
}
- ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, netControlIntent, true)
+ ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, true)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -244,18 +246,19 @@ func (h chainHandler) getHandler(w http.ResponseWriter, r *http.Request) {
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
var ret interface{}
var err error
if len(name) == 0 {
- ret, err = h.client.GetChains(project, compositeApp, compositeAppVersion, netControlIntent)
+ ret, err = h.client.GetChains(project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} else {
- ret, err = h.client.GetChain(name, project, compositeApp, compositeAppVersion, netControlIntent)
+ ret, err = h.client.GetChain(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -278,9 +281,10 @@ func (h chainHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
- err := h.client.DeleteChain(name, project, compositeApp, compositeAppVersion, netControlIntent)
+ err := h.client.DeleteChain(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/src/ovnaction/api/netcontrolintenthandler.go b/src/ovnaction/api/netcontrolintenthandler.go
index 631f13c4..85318ccf 100644
--- a/src/ovnaction/api/netcontrolintenthandler.go
+++ b/src/ovnaction/api/netcontrolintenthandler.go
@@ -22,18 +22,15 @@ import (
"io"
"net/http"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
pkgerrors "github.com/pkg/errors"
- "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
-
"github.com/gorilla/mux"
)
var netCntIntJSONFile string = "json-schemas/metadata.json"
-
-
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type netcontrolintentHandler struct {
@@ -59,6 +56,7 @@ func (h netcontrolintentHandler) createHandler(w http.ResponseWriter, r *http.Re
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
err := json.NewDecoder(r.Body).Decode(&nci)
@@ -72,11 +70,10 @@ func (h netcontrolintentHandler) createHandler(w http.ResponseWriter, r *http.Re
}
err, httpError := validation.ValidateJsonSchemaData(netCntIntJSONFile, nci)
-if err != nil {
- http.Error(w, err.Error(), httpError)
- return
-}
-
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
// Name is required.
if nci.Metadata.Name == "" {
@@ -90,7 +87,7 @@ if err != nil {
return
}
- ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, false)
+ ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, deployIntentGroup, false)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -113,6 +110,7 @@ func (h netcontrolintentHandler) putHandler(w http.ResponseWriter, r *http.Reque
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
err := json.NewDecoder(r.Body).Decode(&nci)
@@ -144,7 +142,7 @@ func (h netcontrolintentHandler) putHandler(w http.ResponseWriter, r *http.Reque
return
}
- ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, true)
+ ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, deployIntentGroup, true)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -167,17 +165,18 @@ func (h netcontrolintentHandler) getHandler(w http.ResponseWriter, r *http.Reque
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
var ret interface{}
var err error
if len(name) == 0 {
- ret, err = h.client.GetNetControlIntents(project, compositeApp, compositeAppVersion)
+ ret, err = h.client.GetNetControlIntents(project, compositeApp, compositeAppVersion, deployIntentGroup)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} else {
- ret, err = h.client.GetNetControlIntent(name, project, compositeApp, compositeAppVersion)
+ ret, err = h.client.GetNetControlIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -200,42 +199,9 @@ func (h netcontrolintentHandler) deleteHandler(w http.ResponseWriter, r *http.Re
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
- err := h.client.DeleteNetControlIntent(name, project, compositeApp, compositeAppVersion)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
-
- w.WriteHeader(http.StatusNoContent)
-}
-
-// Apply handles POST operations to Apply a particular NetControlIntent to the App Context
-// TODO: This is a test API - it can be removed once the orchestrator has been implemented to
-// invoke the appcontext update via grpc.
-func (h netcontrolintentHandler) applyHandler(w http.ResponseWriter, r *http.Request) {
- vars := mux.Vars(r)
- name := vars["name"]
- project := vars["project"]
- compositeApp := vars["composite-app-name"]
- compositeAppVersion := vars["version"]
-
- var aci struct {
- AppContextId string `json:"appContextId"`
- }
-
- err := json.NewDecoder(r.Body).Decode(&aci)
-
- switch {
- case err == io.EOF:
- http.Error(w, "Empty body", http.StatusBadRequest)
- return
- case err != nil:
- http.Error(w, err.Error(), http.StatusUnprocessableEntity)
- return
- }
-
- err = h.client.ApplyNetControlIntent(name, project, compositeApp, compositeAppVersion, aci.AppContextId)
+ err := h.client.DeleteNetControlIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/src/ovnaction/api/workloadifintenthandler.go b/src/ovnaction/api/workloadifintenthandler.go
index e7be6317..5c396378 100644
--- a/src/ovnaction/api/workloadifintenthandler.go
+++ b/src/ovnaction/api/workloadifintenthandler.go
@@ -22,8 +22,8 @@ import (
"io"
"net/http"
- moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
pkgerrors "github.com/pkg/errors"
"github.com/gorilla/mux"
@@ -90,6 +90,7 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
workloadIntent := vars["workload-intent"]
@@ -105,10 +106,10 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re
}
err, httpError := validation.ValidateJsonSchemaData(netIfJSONFile, wif)
-if err != nil {
- http.Error(w, err.Error(), httpError)
- return
-}
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
// Name is required.
if wif.Metadata.Name == "" {
@@ -127,7 +128,7 @@ if err != nil {
return
}
- ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent, false)
+ ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent, false)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -150,6 +151,7 @@ func (h workloadifintentHandler) putHandler(w http.ResponseWriter, r *http.Reque
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
workloadIntent := vars["workload-intent"]
@@ -188,7 +190,7 @@ func (h workloadifintentHandler) putHandler(w http.ResponseWriter, r *http.Reque
return
}
- ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent, true)
+ ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent, true)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -211,19 +213,20 @@ func (h workloadifintentHandler) getHandler(w http.ResponseWriter, r *http.Reque
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
workloadIntent := vars["workload-intent"]
var ret interface{}
var err error
if len(name) == 0 {
- ret, err = h.client.GetWorkloadIfIntents(project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent)
+ ret, err = h.client.GetWorkloadIfIntents(project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} else {
- ret, err = h.client.GetWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent)
+ ret, err = h.client.GetWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -246,10 +249,11 @@ func (h workloadifintentHandler) deleteHandler(w http.ResponseWriter, r *http.Re
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
workloadIntent := vars["workload-intent"]
- err := h.client.DeleteWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent)
+ err := h.client.DeleteWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/src/ovnaction/api/workloadintenthandler.go b/src/ovnaction/api/workloadintenthandler.go
index acf4edbb..485f6f40 100644
--- a/src/ovnaction/api/workloadintenthandler.go
+++ b/src/ovnaction/api/workloadintenthandler.go
@@ -22,8 +22,8 @@ import (
"io"
"net/http"
- moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
pkgerrors "github.com/pkg/errors"
"github.com/gorilla/mux"
@@ -71,6 +71,7 @@ func (h workloadintentHandler) createHandler(w http.ResponseWriter, r *http.Requ
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
err := json.NewDecoder(r.Body).Decode(&wi)
@@ -85,10 +86,10 @@ func (h workloadintentHandler) createHandler(w http.ResponseWriter, r *http.Requ
}
err, httpError := validation.ValidateJsonSchemaData(workloadIntJSONFile, wi)
-if err != nil {
- http.Error(w, err.Error(), httpError)
- return
-}
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
// Name is required.
if wi.Metadata.Name == "" {
@@ -102,7 +103,7 @@ if err != nil {
return
}
- ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, netControlIntent, false)
+ ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, false)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -125,6 +126,7 @@ func (h workloadintentHandler) putHandler(w http.ResponseWriter, r *http.Request
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
err := json.NewDecoder(r.Body).Decode(&wi)
@@ -157,7 +159,7 @@ func (h workloadintentHandler) putHandler(w http.ResponseWriter, r *http.Request
return
}
- ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, netControlIntent, true)
+ ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, true)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -180,18 +182,19 @@ func (h workloadintentHandler) getHandler(w http.ResponseWriter, r *http.Request
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
var ret interface{}
var err error
if len(name) == 0 {
- ret, err = h.client.GetWorkloadIntents(project, compositeApp, compositeAppVersion, netControlIntent)
+ ret, err = h.client.GetWorkloadIntents(project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} else {
- ret, err = h.client.GetWorkloadIntent(name, project, compositeApp, compositeAppVersion, netControlIntent)
+ ret, err = h.client.GetWorkloadIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -214,9 +217,10 @@ func (h workloadintentHandler) deleteHandler(w http.ResponseWriter, r *http.Requ
project := vars["project"]
compositeApp := vars["composite-app-name"]
compositeAppVersion := vars["version"]
+ deployIntentGroup := vars["deployment-intent-group-name"]
netControlIntent := vars["net-control-intent"]
- err := h.client.DeleteWorkloadIntent(name, project, compositeApp, compositeAppVersion, netControlIntent)
+ err := h.client.DeleteWorkloadIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/src/ovnaction/internal/action/action.go b/src/ovnaction/internal/action/action.go
index c9b912fa..ae04cb0f 100644
--- a/src/ovnaction/internal/action/action.go
+++ b/src/ovnaction/internal/action/action.go
@@ -47,11 +47,12 @@ func UpdateAppContext(intentName, appContextId string) error {
project := caMeta.Project
compositeapp := caMeta.CompositeApp
compositeappversion := caMeta.Version
+ deployIntentGroup := caMeta.DeploymentIntentGroup
// Handle all Workload Intents for the Network Control Intent
- wis, err := module.NewWorkloadIntentClient().GetWorkloadIntents(project, compositeapp, compositeappversion, intentName)
+ wis, err := module.NewWorkloadIntentClient().GetWorkloadIntents(project, compositeapp, compositeappversion, deployIntentGroup, intentName)
if err != nil {
- return pkgerrors.Wrapf(err, "Error getting Workload Intents for Network Control Intent %v for %v/%v%v not found", intentName, project, compositeapp, compositeappversion)
+ return pkgerrors.Wrapf(err, "Error getting Workload Intents for Network Control Intent %v for %v/%v%v/%v not found", intentName, project, compositeapp, deployIntentGroup, compositeappversion)
}
// Handle all intents (currently just Workload Interface intents) for each Workload Intent
@@ -66,20 +67,22 @@ func UpdateAppContext(intentName, appContextId string) error {
wifs, err := module.NewWorkloadIfIntentClient().GetWorkloadIfIntents(project,
compositeapp,
compositeappversion,
+ deployIntentGroup,
intentName,
wi.Metadata.Name)
if err != nil {
return pkgerrors.Wrapf(err,
- "Error getting Workload Interface Intents for Workload Intent %v under Network Control Intent %v for %v/%v%v not found",
- wi.Metadata.Name, intentName, project, compositeapp, compositeappversion)
+ "Error getting Workload Interface Intents for Workload Intent %v under Network Control Intent %v for %v/%v%v/%v not found",
+ wi.Metadata.Name, intentName, project, compositeapp, compositeappversion, deployIntentGroup)
}
if len(wifs) == 0 {
log.Warn("No interface intents provided for workload intent", log.Fields{
- "project": project,
- "composite app": compositeapp,
- "composite app version": compositeappversion,
- "network control intent": intentName,
- "workload intent": wi.Metadata.Name,
+ "project": project,
+ "composite app": compositeapp,
+ "composite app version": compositeappversion,
+ "deployment intent group": deployIntentGroup,
+ "network control intent": intentName,
+ "workload intent": wi.Metadata.Name,
})
continue
}
@@ -91,14 +94,15 @@ func UpdateAppContext(intentName, appContextId string) error {
strings.Join([]string{wi.Spec.WorkloadResource, wi.Spec.Type}, "+"))
if err != nil {
log.Warn("App Context resource handle not found", log.Fields{
- "project": project,
- "composite app": compositeapp,
- "composite app version": compositeappversion,
- "network control intent": intentName,
- "workload name": wi.Metadata.Name,
- "app": wi.Spec.AppName,
- "resource": wi.Spec.WorkloadResource,
- "resource type": wi.Spec.Type,
+ "project": project,
+ "composite app": compositeapp,
+ "composite app version": compositeappversion,
+ "deployment intent group": deployIntentGroup,
+ "network control intent": intentName,
+ "workload name": wi.Metadata.Name,
+ "app": wi.Spec.AppName,
+ "resource": wi.Spec.WorkloadResource,
+ "resource type": wi.Spec.Type,
})
continue
}
diff --git a/src/ovnaction/pkg/module/chaining.go b/src/ovnaction/pkg/module/chaining.go
index 45f061fa..bc2cac00 100644
--- a/src/ovnaction/pkg/module/chaining.go
+++ b/src/ovnaction/pkg/module/chaining.go
@@ -54,6 +54,7 @@ type ChainKey struct {
Project string `json:"project"`
CompositeApp string `json:"compositeapp"`
CompositeAppVersion string `json:"compositeappversion"`
+ DigName string `json:"deploymentintentgroup"`
NetControlIntent string `json:"netcontrolintent"`
NetworkChain string `json:"networkchain"`
}
@@ -76,10 +77,10 @@ const ChainingKind = "NetworkChaining"
// ChainManager is an interface exposing the Chain functionality
type ChainManager interface {
- CreateChain(ch Chain, pr, ca, caver, netctrlint string, exists bool) (Chain, error)
- GetChain(name, pr, ca, caver, netctrlint string) (Chain, error)
- GetChains(pr, ca, caver, netctrlint string) ([]Chain, error)
- DeleteChain(name, pr, ca, caver, netctrlint string) error
+ CreateChain(ch Chain, pr, ca, caver, dig, netctrlint string, exists bool) (Chain, error)
+ GetChain(name, pr, ca, caver, dig, netctrlint string) (Chain, error)
+ GetChains(pr, ca, caver, dig, netctrlint string) ([]Chain, error)
+ DeleteChain(name, pr, ca, caver, dig, netctrlint string) error
}
// ChainClient implements the Manager
@@ -100,24 +101,25 @@ func NewChainClient() *ChainClient {
}
// CreateChain - create a new Chain
-func (v *ChainClient) CreateChain(ch Chain, pr, ca, caver, netctrlint string, exists bool) (Chain, error) {
+func (v *ChainClient) CreateChain(ch Chain, pr, ca, caver, dig, netctrlint string, exists bool) (Chain, error) {
//Construct key and tag to select the entry
key := ChainKey{
Project: pr,
CompositeApp: ca,
CompositeAppVersion: caver,
+ DigName: dig,
NetControlIntent: netctrlint,
NetworkChain: ch.Metadata.Name,
}
//Check if the Network Control Intent exists
- _, err := NewNetControlIntentClient().GetNetControlIntent(netctrlint, pr, ca, caver)
+ _, err := NewNetControlIntentClient().GetNetControlIntent(netctrlint, pr, ca, caver, dig)
if err != nil {
return Chain{}, pkgerrors.Errorf("Network Control Intent %v does not exist", netctrlint)
}
//Check if this Chain already exists
- _, err = v.GetChain(ch.Metadata.Name, pr, ca, caver, netctrlint)
+ _, err = v.GetChain(ch.Metadata.Name, pr, ca, caver, dig, netctrlint)
if err == nil && !exists {
return Chain{}, pkgerrors.New("Chain already exists")
}
@@ -131,12 +133,13 @@ func (v *ChainClient) CreateChain(ch Chain, pr, ca, caver, netctrlint string, ex
}
// GetChain returns the Chain for corresponding name
-func (v *ChainClient) GetChain(name, pr, ca, caver, netctrlint string) (Chain, error) {
+func (v *ChainClient) GetChain(name, pr, ca, caver, dig, netctrlint string) (Chain, error) {
//Construct key and tag to select the entry
key := ChainKey{
Project: pr,
CompositeApp: ca,
CompositeAppVersion: caver,
+ DigName: dig,
NetControlIntent: netctrlint,
NetworkChain: name,
}
@@ -160,12 +163,13 @@ func (v *ChainClient) GetChain(name, pr, ca, caver, netctrlint string) (Chain, e
}
// GetChains returns all of the Chains for for the given network control intent
-func (v *ChainClient) GetChains(pr, ca, caver, netctrlint string) ([]Chain, error) {
+func (v *ChainClient) GetChains(pr, ca, caver, dig, netctrlint string) ([]Chain, error) {
//Construct key and tag to select the entry
key := ChainKey{
Project: pr,
CompositeApp: ca,
CompositeAppVersion: caver,
+ DigName: dig,
NetControlIntent: netctrlint,
NetworkChain: "",
}
@@ -189,13 +193,14 @@ func (v *ChainClient) GetChains(pr, ca, caver, netctrlint string) ([]Chain, erro
}
// DeleteChain deletes the Chain from the database
-func (v *ChainClient) DeleteChain(name, pr, ca, caver, netctrlint string) error {
+func (v *ChainClient) DeleteChain(name, pr, ca, caver, dig, netctrlint string) error {
//Construct key and tag to select the entry
key := ChainKey{
Project: pr,
CompositeApp: ca,
CompositeAppVersion: caver,
+ DigName: dig,
NetControlIntent: netctrlint,
NetworkChain: name,
}
diff --git a/src/ovnaction/pkg/module/netcontrolintent.go b/src/ovnaction/pkg/module/netcontrolintent.go
index c005a935..eada4be1 100644
--- a/src/ovnaction/pkg/module/netcontrolintent.go
+++ b/src/ovnaction/pkg/module/netcontrolintent.go
@@ -17,17 +17,7 @@
package module
import (
- "encoding/json"
- "strings"
-
- jyaml "github.com/ghodss/yaml"
-
- nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
- "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
- log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/client-go/kubernetes/scheme"
pkgerrors "github.com/pkg/errors"
)
@@ -43,15 +33,15 @@ type NetControlIntentKey struct {
Project string `json:"project"`
CompositeApp string `json:"compositeapp"`
CompositeAppVersion string `json:"compositeappversion"`
+ DigName string `json:"deploymentintentgroup"`
}
// Manager is an interface exposing the NetControlIntent functionality
type NetControlIntentManager interface {
- CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion string, exists bool) (NetControlIntent, error)
- GetNetControlIntent(name, project, compositeapp, compositeappversion string) (NetControlIntent, error)
- GetNetControlIntents(project, compositeapp, compositeappversion string) ([]NetControlIntent, error)
- DeleteNetControlIntent(name, project, compositeapp, compositeappversion string) error
- ApplyNetControlIntent(name, project, compositeapp, compositeappversion, appContextId string) error
+ CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion, dig string, exists bool) (NetControlIntent, error)
+ GetNetControlIntent(name, project, compositeapp, compositeappversion, dig string) (NetControlIntent, error)
+ GetNetControlIntents(project, compositeapp, compositeappversion, dig string) ([]NetControlIntent, error)
+ DeleteNetControlIntent(name, project, compositeapp, compositeappversion, dig string) error
}
// NetControlIntentClient implements the Manager
@@ -72,7 +62,7 @@ func NewNetControlIntentClient() *NetControlIntentClient {
}
// CreateNetControlIntent - create a new NetControlIntent
-func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion string, exists bool) (NetControlIntent, error) {
+func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion, dig string, exists bool) (NetControlIntent, error) {
//Construct key and tag to select the entry
key := NetControlIntentKey{
@@ -80,10 +70,11 @@ func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, pr
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
}
//Check if this NetControlIntent already exists
- _, err := v.GetNetControlIntent(nci.Metadata.Name, project, compositeapp, compositeappversion)
+ _, err := v.GetNetControlIntent(nci.Metadata.Name, project, compositeapp, compositeappversion, dig)
if err == nil && !exists {
return NetControlIntent{}, pkgerrors.New("NetControlIntent already exists")
}
@@ -97,7 +88,7 @@ func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, pr
}
// GetNetControlIntent returns the NetControlIntent for corresponding name
-func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp, compositeappversion string) (NetControlIntent, error) {
+func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp, compositeappversion, dig string) (NetControlIntent, error) {
//Construct key and tag to select the entry
key := NetControlIntentKey{
@@ -105,6 +96,7 @@ func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
}
value, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
@@ -126,7 +118,7 @@ func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp
}
// GetNetControlIntentList returns all of the NetControlIntent for corresponding name
-func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, compositeappversion string) ([]NetControlIntent, error) {
+func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, compositeappversion, dig string) ([]NetControlIntent, error) {
//Construct key and tag to select the entry
key := NetControlIntentKey{
@@ -134,6 +126,7 @@ func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, com
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
}
var resp []NetControlIntent
@@ -155,7 +148,7 @@ func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, com
}
// Delete the NetControlIntent from database
-func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, compositeapp, compositeappversion string) error {
+func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, compositeapp, compositeappversion, dig string) error {
//Construct key and tag to select the entry
key := NetControlIntentKey{
@@ -163,6 +156,7 @@ func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, composite
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
}
err := db.DBconn.Remove(v.db.storeName, key)
@@ -172,124 +166,3 @@ func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, composite
return nil
}
-
-// (Test Routine) - Apply network-control-intent
-func (v *NetControlIntentClient) ApplyNetControlIntent(name, project, compositeapp, compositeappversion, appContextId string) error {
- // TODO: Handle all Network Chain Intents for the Network Control Intent
-
- // Handle all Workload Intents for the Network Control Intent
- wis, err := NewWorkloadIntentClient().GetWorkloadIntents(project, compositeapp, compositeappversion, name)
- if err != nil {
- return pkgerrors.Wrapf(err, "Error getting Workload Intents for Network Control Intent %v for %v/%v%v not found", name, project, compositeapp, compositeappversion)
- }
-
- // Setup the AppContext
- var context appcontext.AppContext
- _, err = context.LoadAppContext(appContextId)
- if err != nil {
- return pkgerrors.Wrapf(err, "Error getting AppContext with Id: %v for %v/%v%v",
- appContextId, project, compositeapp, compositeappversion)
- }
-
- // Handle all intents (currently just Interface intents) for each Workload Intent
- for _, wi := range wis {
- // The app/resource identified in the workload intent needs to be updated with two annotations.
- // 1 - The "k8s.v1.cni.cncf.io/networks" annotation will have {"name": "ovn-networkobj", "namespace": "default"} added
- // to it (preserving any existing values for this annotation.
- // 2 - The "k8s.plugin.opnfv.org/nfn-network" annotation will add any network interfaces that are provided by the
- // workload/interfaces intents.
-
- // Prepare the list of interfaces from the workload intent
- wifs, err := NewWorkloadIfIntentClient().GetWorkloadIfIntents(project,
- compositeapp,
- compositeappversion,
- name,
- wi.Metadata.Name)
- if err != nil {
- return pkgerrors.Wrapf(err,
- "Error getting Workload Interface Intents for Workload Intent %v under Network Control Intent %v for %v/%v%v not found",
- wi.Metadata.Name, name, project, compositeapp, compositeappversion)
- }
- if len(wifs) == 0 {
- log.Warn("No interface intents provided for workload intent", log.Fields{
- "project": project,
- "composite app": compositeapp,
- "composite app version": compositeappversion,
- "network control intent": name,
- "workload intent": wi.Metadata.Name,
- })
- continue
- }
-
- // Get all clusters for the current App from the AppContext
- clusters, err := context.GetClusterNames(wi.Spec.AppName)
- for _, c := range clusters {
- rh, err := context.GetResourceHandle(wi.Spec.AppName, c,
- strings.Join([]string{wi.Spec.WorkloadResource, wi.Spec.Type}, "+"))
- if err != nil {
- log.Warn("App Context resource handle not found", log.Fields{
- "project": project,
- "composite app": compositeapp,
- "composite app version": compositeappversion,
- "network control intent": name,
- "workload name": wi.Metadata.Name,
- "app": wi.Spec.AppName,
- "resource": wi.Spec.WorkloadResource,
- "resource type": wi.Spec.Type,
- })
- continue
- }
- r, err := context.GetValue(rh)
- if err != nil {
- log.Error("Error retrieving resource from App Context", log.Fields{
- "error": err,
- "resource handle": rh,
- })
- }
-
- // Unmarshal resource to K8S object
- robj, err := runtime.Decode(scheme.Codecs.UniversalDeserializer(), []byte(r.(string)))
-
- // Add network annotation to object
- netAnnot := nettypes.NetworkSelectionElement{
- Name: "ovn-networkobj",
- Namespace: "default",
- }
- AddNetworkAnnotation(robj, netAnnot)
-
- // Add nfn interface annotations to object
- var newNfnIfs []WorkloadIfIntentSpec
- for _, i := range wifs {
- newNfnIfs = append(newNfnIfs, i.Spec)
- }
- AddNfnAnnotation(robj, newNfnIfs)
-
- // Marshal object back to yaml format (via json - seems to eliminate most clutter)
- j, err := json.Marshal(robj)
- if err != nil {
- log.Error("Error marshalling resource to JSON", log.Fields{
- "error": err,
- })
- continue
- }
- y, err := jyaml.JSONToYAML(j)
- if err != nil {
- log.Error("Error marshalling resource to YAML", log.Fields{
- "error": err,
- })
- continue
- }
-
- // Update resource in AppContext
- err = context.UpdateResourceValue(rh, string(y))
- if err != nil {
- log.Error("Network updating app context resource handle", log.Fields{
- "error": err,
- "resource handle": rh,
- })
- }
- }
- }
-
- return nil
-}
diff --git a/src/ovnaction/pkg/module/workloadifintent.go b/src/ovnaction/pkg/module/workloadifintent.go
index 55062564..cea336f6 100644
--- a/src/ovnaction/pkg/module/workloadifintent.go
+++ b/src/ovnaction/pkg/module/workloadifintent.go
@@ -41,6 +41,7 @@ type WorkloadIfIntentKey struct {
Project string `json:"provider"`
CompositeApp string `json:"compositeapp"`
CompositeAppVersion string `json:"compositeappversion"`
+ DigName string `json:"deploymentintentgroup"`
NetControlIntent string `json:"netcontrolintent"`
WorkloadIntent string `json:"workloadintent"`
WorkloadIfIntent string `json:"workloadifintent"`
@@ -48,10 +49,10 @@ type WorkloadIfIntentKey struct {
// Manager is an interface exposing the WorkloadIfIntent functionality
type WorkloadIfIntentManager interface {
- CreateWorkloadIfIntent(wi WorkloadIfIntent, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error)
- GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) (WorkloadIfIntent, error)
- GetWorkloadIfIntents(project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error)
- DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) error
+ CreateWorkloadIfIntent(wi WorkloadIfIntent, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error)
+ GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) (WorkloadIfIntent, error)
+ GetWorkloadIfIntents(project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error)
+ DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) error
}
// WorkloadIfIntentClient implements the Manager
@@ -72,26 +73,27 @@ func NewWorkloadIfIntentClient() *WorkloadIfIntentClient {
}
// CreateWorkloadIfIntent - create a new WorkloadIfIntent
-func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) {
+func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) {
//Construct key and tag to select the entry
key := WorkloadIfIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: workloadintent,
WorkloadIfIntent: wif.Metadata.Name,
}
//Check if the Workload Intent exists
- _, err := NewWorkloadIntentClient().GetWorkloadIntent(workloadintent, project, compositeapp, compositeappversion, netcontrolintent)
+ _, err := NewWorkloadIntentClient().GetWorkloadIntent(workloadintent, project, compositeapp, compositeappversion, dig, netcontrolintent)
if err != nil {
return WorkloadIfIntent{}, pkgerrors.Errorf("Workload Intent %v does not exist", workloadintent)
}
//Check if this WorkloadIfIntent already exists
- _, err = v.GetWorkloadIfIntent(wif.Metadata.Name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent)
+ _, err = v.GetWorkloadIfIntent(wif.Metadata.Name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent)
if err == nil && !exists {
return WorkloadIfIntent{}, pkgerrors.New("WorkloadIfIntent already exists")
}
@@ -105,13 +107,14 @@ func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, pr
}
// GetWorkloadIfIntent returns the WorkloadIfIntent for corresponding name
-func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) {
+func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) {
//Construct key and tag to select the entry
key := WorkloadIfIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: workloadintent,
WorkloadIfIntent: name,
@@ -136,13 +139,14 @@ func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp
}
// GetWorkloadIfIntentList returns all of the WorkloadIfIntent for corresponding name
-func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) {
+func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) {
//Construct key and tag to select the entry
key := WorkloadIfIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: workloadintent,
WorkloadIfIntent: "",
@@ -167,13 +171,14 @@ func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, com
}
// Delete the WorkloadIfIntent from database
-func (v *WorkloadIfIntentClient) DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) error {
+func (v *WorkloadIfIntentClient) DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) error {
//Construct key and tag to select the entry
key := WorkloadIfIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: workloadintent,
WorkloadIfIntent: name,
diff --git a/src/ovnaction/pkg/module/workloadintent.go b/src/ovnaction/pkg/module/workloadintent.go
index e6916954..b1ca9d02 100644
--- a/src/ovnaction/pkg/module/workloadintent.go
+++ b/src/ovnaction/pkg/module/workloadintent.go
@@ -39,16 +39,17 @@ type WorkloadIntentKey struct {
Project string `json:"provider"`
CompositeApp string `json:"compositeapp"`
CompositeAppVersion string `json:"compositeappversion"`
+ DigName string `json:"deploymentintentgroup"`
NetControlIntent string `json:"netcontrolintent"`
WorkloadIntent string `json:"workloadintent"`
}
// Manager is an interface exposing the WorkloadIntent functionality
type WorkloadIntentManager interface {
- CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, netcontrolintent string, exists bool) (WorkloadIntent, error)
- GetWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) (WorkloadIntent, error)
- GetWorkloadIntents(project, compositeapp, compositeappversion, netcontrolintent string) ([]WorkloadIntent, error)
- DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) error
+ CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, dig, netcontrolintent string, exists bool) (WorkloadIntent, error)
+ GetWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) (WorkloadIntent, error)
+ GetWorkloadIntents(project, compositeapp, compositeappversion, dig, netcontrolintent string) ([]WorkloadIntent, error)
+ DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) error
}
// WorkloadIntentClient implements the Manager
@@ -69,25 +70,26 @@ func NewWorkloadIntentClient() *WorkloadIntentClient {
}
// CreateWorkloadIntent - create a new WorkloadIntent
-func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, netcontrolintent string, exists bool) (WorkloadIntent, error) {
+func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, dig, netcontrolintent string, exists bool) (WorkloadIntent, error) {
//Construct key and tag to select the entry
key := WorkloadIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: wi.Metadata.Name,
}
//Check if the Network Control Intent exists
- _, err := NewNetControlIntentClient().GetNetControlIntent(netcontrolintent, project, compositeapp, compositeappversion)
+ _, err := NewNetControlIntentClient().GetNetControlIntent(netcontrolintent, project, compositeapp, compositeappversion, dig)
if err != nil {
return WorkloadIntent{}, pkgerrors.Errorf("Network Control Intent %v does not exist", netcontrolintent)
}
//Check if this WorkloadIntent already exists
- _, err = v.GetWorkloadIntent(wi.Metadata.Name, project, compositeapp, compositeappversion, netcontrolintent)
+ _, err = v.GetWorkloadIntent(wi.Metadata.Name, project, compositeapp, compositeappversion, dig, netcontrolintent)
if err == nil && !exists {
return WorkloadIntent{}, pkgerrors.New("WorkloadIntent already exists")
}
@@ -101,13 +103,14 @@ func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project,
}
// GetWorkloadIntent returns the WorkloadIntent for corresponding name
-func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) (WorkloadIntent, error) {
+func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) (WorkloadIntent, error) {
//Construct key and tag to select the entry
key := WorkloadIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: name,
}
@@ -131,13 +134,14 @@ func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, co
}
// GetWorkloadIntentList returns all of the WorkloadIntent for corresponding name
-func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, compositeappversion, netcontrolintent string) ([]WorkloadIntent, error) {
+func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, compositeappversion, dig, netcontrolintent string) ([]WorkloadIntent, error) {
//Construct key and tag to select the entry
key := WorkloadIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: "",
}
@@ -161,13 +165,14 @@ func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, composi
}
// Delete the WorkloadIntent from database
-func (v *WorkloadIntentClient) DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) error {
+func (v *WorkloadIntentClient) DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) error {
//Construct key and tag to select the entry
key := WorkloadIntentKey{
Project: project,
CompositeApp: compositeapp,
CompositeAppVersion: compositeappversion,
+ DigName: dig,
NetControlIntent: netcontrolintent,
WorkloadIntent: name,
}
diff --git a/src/tools/emcoctl/cmd/utils.go b/src/tools/emcoctl/cmd/utils.go
index d266a00f..5e063d12 100644
--- a/src/tools/emcoctl/cmd/utils.go
+++ b/src/tools/emcoctl/cmd/utils.go
@@ -332,7 +332,7 @@ func GetURL(anchor string) (string, error) {
baseUrl = GetDcmURL()
break
}
- if len(s) >= 6 && s[5] == "network-controller-intent" {
+ if len(s) >= 8 && s[7] == "network-controller-intent" {
baseUrl = GetOvnactionURL()
break
}
diff --git a/src/tools/emcoctl/examples/test.yaml b/src/tools/emcoctl/examples/test.yaml
index e54ff36e..f660f748 100644
--- a/src/tools/emcoctl/examples/test.yaml
+++ b/src/tools/emcoctl/examples/test.yaml
@@ -8,8 +8,8 @@ metadata :
userData1: test1
userData2: test2
spec:
- host: localhost
- port: 9031
+ host: rsync
+ port: 9041
---
#creating cluster provider
@@ -33,7 +33,7 @@ metadata :
userData1: test1
userData2: test2
file:
- /home/otc/.kube/config
+ /home/vagrant/.kube/config
---
#Add label cluster
@@ -137,23 +137,51 @@ file:
---
+#create deployment intent group
+version: emco/v2
+resourceContext:
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups
+metadata :
+ name: collection-deployment-intent-group
+ description: "description"
+ userData1: test1
+ userData2: test2
+spec:
+ profile: collection-composite-profile
+ version: r1
+ logical-cloud: NA
+ override-values: []
+
+---
+#create intent in deployment intent group
+version: emco/v2
+resourceContext:
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups/collection-deployment-intent-group/intents
+metadata :
+ name: collection-deployment-intent
+ description: "description"
+ userData1: test1
+ userData2: test2
+spec:
+ intent:
+ genericPlacementIntent: collection-placement-intent
+
+---
#create the generic placement intent
version: emco/v2
resourceContext:
- anchor: projects/proj1/composite-apps/collection-composite-app/v1/generic-placement-intents
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups/collection-deployment-intent-group/generic-placement-intents
metadata :
name: collection-placement-intent
description: "description for app"
userData1: test1
userData2: test2
-spec:
- logical-cloud: NA
---
#add the prometheus app placement intent to the generic placement intent
version: emco/v2
resourceContext:
- anchor: projects/proj1/composite-apps/collection-composite-app/v1/generic-placement-intents/collection-placement-intent/app-intents
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups/collection-deployment-intent-group/generic-placement-intents/collection-placement-intent/app-intents
metadata:
name: prometheus-placement-intent
description: description of placement_intent
@@ -169,7 +197,7 @@ spec:
#add the prometheus app placement intent to the generic placement intent
version: emco/v2
resourceContext:
- anchor: projects/proj1/composite-apps/collection-composite-app/v1/generic-placement-intents/collection-placement-intent/app-intents
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups/collection-deployment-intent-group/generic-placement-intents/collection-placement-intent/app-intents
metadata:
name: collectd-placement-intent
description: description of placement_intent
@@ -183,35 +211,6 @@ spec:
cluster-label-name: edge-cluster
---
-#create deployment intent group
-version: emco/v2
-resourceContext:
- anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups
-metadata :
- name: collection-deployment-intent-group
- description: "description"
- userData1: test1
- userData2: test2
-spec:
- profile: collection-composite-profile
- version: r1
- override-values: []
-
----
-#create intent in deployment intent group
-version: emco/v2
-resourceContext:
- anchor: projects/proj1/composite-apps/collection-composite-app/v1/deployment-intent-groups/collection-deployment-intent-group/intents
-metadata :
- name: collection-deployment-intent
- description: "description"
- userData1: test1
- userData2: test2
-spec:
- intent:
- genericPlacementIntent: collection-placement-intent
-
----
#Approve
version: emco/v2
resourceContext:
diff --git a/src/tools/emcoctl/examples/vfw.yaml b/src/tools/emcoctl/examples/vfw.yaml
index c84a1bab..251c892d 100644
--- a/src/tools/emcoctl/examples/vfw.yaml
+++ b/src/tools/emcoctl/examples/vfw.yaml
@@ -3,7 +3,7 @@ version: emco/v2
resourceContext:
anchor: controllers
metadata :
- name: rsync
+ name: rsync
spec:
host: "192.168.121.6"
port: 30546
@@ -14,10 +14,10 @@ version: emco/v2
resourceContext:
anchor: controllers
metadata :
- name: ovnaction
+ name: ovnaction
spec:
- host: "192.168.121.6"
- port: 32259
+ host: "ovnaction"
+ port: 9053
type: "action"
priority: 1
@@ -28,7 +28,7 @@ version: emco/v2
resourceContext:
anchor: cluster-providers
metadata :
- name: vfw-cluster-provider
+ name: vfw-cluster-provider
---
#creating cluster
@@ -36,7 +36,7 @@ version: emco/v2
resourceContext:
anchor: cluster-providers/vfw-cluster-provider/clusters
metadata :
- name: edge01
+ name: edge01
file:
/home/otc/.kube/config
@@ -65,7 +65,7 @@ version: emco/v2
resourceContext:
anchor: cluster-providers/vfw-cluster-provider/clusters/edge01/networks
metadata:
- name: emco-unprotected-net
+ name: unprotected-private-net
spec:
cniType: ovn4nfv
ipv4Subnets:
@@ -184,20 +184,52 @@ file:
/opt/csar/cb009bfe-bbee-11e8-9766-525400435678/profile.tar.gz
---
-#create the generic placement intent
+#create deployment intent group
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/generic-placement-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups
metadata :
- name: fw-placement-intent
+ name: vfw_deployment_intent_group
spec:
+ profile: vfw_composite-profile
+ version: r1
logical-cloud: NA
+ override-values:
+ - app-name: packetgen
+ values:
+ ".Values.service.ports.nodePort": '30888'
+ - app-name: firewall
+ values:
+ ".Values.global.dcaeCollectorIp": 1.2.3.4
+ ".Values.global.dcaeCollectorPort": '8888'
+ - app-name: sink
+ values:
+ ".Values.service.ports.nodePort": '30677'
+
+---
+version: emco/v2
+resourceContext:
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/intents
+metadata :
+ name: fw-deployment-intent
+spec:
+ intent:
+ genericPlacementIntent: fw-placement-intent
+ ovnaction: vfw_ovnaction_intent
+
+---
+#create the generic placement intent
+version: emco/v2
+resourceContext:
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/generic-placement-intents
+metadata :
+ name: fw-placement-intent
---
#add the packetgen app placement intent to the generic placement intent
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/generic-placement-intents/fw-placement-intent/app-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/generic-placement-intents/fw-placement-intent/app-intents
metadata:
name: packetgen-placement-intent
spec:
@@ -210,7 +242,7 @@ spec:
#add the firewall app placement intent to the generic placement intent
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/generic-placement-intents/fw-placement-intent/app-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/generic-placement-intents/fw-placement-intent/app-intents
metadata:
name: firewall-placement-intent
spec:
@@ -224,7 +256,7 @@ spec:
#add the sink app placement intent to the generic placement intent
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/generic-placement-intents/fw-placement-intent/app-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/generic-placement-intents/fw-placement-intent/app-intents
metadata:
name: sink-placement-intent
spec:
@@ -235,20 +267,20 @@ spec:
cluster-label-name: LabelA
---
-#creating cluster provider
+#creating network intents
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent
metadata :
- name: vfw_ovnaction_intent
+ name: vfw_ovnaction_intent
---
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents
metadata :
- name: packetgen_workload_intent
+ name: packetgen_workload_intent
spec:
application-name: packetgen
workload-resource: r1-packetgen
@@ -258,9 +290,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents
metadata :
- name: firewall_workload_intent
+ name: firewall_workload_intent
spec:
application-name: firewall
workload-resource: r1-firewall
@@ -270,9 +302,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents
metadata :
- name: sink_workload_intent
+ name: sink_workload_intent
spec:
application-name: sink
workload-resource: r1-sink
@@ -282,9 +314,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/packetgen_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/packetgen_workload_intent/interfaces
metadata :
- name: packetgen_unprotected_if
+ name: packetgen_unprotected_if
spec:
interface: eth1
name: unprotected-private-net
@@ -295,9 +327,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/packetgen_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/packetgen_workload_intent/interfaces
metadata :
- name: packetgen_emco_if
+ name: packetgen_emco_if
spec:
interface: eth2
name: emco-private-net
@@ -308,9 +340,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/firewall_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/firewall_workload_intent/interfaces
metadata :
- name: firewall_emco_if
+ name: firewall_emco_if
spec:
interface: eth3
name: emco-private-net
@@ -321,9 +353,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/firewall_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/firewall_workload_intent/interfaces
metadata :
- name: firewall_unprotected_if
+ name: firewall_unprotected_if
spec:
interface: eth1
name: unprotected-private-net
@@ -334,9 +366,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/firewall_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/firewall_workload_intent/interfaces
metadata :
- name: firewall_protected_if
+ name: firewall_protected_if
spec:
interface: eth2
name: protected-private-net
@@ -347,9 +379,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/sink_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/sink_workload_intent/interfaces
metadata :
- name: sink_protected_if
+ name: sink_protected_if
spec:
interface: eth1
name: protected-private-net
@@ -360,9 +392,9 @@ spec:
#
version: emco/v2
resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/network-controller-intent/vfw_ovnaction_intent/workload-intents/sink_workload_intent/interfaces
+ anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/network-controller-intent/vfw_ovnaction_intent/workload-intents/sink_workload_intent/interfaces
metadata :
- name: sink_emco_if
+ name: sink_emco_if
spec:
interface: eth2
name: emco-private-net
@@ -370,39 +402,6 @@ spec:
ipAddress: 10.10.20.4
---
-#create deployment intent group
-version: emco/v2
-resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups
-metadata :
- name: vfw_deployment_intent_group
-spec:
- profile: vfw_composite-profile
- version: r1
- override-values:
- - app-name: packetgen
- values:
- ".Values.service.ports.nodePort": '30888'
- - app-name: firewall
- values:
- ".Values.global.dcaeCollectorIp": 1.2.3.4
- ".Values.global.dcaeCollectorPort": '8888'
- - app-name: sink
- values:
- ".Values.service.ports.nodePort": '30677'
-
----
-version: emco/v2
-resourceContext:
- anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/intents
-metadata :
- name: fw-deployment-intent
-spec:
- intent:
- genericPlacementIntent: fw-placement-intent
- ovnaction: vfw_ovnaction_intent
-
----
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group/approve