aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clm/api/clusterhandler.go31
-rw-r--r--src/clm/api/clusterhandler_test.go6
-rw-r--r--src/clm/json-schemas/cluster-kv.json (renamed from src/orchestrator/api/json-schemas/cluster-kv.json)0
-rw-r--r--src/clm/json-schemas/cluster-label.json (renamed from src/orchestrator/api/json-schemas/cluster-label.json)0
-rw-r--r--src/clm/json-schemas/metadata.json (renamed from src/orchestrator/api/json-schemas/metadata.json)0
-rw-r--r--src/ncm/api/networkhandler.go9
-rw-r--r--src/ncm/api/providernethandler.go8
-rw-r--r--src/ncm/json-schemas/provider-network.json (renamed from src/orchestrator/api/json-schemas/provider-network.json)0
-rw-r--r--src/ncm/json-schemas/virtual-network.json (renamed from src/orchestrator/api/json-schemas/virtual-network.json)0
-rw-r--r--src/orchestrator/api/add_intents_handler.go5
-rw-r--r--src/orchestrator/api/app_intent_handler.go5
-rw-r--r--src/orchestrator/api/app_profilehandler.go5
-rw-r--r--src/orchestrator/api/apphandler.go5
-rw-r--r--src/orchestrator/api/composite_app_handler.go5
-rw-r--r--src/orchestrator/api/composite_profilehandler.go5
-rw-r--r--src/orchestrator/api/composite_profilehandler_test.go4
-rw-r--r--src/orchestrator/api/controllerhandler.go5
-rw-r--r--src/orchestrator/api/controllerhandler_test.go4
-rw-r--r--src/orchestrator/api/deployment_intent_groups_handler.go5
-rw-r--r--src/orchestrator/api/generic_placement_intent_handler.go5
-rw-r--r--src/orchestrator/api/projecthandler.go6
-rw-r--r--src/orchestrator/api/projecthandler_test.go4
-rw-r--r--src/orchestrator/json-schemas/composite-app.json (renamed from src/orchestrator/api/json-schemas/composite-app.json)0
-rw-r--r--src/orchestrator/json-schemas/composite-profile.json (renamed from src/orchestrator/api/json-schemas/composite-profile.json)0
-rw-r--r--src/orchestrator/json-schemas/controller.json (renamed from src/orchestrator/api/json-schemas/controller.json)0
-rw-r--r--src/orchestrator/json-schemas/deployment-group-intent.json (renamed from src/orchestrator/api/json-schemas/deployment-group-intent.json)0
-rw-r--r--src/orchestrator/json-schemas/deployment-intent.json (renamed from src/orchestrator/api/json-schemas/deployment-intent.json)0
-rw-r--r--src/orchestrator/json-schemas/generic-placement-intent-app.json (renamed from src/orchestrator/api/json-schemas/generic-placement-intent-app.json)0
-rw-r--r--src/orchestrator/json-schemas/generic-placement-intent.json (renamed from src/orchestrator/api/json-schemas/generic-placement-intent.json)0
-rw-r--r--src/orchestrator/json-schemas/metadata.json37
-rwxr-xr-xsrc/orchestrator/scripts/start-dev.sh2
-rw-r--r--src/ovnaction/api/netcontrolintenthandler.go13
-rw-r--r--src/ovnaction/api/workloadifintenthandler.go8
-rw-r--r--src/ovnaction/api/workloadintenthandler.go8
-rw-r--r--src/ovnaction/json-schemas/metadata.json37
-rw-r--r--src/ovnaction/json-schemas/network-load-interface.json (renamed from src/orchestrator/api/json-schemas/network-load-interface.json)4
-rw-r--r--src/ovnaction/json-schemas/network-workload.json (renamed from src/orchestrator/api/json-schemas/network-workload.json)0
-rw-r--r--src/tools/emcoctl/Readme.md131
-rw-r--r--src/tools/emcoctl/examples/emco-cfg.yaml6
-rw-r--r--src/tools/emcoctl/examples/test.yaml17
-rw-r--r--src/tools/emcoctl/examples/vfw.yaml34
41 files changed, 364 insertions, 50 deletions
diff --git a/src/clm/api/clusterhandler.go b/src/clm/api/clusterhandler.go
index 84dd3230..75fcc561 100644
--- a/src/clm/api/clusterhandler.go
+++ b/src/clm/api/clusterhandler.go
@@ -28,10 +28,16 @@ import (
"net/textproto"
clusterPkg "github.com/onap/multicloud-k8s/src/clm/pkg/cluster"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
"github.com/gorilla/mux"
)
+var cpJSONFile string = "json-schemas/metadata.json"
+var ckvJSONFile string = "json-schemas/cluster-kv.json"
+var clJSONFile string = "json-schemas/cluster-label.json"
+
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type clusterHandler struct {
@@ -55,6 +61,12 @@ func (h clusterHandler) createClusterProviderHandler(w http.ResponseWriter, r *h
return
}
+ err, httpError := validation.ValidateJsonSchemaData(cpJSONFile, p)
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
+
// Name is required.
if p.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
@@ -148,6 +160,12 @@ func (h clusterHandler) createClusterHandler(w http.ResponseWriter, r *http.Requ
return
}
+ err, httpError := validation.ValidateJsonSchemaData(cpJSONFile, p)
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
+
//Read the file section and ignore the header
file, _, err := r.FormFile("file")
if err != nil {
@@ -333,6 +351,12 @@ func (h clusterHandler) createClusterLabelHandler(w http.ResponseWriter, r *http
err := json.NewDecoder(r.Body).Decode(&p)
+ err, httpError := validation.ValidateJsonSchemaData(clJSONFile, p)
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
+
// LabelName is required.
if p.LabelName == "" {
http.Error(w, "Missing label name in POST request", http.StatusBadRequest)
@@ -413,6 +437,13 @@ func (h clusterHandler) createClusterKvPairsHandler(w http.ResponseWriter, r *ht
err := json.NewDecoder(r.Body).Decode(&p)
+ // Verify JSON Body
+ err, httpError := validation.ValidateJsonSchemaData(ckvJSONFile, p)
+ if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+ }
+
// KvPairsName is required.
if p.Metadata.Name == "" {
http.Error(w, "Missing Key Value pair name in POST request", http.StatusBadRequest)
diff --git a/src/clm/api/clusterhandler_test.go b/src/clm/api/clusterhandler_test.go
index 076718df..a866835b 100644
--- a/src/clm/api/clusterhandler_test.go
+++ b/src/clm/api/clusterhandler_test.go
@@ -186,6 +186,12 @@ func (m *mockClusterManager) DeleteClusterKvPairs(provider, clusterName, kvpair
return m.Err
}
+func init() {
+ cpJSONFile = "../json-schemas/metadata.json"
+ ckvJSONFile = "../json-schemas/cluster-kv.json"
+ clJSONFile = "../json-schemas/cluster-label.json"
+}
+
func TestClusterProviderCreateHandler(t *testing.T) {
testCases := []struct {
label string
diff --git a/src/orchestrator/api/json-schemas/cluster-kv.json b/src/clm/json-schemas/cluster-kv.json
index c7013bab..c7013bab 100644
--- a/src/orchestrator/api/json-schemas/cluster-kv.json
+++ b/src/clm/json-schemas/cluster-kv.json
diff --git a/src/orchestrator/api/json-schemas/cluster-label.json b/src/clm/json-schemas/cluster-label.json
index 22267b3d..22267b3d 100644
--- a/src/orchestrator/api/json-schemas/cluster-label.json
+++ b/src/clm/json-schemas/cluster-label.json
diff --git a/src/orchestrator/api/json-schemas/metadata.json b/src/clm/json-schemas/metadata.json
index 960545ee..960545ee 100644
--- a/src/orchestrator/api/json-schemas/metadata.json
+++ b/src/clm/json-schemas/metadata.json
diff --git a/src/ncm/api/networkhandler.go b/src/ncm/api/networkhandler.go
index ed266697..6f305be1 100644
--- a/src/ncm/api/networkhandler.go
+++ b/src/ncm/api/networkhandler.go
@@ -30,6 +30,9 @@ import (
"github.com/gorilla/mux"
)
+var vnJSONFile string = "json-schemas/virtual-network.json"
+
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type networkHandler struct {
@@ -86,6 +89,12 @@ func (h networkHandler) createNetworkHandler(w http.ResponseWriter, r *http.Requ
return
}
+ err, httpError := validation.ValidateJsonSchemaData(vnJSONFile, p)
+if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+}
+
// Name is required.
if p.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
diff --git a/src/ncm/api/providernethandler.go b/src/ncm/api/providernethandler.go
index 66a41a4d..48d5d7ea 100644
--- a/src/ncm/api/providernethandler.go
+++ b/src/ncm/api/providernethandler.go
@@ -31,6 +31,8 @@ import (
"github.com/gorilla/mux"
)
+var pnetJSONFile string = "json-schemas/provider-network.json"
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type providernetHandler struct {
@@ -139,6 +141,12 @@ func (h providernetHandler) createProviderNetHandler(w http.ResponseWriter, r *h
return
}
+ err, httpError := validation.ValidateJsonSchemaData(pnetJSONFile, p)
+if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+}
+
// Name is required.
if p.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
diff --git a/src/orchestrator/api/json-schemas/provider-network.json b/src/ncm/json-schemas/provider-network.json
index 0aef0304..0aef0304 100644
--- a/src/orchestrator/api/json-schemas/provider-network.json
+++ b/src/ncm/json-schemas/provider-network.json
diff --git a/src/orchestrator/api/json-schemas/virtual-network.json b/src/ncm/json-schemas/virtual-network.json
index f2bc9d3d..f2bc9d3d 100644
--- a/src/orchestrator/api/json-schemas/virtual-network.json
+++ b/src/ncm/json-schemas/virtual-network.json
diff --git a/src/orchestrator/api/add_intents_handler.go b/src/orchestrator/api/add_intents_handler.go
index 21a33739..66f3839a 100644
--- a/src/orchestrator/api/add_intents_handler.go
+++ b/src/orchestrator/api/add_intents_handler.go
@@ -27,6 +27,8 @@ import (
"github.com/gorilla/mux"
)
+var addIntentJSONFile string = "json-schemas/deployment-intent.json"
+
type intentHandler struct {
client moduleLib.IntentManager
}
@@ -46,9 +48,8 @@ func (h intentHandler) addIntentHandler(w http.ResponseWriter, r *http.Request)
return
}
- jsonFile := "json-schemas/deployment-intent.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, i)
+ err, httpError := validation.ValidateJsonSchemaData(addIntentJSONFile, i)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/app_intent_handler.go b/src/orchestrator/api/app_intent_handler.go
index a51b9b92..1d48f8a6 100644
--- a/src/orchestrator/api/app_intent_handler.go
+++ b/src/orchestrator/api/app_intent_handler.go
@@ -26,6 +26,8 @@ import (
moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
)
+var appIntentJSONFile string = "json-schemas/generic-placement-intent-app.json"
+
/* Used to store backend implementation objects
Also simplifies mocking for unit testing purposes
*/
@@ -48,9 +50,8 @@ func (h appIntentHandler) createAppIntentHandler(w http.ResponseWriter, r *http.
return
}
- jsonFile := "json-schemas/generic-placement-intent-app.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, a)
+ err, httpError := validation.ValidateJsonSchemaData(appIntentJSONFile, a)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/app_profilehandler.go b/src/orchestrator/api/app_profilehandler.go
index 2fa0f26d..58cd2145 100644
--- a/src/orchestrator/api/app_profilehandler.go
+++ b/src/orchestrator/api/app_profilehandler.go
@@ -34,6 +34,8 @@ import (
pkgerrors "github.com/pkg/errors"
)
+var appProfileJSONFile string = "json-schemas/metadata.json"
+
/* Used to store backend implementation objects
Also simplifies mocking for unit testing purposes
*/
@@ -73,9 +75,8 @@ func (h appProfileHandler) createAppProfileHandler(w http.ResponseWriter, r *htt
return
}
- jsonFile := "json-schemas/metadata.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, ap)
+ err, httpError := validation.ValidateJsonSchemaData(appProfileJSONFile, ap)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/apphandler.go b/src/orchestrator/api/apphandler.go
index 7d901a8f..7429f5c2 100644
--- a/src/orchestrator/api/apphandler.go
+++ b/src/orchestrator/api/apphandler.go
@@ -33,6 +33,8 @@ import (
"github.com/gorilla/mux"
)
+var appJSONFile string = "json-schemas/metadata.json"
+
// appHandler to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type appHandler struct {
@@ -70,9 +72,8 @@ func (h appHandler) createAppHandler(w http.ResponseWriter, r *http.Request) {
return
}
- jsonFile := "json-schemas/metadata.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, a)
+ err, httpError := validation.ValidateJsonSchemaData(appJSONFile, a)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/composite_app_handler.go b/src/orchestrator/api/composite_app_handler.go
index 1e69c353..d531b28d 100644
--- a/src/orchestrator/api/composite_app_handler.go
+++ b/src/orchestrator/api/composite_app_handler.go
@@ -26,6 +26,8 @@ import (
moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
)
+var caJSONFile string = "json-schemas/composite-app.json"
+
// compositeAppHandler to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type compositeAppHandler struct {
@@ -47,9 +49,8 @@ func (h compositeAppHandler) createHandler(w http.ResponseWriter, r *http.Reques
http.Error(w, err.Error(), http.StatusUnprocessableEntity)
return
}
- jsonFile := "json-schemas/composite-app.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, c)
+ err, httpError := validation.ValidateJsonSchemaData(caJSONFile, c)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/composite_profilehandler.go b/src/orchestrator/api/composite_profilehandler.go
index 5a3fb19c..de1c8f2d 100644
--- a/src/orchestrator/api/composite_profilehandler.go
+++ b/src/orchestrator/api/composite_profilehandler.go
@@ -27,6 +27,8 @@ import (
"github.com/gorilla/mux"
)
+var caprofileJSONFile string = "json-schemas/metadata.json"
+
/* Used to store backend implementation objects
Also simplifies mocking for unit testing purposes
*/
@@ -49,9 +51,8 @@ func (h compositeProfileHandler) createHandler(w http.ResponseWriter, r *http.Re
return
}
- jsonFile := "json-schemas/metadata.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, cpf)
+ err, httpError := validation.ValidateJsonSchemaData(caprofileJSONFile, cpf)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/composite_profilehandler_test.go b/src/orchestrator/api/composite_profilehandler_test.go
index ec3ec24b..d1e34230 100644
--- a/src/orchestrator/api/composite_profilehandler_test.go
+++ b/src/orchestrator/api/composite_profilehandler_test.go
@@ -70,6 +70,10 @@ func (m *mockCompositeProfileManager) DeleteCompositeProfile(name string, projec
return m.Err
}
+func init() {
+ caprofileJSONFile = "../json-schemas/metadata.json"
+}
+
func Test_compositeProfileHandler_createHandler(t *testing.T) {
testCases := []struct {
label string
diff --git a/src/orchestrator/api/controllerhandler.go b/src/orchestrator/api/controllerhandler.go
index be300d89..418aa70f 100644
--- a/src/orchestrator/api/controllerhandler.go
+++ b/src/orchestrator/api/controllerhandler.go
@@ -28,6 +28,8 @@ import (
pkgerrors "github.com/pkg/errors"
)
+var controllerJSONFile string = "json-schemas/controller.json"
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type controllerHandler struct {
@@ -87,9 +89,8 @@ func (h controllerHandler) createHandler(w http.ResponseWriter, r *http.Request)
return
}
- jsonFile := "json-schemas/controller.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, m)
+ err, httpError := validation.ValidateJsonSchemaData(controllerJSONFile, m)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/controllerhandler_test.go b/src/orchestrator/api/controllerhandler_test.go
index 6cbb2a79..ecc2d1f7 100644
--- a/src/orchestrator/api/controllerhandler_test.go
+++ b/src/orchestrator/api/controllerhandler_test.go
@@ -73,6 +73,10 @@ func (m *mockControllerManager) InitControllers() {
return
}
+func init() {
+ controllerJSONFile = "../json-schemas/controller.json"
+}
+
func TestControllerCreateHandler(t *testing.T) {
testCases := []struct {
label string
diff --git a/src/orchestrator/api/deployment_intent_groups_handler.go b/src/orchestrator/api/deployment_intent_groups_handler.go
index 76dea14c..b9466a2c 100644
--- a/src/orchestrator/api/deployment_intent_groups_handler.go
+++ b/src/orchestrator/api/deployment_intent_groups_handler.go
@@ -27,6 +27,8 @@ import (
"github.com/gorilla/mux"
)
+var dpiJSONFile string = "json-schemas/deployment-group-intent.json"
+
/* Used to store backend implementation objects
Also simplifies mocking for unit testing purposes
*/
@@ -49,9 +51,8 @@ func (h deploymentIntentGroupHandler) createDeploymentIntentGroupHandler(w http.
return
}
- jsonFile := "json-schemas/deployment-group-intent.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, d)
+ err, httpError := validation.ValidateJsonSchemaData(dpiJSONFile, d)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/generic_placement_intent_handler.go b/src/orchestrator/api/generic_placement_intent_handler.go
index 16f1f234..2415ae2c 100644
--- a/src/orchestrator/api/generic_placement_intent_handler.go
+++ b/src/orchestrator/api/generic_placement_intent_handler.go
@@ -27,6 +27,8 @@ import (
"github.com/gorilla/mux"
)
+var gpiJSONFile string = "json-schemas/generic-placement-intent.json"
+
/* Used to store backend implementation objects
Also simplifies mocking for unit testing purposes
*/
@@ -49,9 +51,8 @@ func (h genericPlacementIntentHandler) createGenericPlacementIntentHandler(w htt
return
}
- jsonFile := "json-schemas/generic-placement-intent.json"
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, g)
+ err, httpError := validation.ValidateJsonSchemaData(gpiJSONFile, g)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/projecthandler.go b/src/orchestrator/api/projecthandler.go
index f130d283..07cd79ce 100644
--- a/src/orchestrator/api/projecthandler.go
+++ b/src/orchestrator/api/projecthandler.go
@@ -26,6 +26,8 @@ import (
moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
)
+var projectJSONFile string = "json-schemas/metadata.json"
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type projectHandler struct {
@@ -47,9 +49,9 @@ func (h projectHandler) createHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusUnprocessableEntity)
return
}
- jsonFile := "json-schemas/metadata.json"
+
// Verify JSON Body
- err, httpError := validation.ValidateJsonSchemaData(jsonFile, p)
+ err, httpError := validation.ValidateJsonSchemaData(projectJSONFile, p)
if err != nil {
http.Error(w, err.Error(), httpError)
return
diff --git a/src/orchestrator/api/projecthandler_test.go b/src/orchestrator/api/projecthandler_test.go
index ef5fdf07..5e88bab9 100644
--- a/src/orchestrator/api/projecthandler_test.go
+++ b/src/orchestrator/api/projecthandler_test.go
@@ -64,6 +64,10 @@ func (m *mockProjectManager) GetAllProjects() ([]moduleLib.Project, error) {
return []moduleLib.Project{}, m.Err
}
+func init() {
+ projectJSONFile = "../json-schemas/metadata.json"
+}
+
func TestProjectCreateHandler(t *testing.T) {
testCases := []struct {
label string
diff --git a/src/orchestrator/api/json-schemas/composite-app.json b/src/orchestrator/json-schemas/composite-app.json
index 3f976831..3f976831 100644
--- a/src/orchestrator/api/json-schemas/composite-app.json
+++ b/src/orchestrator/json-schemas/composite-app.json
diff --git a/src/orchestrator/api/json-schemas/composite-profile.json b/src/orchestrator/json-schemas/composite-profile.json
index e404a64c..e404a64c 100644
--- a/src/orchestrator/api/json-schemas/composite-profile.json
+++ b/src/orchestrator/json-schemas/composite-profile.json
diff --git a/src/orchestrator/api/json-schemas/controller.json b/src/orchestrator/json-schemas/controller.json
index 3263ff21..3263ff21 100644
--- a/src/orchestrator/api/json-schemas/controller.json
+++ b/src/orchestrator/json-schemas/controller.json
diff --git a/src/orchestrator/api/json-schemas/deployment-group-intent.json b/src/orchestrator/json-schemas/deployment-group-intent.json
index 2740747b..2740747b 100644
--- a/src/orchestrator/api/json-schemas/deployment-group-intent.json
+++ b/src/orchestrator/json-schemas/deployment-group-intent.json
diff --git a/src/orchestrator/api/json-schemas/deployment-intent.json b/src/orchestrator/json-schemas/deployment-intent.json
index 6bdc0b43..6bdc0b43 100644
--- a/src/orchestrator/api/json-schemas/deployment-intent.json
+++ b/src/orchestrator/json-schemas/deployment-intent.json
diff --git a/src/orchestrator/api/json-schemas/generic-placement-intent-app.json b/src/orchestrator/json-schemas/generic-placement-intent-app.json
index 0b6447c2..0b6447c2 100644
--- a/src/orchestrator/api/json-schemas/generic-placement-intent-app.json
+++ b/src/orchestrator/json-schemas/generic-placement-intent-app.json
diff --git a/src/orchestrator/api/json-schemas/generic-placement-intent.json b/src/orchestrator/json-schemas/generic-placement-intent.json
index 44df9087..44df9087 100644
--- a/src/orchestrator/api/json-schemas/generic-placement-intent.json
+++ b/src/orchestrator/json-schemas/generic-placement-intent.json
diff --git a/src/orchestrator/json-schemas/metadata.json b/src/orchestrator/json-schemas/metadata.json
new file mode 100644
index 00000000..960545ee
--- /dev/null
+++ b/src/orchestrator/json-schemas/metadata.json
@@ -0,0 +1,37 @@
+
+{
+ "$schema": "http://json-schema.org/schema#",
+ "type": "object",
+ "properties": {
+ "metadata": {
+ "required": ["name"],
+ "properties": {
+ "userData2": {
+ "description": "User relevant data for the resource",
+ "type": "string",
+ "example": "Some more data",
+ "maxLength": 512
+ },
+ "userData1": {
+ "description": "User relevant data for the resource",
+ "type": "string",
+ "example": "Some data",
+ "maxLength": 512
+ },
+ "name": {
+ "description": "Name of the resource",
+ "type": "string",
+ "example": "ResName",
+ "maxLength": 128,
+ "pattern": "[-_0-9a-zA-Z]+$"
+ },
+ "description": {
+ "description": "Description for the resource",
+ "type": "string",
+ "example": "Resource description",
+ "maxLength": 1024
+ }
+ }
+ }
+ }
+ } \ No newline at end of file
diff --git a/src/orchestrator/scripts/start-dev.sh b/src/orchestrator/scripts/start-dev.sh
index 003773be..ad21dc47 100755
--- a/src/orchestrator/scripts/start-dev.sh
+++ b/src/orchestrator/scripts/start-dev.sh
@@ -28,6 +28,6 @@ echo "Compiling source code"
pushd $opath
generate_config
make all
-cp -r $k8s_path/src/orchestrator/api/json-schemas $k8s_path/src/orchestrator
+cp -r $k8s_path/src/orchestrator/json-schemas $k8s_path/src/orchestrator
./orchestrator
popd
diff --git a/src/ovnaction/api/netcontrolintenthandler.go b/src/ovnaction/api/netcontrolintenthandler.go
index fe2109b6..631f13c4 100644
--- a/src/ovnaction/api/netcontrolintenthandler.go
+++ b/src/ovnaction/api/netcontrolintenthandler.go
@@ -24,10 +24,16 @@ import (
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 {
@@ -65,6 +71,13 @@ func (h netcontrolintentHandler) createHandler(w http.ResponseWriter, r *http.Re
return
}
+ err, httpError := validation.ValidateJsonSchemaData(netCntIntJSONFile, nci)
+if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+}
+
+
// Name is required.
if nci.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
diff --git a/src/ovnaction/api/workloadifintenthandler.go b/src/ovnaction/api/workloadifintenthandler.go
index cf8f45bf..e7be6317 100644
--- a/src/ovnaction/api/workloadifintenthandler.go
+++ b/src/ovnaction/api/workloadifintenthandler.go
@@ -29,6 +29,8 @@ import (
"github.com/gorilla/mux"
)
+var netIfJSONFile string = "json-schemas/network-load-interface.json"
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type workloadifintentHandler struct {
@@ -102,6 +104,12 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re
return
}
+ err, httpError := validation.ValidateJsonSchemaData(netIfJSONFile, wif)
+if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+}
+
// Name is required.
if wif.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
diff --git a/src/ovnaction/api/workloadintenthandler.go b/src/ovnaction/api/workloadintenthandler.go
index cf7ecebc..acf4edbb 100644
--- a/src/ovnaction/api/workloadintenthandler.go
+++ b/src/ovnaction/api/workloadintenthandler.go
@@ -29,6 +29,8 @@ import (
"github.com/gorilla/mux"
)
+var workloadIntJSONFile string = "json-schemas/network-workload.json"
+
// Used to store backend implementations objects
// Also simplifies mocking for unit testing purposes
type workloadintentHandler struct {
@@ -82,6 +84,12 @@ func (h workloadintentHandler) createHandler(w http.ResponseWriter, r *http.Requ
return
}
+ err, httpError := validation.ValidateJsonSchemaData(workloadIntJSONFile, wi)
+if err != nil {
+ http.Error(w, err.Error(), httpError)
+ return
+}
+
// Name is required.
if wi.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
diff --git a/src/ovnaction/json-schemas/metadata.json b/src/ovnaction/json-schemas/metadata.json
new file mode 100644
index 00000000..960545ee
--- /dev/null
+++ b/src/ovnaction/json-schemas/metadata.json
@@ -0,0 +1,37 @@
+
+{
+ "$schema": "http://json-schema.org/schema#",
+ "type": "object",
+ "properties": {
+ "metadata": {
+ "required": ["name"],
+ "properties": {
+ "userData2": {
+ "description": "User relevant data for the resource",
+ "type": "string",
+ "example": "Some more data",
+ "maxLength": 512
+ },
+ "userData1": {
+ "description": "User relevant data for the resource",
+ "type": "string",
+ "example": "Some data",
+ "maxLength": 512
+ },
+ "name": {
+ "description": "Name of the resource",
+ "type": "string",
+ "example": "ResName",
+ "maxLength": 128,
+ "pattern": "[-_0-9a-zA-Z]+$"
+ },
+ "description": {
+ "description": "Description for the resource",
+ "type": "string",
+ "example": "Resource description",
+ "maxLength": 1024
+ }
+ }
+ }
+ }
+ } \ No newline at end of file
diff --git a/src/orchestrator/api/json-schemas/network-load-interface.json b/src/ovnaction/json-schemas/network-load-interface.json
index dd5b40d1..896f4f2b 100644
--- a/src/orchestrator/api/json-schemas/network-load-interface.json
+++ b/src/ovnaction/json-schemas/network-load-interface.json
@@ -37,8 +37,8 @@
},
"defaultGateway": {
"description": "Is this interface default gateway",
- "type": "boolean",
- "example": false,
+ "type": "string",
+ "example": "false",
"maxLength": 128
}
}
diff --git a/src/orchestrator/api/json-schemas/network-workload.json b/src/ovnaction/json-schemas/network-workload.json
index c5dc14cb..c5dc14cb 100644
--- a/src/orchestrator/api/json-schemas/network-workload.json
+++ b/src/ovnaction/json-schemas/network-workload.json
diff --git a/src/tools/emcoctl/Readme.md b/src/tools/emcoctl/Readme.md
index ecbcf4de..105398c1 100644
--- a/src/tools/emcoctl/Readme.md
+++ b/src/tools/emcoctl/Readme.md
@@ -84,3 +84,134 @@ For deleting one resource anchor can be provided as an arguement
`$ emcoctl delete <anchor>`
`$ emcoctl delete projects/testvfw/composite-apps/compositevfw/v1/deployment-intent-groups/vfw_deployment_intent_group`
+
+
+## Using helm charts through emcoctl
+
+When you need to use emcoctl for deploying helm
+charts the following steps are required.
+
+1. Make sure that the composite app which you are planning to deploy, the tree structure is as below
+
+```
+
+$ tree collection/app1/
+collection/app1/
+├── helm
+│   └── collectd
+│   ├── Chart.yaml
+│   ├── resources
+│   │   └── collectd.conf
+│   ├── templates
+│   │   ├── configmap.yaml
+│   │   ├── daemonset.yaml
+│   │   ├── _helpers.tpl
+│   │   ├── NOTES.txt
+│   │   └── service.yaml
+│   └── values.yaml
+└── profile
+ ├── manifest.yaml
+ └── override_values.yaml
+
+5 directories, 10 files
+
+$ tree collection/m3db/
+collection/m3db/
+├── helm
+│   └── m3db
+│   ├── Chart.yaml
+│   ├── del.yaml
+│   ├── templates
+│   │   └── m3dbcluster.yaml
+│   └── values.yaml
+└── profile
+ ├── manifest.yaml
+ └── override_values.yaml
+
+4 directories, 6 files
+
+```
+
+### NOTE
+```
+* In the above example, we have a composite app : collection
+The collection composite-app shown has two apps : app1(collectd)
+and m3db
+* Each app has two dirs : a. HELM and b. PROFILE.
+* Helm dir shall have the real helm charts of the app.
+* profile shall have the two files - manifest.yaml and override_values.yaml for creating the customized profile.
+```
+
+### Commands for making the tar files from helm.
+
+```
+ tar -czf collectd.tar.gz -C $test_folder/vnfs/comp-app/collection/app1/helm .
+ tar -czf collectd_profile.tar.gz -C $test_folder/vnfs/comp-app/collection/app1/profile .
+ ----------------------------------------
+ tar -czf m3db.tar.gz -C $test_folder/vnfs/comp-app/collection/m3db/helm .
+ tar -czf m3db_profile.tar.gz -C $test_folder/vnfs/comp-app/collection/m3db/profile .
+```
+
+Once you have generated the tar files, you need to give the path in file which you are applying using the emcoctl. For eg:
+
+```
+#adding collectd app to the composite app
+version: emco/v2
+resourceContext:
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/apps
+metadata :
+ name: collectd
+ description: "description for app"
+ userData1: test1
+ userData2: test2
+file:
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/collectd.tar.gz
+
+```
+
+```
+#adding collectd app profiles to the composite profile
+version: emco/v2
+resourceContext:
+ anchor: projects/proj1/composite-apps/collection-composite-app/v1/composite-profiles/collection-composite-profile/profiles
+metadata :
+ name: collectd-profile
+ description: test
+ userData1: test1
+ userData2: test2
+spec:
+ app-name: collectd
+file:
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/collectd_profile.tar.gz
+
+```
+
+### Running the emcoctl
+
+```
+* Make sure that the emcoctl is build.You can build it by issuing the 'make' command.
+Dir : $MULTICLOUD-K8s_HOME/src/tools/emcoctl
+```
+* Then run the emcoctl by command:
+```
+./emcoctl --config ./examples/emco-cfg.yaml apply -f ./examples/test.yaml
+
+```
+
+Here, emco-cfg.yaml contains the config/port details of each of the microservices you are using.
+A sample configuration is :
+
+```
+ orchestrator:
+ host: localhost
+ port: 9015
+ clm:
+ host: localhost
+ port: 9019
+ ncm:
+ host: localhost
+ port: 9016
+ ovnaction:
+ host: localhost
+ port: 9051
+```
diff --git a/src/tools/emcoctl/examples/emco-cfg.yaml b/src/tools/emcoctl/examples/emco-cfg.yaml
index c1703def..a7e284ab 100644
--- a/src/tools/emcoctl/examples/emco-cfg.yaml
+++ b/src/tools/emcoctl/examples/emco-cfg.yaml
@@ -3,10 +3,10 @@
port: 9015
clm:
host: localhost
- port: 9061
+ port: 9019
ncm:
host: localhost
- port: 9031
+ port: 9016
ovnaction:
host: localhost
- port: 9051 \ No newline at end of file
+ port: 9018
diff --git a/src/tools/emcoctl/examples/test.yaml b/src/tools/emcoctl/examples/test.yaml
index 924f7e55..e54ff36e 100644
--- a/src/tools/emcoctl/examples/test.yaml
+++ b/src/tools/emcoctl/examples/test.yaml
@@ -33,7 +33,7 @@ metadata :
userData1: test1
userData2: test2
file:
- kubeconfig
+ /home/otc/.kube/config
---
#Add label cluster
@@ -77,7 +77,7 @@ metadata :
userData1: test1
userData2: test2
file:
- prometheus-operator.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/prometheus-operator.tar.gz
---
#adding collectd app to the composite app
@@ -90,7 +90,7 @@ metadata :
userData1: test1
userData2: test2
file:
- collectd.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/collectd.tar.gz
---
#creating collection composite profile entry
@@ -116,7 +116,9 @@ metadata :
spec:
app-name: prometheus-operator
file:
- prometheus-operator_profile.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/prometheus-operator_profile.tar.gz
+
+
---
#adding collectd app profiles to the composite profile
@@ -131,7 +133,8 @@ metadata :
spec:
app-name: collectd
file:
- collectd_profile.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/collectd_profile.tar.gz
+
---
#create the generic placement intent
@@ -160,7 +163,7 @@ spec:
app-name: prometheus-operator
intent:
allOf:
- - provider-name: cluster-provider1
+ - provider-name: provider1
cluster-label-name: edge-cluster
---
#add the prometheus app placement intent to the generic placement intent
@@ -176,7 +179,7 @@ spec:
app-name: collectd
intent:
allOf:
- - provider-name: cluster-provider1
+ - provider-name: provider1
cluster-label-name: edge-cluster
---
diff --git a/src/tools/emcoctl/examples/vfw.yaml b/src/tools/emcoctl/examples/vfw.yaml
index b5df4834..c84a1bab 100644
--- a/src/tools/emcoctl/examples/vfw.yaml
+++ b/src/tools/emcoctl/examples/vfw.yaml
@@ -38,7 +38,7 @@ resourceContext:
metadata :
name: edge01
file:
- kubeconfig
+ /home/otc/.kube/config
---
#Add label cluster
@@ -89,7 +89,7 @@ spec:
---
version: emco/v2
resourceContext:
- anchor: cluster-providers/vfw-cluster-provider/clusters/edge01/apply
+ anchor: cluster-providers/vfw-cluster-provider/clusters/edge01/apply
---
#create project
@@ -100,7 +100,7 @@ metadata :
name: testvfw
---
-#creating collection composite app entry
+#creating vfw composite app entry
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps
@@ -110,37 +110,37 @@ spec:
version: v1
---
-#adding prometheus app to the composite app
+#adding packetgen app to the composite app
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps/compositevfw/v1/apps
metadata :
name: packetgen
file:
- /home/vagrant/multicloud-k8s/kud/demo/composite-firewall/packetgen.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/packetgen.tar.gz
---
-#adding prometheus app to the composite app
+#adding firewall app to the composite app
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps/compositevfw/v1/apps
metadata :
name: firewall
file:
- /home/vagrant/multicloud-k8s/kud/demo/composite-firewall/firewall.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/firewall.tar.gz
---
-#adding collectd app to the composite app
+#adding sink app to the composite app
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps/compositevfw/v1/apps
metadata :
name: sink
file:
- /home/vagrant/multicloud-k8s/kud/demo/composite-firewall/sink.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/sink.tar.gz
---
-#creating collection composite profile entry
+#creating vfw composite profile entry
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps/compositevfw/v1/composite-profiles
@@ -148,7 +148,7 @@ metadata :
name: vfw_composite-profile
---
-#adding prometheus app profiles to the composite profile
+#adding packetgen app profiles to the composite profile
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps/compositevfw/v1/composite-profiles/vfw_composite-profile/profiles
@@ -157,7 +157,7 @@ metadata :
spec:
app-name: packetgen
file:
- /home/vagrant/multicloud-k8s/kud/demo/composite-firewall/profile.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/profile.tar.gz
---
#adding firewall app profiles to the composite profile
@@ -169,7 +169,7 @@ metadata :
spec:
app-name: firewall
file:
- /home/vagrant/multicloud-k8s/kud/demo/composite-firewall/profile.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/profile.tar.gz
---
#adding firewall app profiles to the composite profile
@@ -181,7 +181,7 @@ metadata :
spec:
app-name: sink
file:
- /home/vagrant/multicloud-k8s/kud/demo/composite-firewall/profile.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/profile.tar.gz
---
#create the generic placement intent
@@ -194,7 +194,7 @@ spec:
logical-cloud: NA
---
-#add the prometheus app placement intent to the generic 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
@@ -207,7 +207,7 @@ spec:
- provider-name: vfw-cluster-provider
cluster-label-name: LabelA
---
-#add the prometheus app placement intent to the generic placement intent
+#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
@@ -221,7 +221,7 @@ spec:
cluster-label-name: LabelA
---
-#add the prometheus app placement intent to the generic placement intent
+#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