Adding validations for all JSON data across modules 22/111722/4
authorRajamohan Raj <rajamohan.raj@intel.com>
Wed, 26 Aug 2020 00:28:12 +0000 (00:28 +0000)
committerRajamohan Raj <rajamohan.raj@intel.com>
Thu, 10 Sep 2020 22:12:17 +0000 (22:12 +0000)
Issue-ID: MULTICLOUD-1198
Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com>
Change-Id: Idc2fbfd6e875bd7b662c7d60925aeb776b3f7bea

43 files changed:
build/Dockerfile
docs/emco_apis.yaml
src/clm/api/clusterhandler.go
src/clm/api/clusterhandler_test.go
src/clm/json-schemas/cluster-kv.json [moved from src/orchestrator/api/json-schemas/cluster-kv.json with 100% similarity]
src/clm/json-schemas/cluster-label.json [moved from src/orchestrator/api/json-schemas/cluster-label.json with 100% similarity]
src/clm/json-schemas/metadata.json [moved from src/orchestrator/api/json-schemas/metadata.json with 100% similarity]
src/ncm/api/networkhandler.go
src/ncm/api/providernethandler.go
src/ncm/json-schemas/provider-network.json [moved from src/orchestrator/api/json-schemas/provider-network.json with 100% similarity]
src/ncm/json-schemas/virtual-network.json [moved from src/orchestrator/api/json-schemas/virtual-network.json with 100% similarity]
src/orchestrator/api/add_intents_handler.go
src/orchestrator/api/app_intent_handler.go
src/orchestrator/api/app_profilehandler.go
src/orchestrator/api/apphandler.go
src/orchestrator/api/composite_app_handler.go
src/orchestrator/api/composite_profilehandler.go
src/orchestrator/api/composite_profilehandler_test.go
src/orchestrator/api/controllerhandler.go
src/orchestrator/api/controllerhandler_test.go
src/orchestrator/api/deployment_intent_groups_handler.go
src/orchestrator/api/generic_placement_intent_handler.go
src/orchestrator/api/projecthandler.go
src/orchestrator/api/projecthandler_test.go
src/orchestrator/json-schemas/composite-app.json [moved from src/orchestrator/api/json-schemas/composite-app.json with 100% similarity]
src/orchestrator/json-schemas/composite-profile.json [moved from src/orchestrator/api/json-schemas/composite-profile.json with 100% similarity]
src/orchestrator/json-schemas/controller.json [moved from src/orchestrator/api/json-schemas/controller.json with 100% similarity]
src/orchestrator/json-schemas/deployment-group-intent.json [moved from src/orchestrator/api/json-schemas/deployment-group-intent.json with 100% similarity]
src/orchestrator/json-schemas/deployment-intent.json [moved from src/orchestrator/api/json-schemas/deployment-intent.json with 100% similarity]
src/orchestrator/json-schemas/generic-placement-intent-app.json [moved from src/orchestrator/api/json-schemas/generic-placement-intent-app.json with 100% similarity]
src/orchestrator/json-schemas/generic-placement-intent.json [moved from src/orchestrator/api/json-schemas/generic-placement-intent.json with 100% similarity]
src/orchestrator/json-schemas/metadata.json [new file with mode: 0644]
src/orchestrator/scripts/start-dev.sh
src/ovnaction/api/netcontrolintenthandler.go
src/ovnaction/api/workloadifintenthandler.go
src/ovnaction/api/workloadintenthandler.go
src/ovnaction/json-schemas/metadata.json [new file with mode: 0644]
src/ovnaction/json-schemas/network-load-interface.json [moved from src/orchestrator/api/json-schemas/network-load-interface.json with 97% similarity]
src/ovnaction/json-schemas/network-workload.json [moved from src/orchestrator/api/json-schemas/network-workload.json with 100% similarity]
src/tools/emcoctl/Readme.md
src/tools/emcoctl/examples/emco-cfg.yaml
src/tools/emcoctl/examples/test.yaml
src/tools/emcoctl/examples/vfw.yaml

index ea9b001..d7ba3c3 100644 (file)
@@ -30,7 +30,13 @@ COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/rsync/rsyn
 COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/ovnaction/ovnaction ./
 COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/clm/clm ./
 COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/build/entrypoint ./
-COPY --chown=emco --from=0  /go/src/github.com/onap/multicloud-k8s/src/orchestrator/api/json-schemas ./json-schemas
+COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/orchestrator/json-schemas ./json-schemas
+COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/ncm/json-schemas ./json-schemas
+COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/clm/json-schemas ./json-schemas
+COPY --chown=emco --from=0 /go/src/github.com/onap/multicloud-k8s/src/ovnaction/json-schemas ./json-schemas
+
+
+
 
 USER emco
 
index 163e3d6..5f9c551 100644 (file)
@@ -3210,10 +3210,10 @@ components:
               maxLength: 128
               example: "provider-1"
             defaultGateway:
-              type: boolean
+              type: "string"
               description: Is this interface default gateway
               maxLength: 128
-              example: false
+              example: "false"
             ipAddress:
               type: string
               description: Name of the network
index 84dd323..75fcc56 100644 (file)
@@ -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)
index 076718d..a866835 100644 (file)
@@ -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
index ed26669..6f305be 100644 (file)
@@ -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)
index 66a41a4..48d5d7e 100644 (file)
@@ -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)
index 21a3373..66f3839 100644 (file)
@@ -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
index a51b9b9..1d48f8a 100644 (file)
@@ -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
index 2fa0f26..58cd214 100644 (file)
@@ -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
index 7d901a8..7429f5c 100644 (file)
@@ -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
index 1e69c35..d531b28 100644 (file)
@@ -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
index 5a3fb19..de1c8f2 100644 (file)
@@ -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
index ec3ec24..d1e3423 100644 (file)
@@ -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
index be300d8..418aa70 100644 (file)
@@ -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
index 6cbb2a7..ecc2d1f 100644 (file)
@@ -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
index 76dea14..b9466a2 100644 (file)
@@ -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
index 16f1f23..2415ae2 100644 (file)
@@ -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
index f130d28..07cd79c 100644 (file)
@@ -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
index ef5fdf0..5e88bab 100644 (file)
@@ -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/json-schemas/metadata.json b/src/orchestrator/json-schemas/metadata.json
new file mode 100644 (file)
index 0000000..960545e
--- /dev/null
@@ -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
index 003773b..ad21dc4 100755 (executable)
@@ -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
index fe2109b..631f13c 100644 (file)
@@ -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)
index cf8f45b..e7be631 100644 (file)
@@ -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)
index cf7eceb..acf4edb 100644 (file)
@@ -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 (file)
index 0000000..960545e
--- /dev/null
@@ -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
@@ -37,8 +37,8 @@
           },
           "defaultGateway": {
             "description": "Is this interface default gateway",
-            "type": "boolean",
-            "example": false,
+            "type": "string",
+            "example": "false",
             "maxLength": 128
           }
         }
index ecbcf4d..105398c 100644 (file)
@@ -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
+```
index c1703de..a7e284a 100644 (file)
@@ -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
index 924f7e5..e54ff36 100644 (file)
@@ -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
 
 ---
index b5df483..c84a1ba 100644 (file)
@@ -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