aboutsummaryrefslogtreecommitdiffstats
path: root/src/dcm/api/logicalCloudHandler.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/dcm/api/logicalCloudHandler.go')
-rw-r--r--src/dcm/api/logicalCloudHandler.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/dcm/api/logicalCloudHandler.go b/src/dcm/api/logicalCloudHandler.go
index fb0f0c63..b5161efa 100644
--- a/src/dcm/api/logicalCloudHandler.go
+++ b/src/dcm/api/logicalCloudHandler.go
@@ -25,6 +25,7 @@ import (
"github.com/gorilla/mux"
"github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+ orch "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
pkgerrors "github.com/pkg/errors"
)
@@ -59,6 +60,15 @@ func (h logicalCloudHandler) createHandler(w http.ResponseWriter, r *http.Reques
return
}
+ // Validate that the specified Project exists
+ // before associating a Logical Cloud with it
+ p := orch.NewProjectClient()
+ _, err = p.GetProject(project)
+ if err != nil {
+ http.Error(w, "The specified project does not exist.", http.StatusNotFound)
+ return
+ }
+
ret, err := h.client.Create(project, v)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -186,7 +196,7 @@ func (h logicalCloudHandler) applyHandler(w http.ResponseWriter, r *http.Request
return
}
- _, ctxVal, err := h.client.GetLogicalCloudContext(name)
+ _, ctxVal, err := h.client.GetLogicalCloudContext(project, name)
if ctxVal != "" {
err = pkgerrors.New("Logical Cloud already applied")
http.Error(w, err.Error(), http.StatusConflict)
@@ -212,7 +222,7 @@ func (h logicalCloudHandler) applyHandler(w http.ResponseWriter, r *http.Request
return
}
- err = module.CreateEtcdContext(lc, clusters, quotas)
+ err = module.CreateEtcdContext(project, lc, clusters, quotas)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -237,7 +247,7 @@ func (h logicalCloudHandler) terminateHandler(w http.ResponseWriter, r *http.Req
return
}
- _, ctxVal, err := h.client.GetLogicalCloudContext(name)
+ _, ctxVal, err := h.client.GetLogicalCloudContext(project, name)
if ctxVal == "" {
err = pkgerrors.New("Logical Cloud hasn't been applied yet")
http.Error(w, err.Error(), http.StatusConflict)
@@ -259,7 +269,7 @@ func (h logicalCloudHandler) terminateHandler(w http.ResponseWriter, r *http.Req
return
}
- err = module.DestroyEtcdContext(lc, clusters, quotas)
+ err = module.DestroyEtcdContext(project, lc, clusters, quotas)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return