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
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
"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 {
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)
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 {
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)
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)
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
"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 {
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)
"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 {
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)
"github.com/gorilla/mux"
)
+var addIntentJSONFile string = "json-schemas/deployment-intent.json"
+
type intentHandler struct {
client moduleLib.IntentManager
}
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
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
*/
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
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
*/
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
"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 {
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
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 {
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
"github.com/gorilla/mux"
)
+var caprofileJSONFile string = "json-schemas/metadata.json"
+
/* Used to store backend implementation objects
Also simplifies mocking for unit testing purposes
*/
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
return m.Err
}
+func init() {
+ caprofileJSONFile = "../json-schemas/metadata.json"
+}
+
func Test_compositeProfileHandler_createHandler(t *testing.T) {
testCases := []struct {
label string
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 {
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
return
}
+func init() {
+ controllerJSONFile = "../json-schemas/controller.json"
+}
+
func TestControllerCreateHandler(t *testing.T) {
testCases := []struct {
label string
"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
*/
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
"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
*/
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
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 {
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
return []moduleLib.Project{}, m.Err
}
+func init() {
+ projectJSONFile = "../json-schemas/metadata.json"
+}
+
func TestProjectCreateHandler(t *testing.T) {
testCases := []struct {
label string
--- /dev/null
+
+{
+ "$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
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
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 {
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)
"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 {
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)
"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 {
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)
--- /dev/null
+
+{
+ "$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
},
"defaultGateway": {
"description": "Is this interface default gateway",
- "type": "boolean",
- "example": false,
+ "type": "string",
+ "example": "false",
"maxLength": 128
}
}
`$ 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
+```
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
userData1: test1
userData2: test2
file:
- kubeconfig
+ /home/otc/.kube/config
---
#Add label cluster
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
userData1: test1
userData2: test2
file:
- collectd.tar.gz
+ /opt/csar/cb009bfe-bbee-11e8-9766-525400435678/collectd.tar.gz
---
#creating collection composite profile entry
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
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
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
app-name: collectd
intent:
allOf:
- - provider-name: cluster-provider1
+ - provider-name: provider1
cluster-label-name: edge-cluster
---
metadata :
name: edge01
file:
- kubeconfig
+ /home/otc/.kube/config
---
#Add label cluster
---
version: emco/v2
resourceContext:
- anchor: cluster-providers/vfw-cluster-provider/clusters/edge01/apply
+ anchor: cluster-providers/vfw-cluster-provider/clusters/edge01/apply
---
#create project
name: testvfw
---
-#creating collection composite app entry
+#creating vfw composite app entry
version: emco/v2
resourceContext:
anchor: projects/testvfw/composite-apps
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
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
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
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
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
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
- 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
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