aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api/handler.go
diff options
context:
space:
mode:
authorVictor Morales <victor.morales@intel.com>2019-03-21 01:40:19 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-21 01:40:19 +0000
commit57ba15140f909434bd309a447c53eb6db4147f8f (patch)
tree623eeabee5b57c7d32cd80497309155da9a189f1 /src/k8splugin/api/handler.go
parent69320e75210709ad2dadf3c183289e9a67cf4817 (diff)
parent17275e9b6899ba611458f8ca9aaa868c70d7d0cf (diff)
Merge "Bring in all the other helper code"
Diffstat (limited to 'src/k8splugin/api/handler.go')
-rw-r--r--src/k8splugin/api/handler.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/k8splugin/api/handler.go b/src/k8splugin/api/handler.go
index a6db3c18..32bfa594 100644
--- a/src/k8splugin/api/handler.go
+++ b/src/k8splugin/api/handler.go
@@ -27,6 +27,7 @@ import (
helper "k8splugin/internal/app"
"k8splugin/internal/db"
+ "k8splugin/internal/rb"
)
//TODO: Separate the http handler code and backend code out
@@ -53,7 +54,11 @@ func validateBody(body interface{}) error {
werr := pkgerrors.Wrap(errors.New("Invalid/Missing CsarID in POST request"), "CreateVnfRequest bad request")
return werr
}
- if strings.Contains(b.CloudRegionID, "|") || strings.Contains(b.Namespace, "|") {
+ if b.RBProfileID == "" {
+ werr := pkgerrors.Wrap(errors.New("Invalid/Missing RB ProfileID in POST request"), "CreateVnfRequest bad request")
+ return werr
+ }
+ if strings.Contains(b.CloudRegionID, "|") {
werr := pkgerrors.Wrap(errors.New("Character \"|\" not allowed in CSAR ID"), "CreateVnfRequest bad request")
return werr
}
@@ -104,18 +109,21 @@ func CreateHandler(w http.ResponseWriter, r *http.Request) {
},
nil
*/
- externalVNFID, resourceNameMap, err := helper.CreateVNF(resource.CsarID, resource.CloudRegionID, resource.Namespace, &kubeclient)
+ externalVNFID, resourceNameMap, err := helper.CreateVNF(resource.CsarID, resource.CloudRegionID,
+ resource.RBProfileID, &kubeclient)
if err != nil {
werr := pkgerrors.Wrap(err, "Read Kubernetes Data information error")
http.Error(w, werr.Error(), http.StatusInternalServerError)
return
}
+ rbProfile, _ := rb.NewProfileClient().Get(resource.RBProfileID)
+ namespace := rbProfile.Namespace
// cloud1-default-uuid
- internalVNFID := resource.CloudRegionID + "-" + resource.Namespace + "-" + externalVNFID
+ internalVNFID := resource.CloudRegionID + "-" + namespace + "-" + externalVNFID
// Persist in AAI database.
- log.Printf("Cloud Region ID: %s, Namespace: %s, VNF ID: %s ", resource.CloudRegionID, resource.Namespace, externalVNFID)
+ log.Printf("Cloud Region ID: %s, Namespace: %s, VNF ID: %s ", resource.CloudRegionID, namespace, externalVNFID)
// TODO: Uncomment when annotations are done
// krd.AddNetworkAnnotationsToPod(kubeData, resource.Networks)
@@ -132,7 +140,7 @@ func CreateHandler(w http.ResponseWriter, r *http.Request) {
resp := CreateVnfResponse{
VNFID: externalVNFID,
CloudRegionID: resource.CloudRegionID,
- Namespace: resource.Namespace,
+ Namespace: namespace,
VNFComponents: resourceNameMap,
}