aboutsummaryrefslogtreecommitdiffstats
path: root/src/ovnaction
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2020-10-05 22:45:38 +0000
committerGerrit Code Review <gerrit@onap.org>2020-10-05 22:45:38 +0000
commitbb3df0da7c6eddee2f2fe36a46aa86860fc53f92 (patch)
tree65dacebb91fb6dff900da5df5407d10bcf01184c /src/ovnaction
parent9966f6af186676f38754c64759496eef0a1bc508 (diff)
parent1fc90f15489ae3eafeb5994f5285f09750feae4c (diff)
Merge "Ovnaction and vfw updates for deploy api change"
Diffstat (limited to 'src/ovnaction')
-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
10 files changed, 152 insertions, 283 deletions
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,
}