summaryrefslogtreecommitdiffstats
path: root/src/dcm/api
diff options
context:
space:
mode:
authorItohan <itohan.ukponmwan@intel.com>2020-04-14 17:06:13 -0700
committerItohan <itohan.ukponmwan@intel.com>2020-04-20 12:02:19 -0700
commitb0919a7cd6f49bcd2ae3e59c7a31e40f36cb7879 (patch)
treef756d263bd25140ad83cf6b9041a9e3f62f7e5c7 /src/dcm/api
parentf853b30cdc2655f6889f24214ba21791351c0787 (diff)
Implement Apply API for DCM
This implents the Apply API. When the apply API is called, this reads from mongodb and creates resources in ETCD Issue-ID: MULTICLOUD-996 Signed-off-by: Itohan Ukponmwan <itohan.ukponmwan@intel.com> Change-Id: I5b9c8b44673e66296d1339b5b3f4afc5f4cae9cc
Diffstat (limited to 'src/dcm/api')
-rw-r--r--src/dcm/api/api.go22
-rw-r--r--src/dcm/api/logicalCloudHandler.go37
2 files changed, 46 insertions, 13 deletions
diff --git a/src/dcm/api/api.go b/src/dcm/api/api.go
index d050a5ba..87ad77b5 100644
--- a/src/dcm/api/api.go
+++ b/src/dcm/api/api.go
@@ -36,7 +36,19 @@ func NewRouter(
if logicalCloudClient == nil {
logicalCloudClient = module.NewLogicalCloudClient()
}
- logicalCloudHandler := logicalCloudHandler{client: logicalCloudClient}
+
+ if clusterClient == nil {
+ clusterClient = module.NewClusterClient()
+ }
+
+ if quotaClient == nil {
+ quotaClient = module.NewQuotaClient()
+ }
+
+ logicalCloudHandler := logicalCloudHandler{client: logicalCloudClient,
+ clusterClient: clusterClient,
+ quotaClient: quotaClient,
+ }
lcRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
lcRouter.HandleFunc(
"/logical-clouds",
@@ -67,9 +79,7 @@ func NewRouter(
logicalCloudHandler.associateHandler).Methods("GET")*/
// Set up Cluster API
- if clusterClient == nil {
- clusterClient = module.NewClusterClient()
- }
+
clusterHandler := clusterHandler{client: clusterClient}
clusterRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
clusterRouter.HandleFunc(
@@ -108,9 +118,7 @@ func NewRouter(
userPermissionHandler.deleteHandler).Methods("DELETE")
// Set up Quota API
- if quotaClient == nil {
- quotaClient = module.NewQuotaClient()
- }
+
quotaHandler := quotaHandler{client: quotaClient}
quotaRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
quotaRouter.HandleFunc(
diff --git a/src/dcm/api/logicalCloudHandler.go b/src/dcm/api/logicalCloudHandler.go
index 7df0ae2e..d8fcf268 100644
--- a/src/dcm/api/logicalCloudHandler.go
+++ b/src/dcm/api/logicalCloudHandler.go
@@ -30,6 +30,8 @@ import (
// logicalCloudHandler is used to store backend implementations objects
type logicalCloudHandler struct {
client module.LogicalCloudManager
+ clusterClient module.ClusterManager
+ quotaClient module.QuotaManager
}
// CreateHandler handles creation of the logical cloud entry in the database
@@ -156,15 +158,38 @@ func (h logicalCloudHandler) deleteHandler(w http.ResponseWriter, r *http.Reques
}
func (h logicalCloudHandler) applyHandler(w http.ResponseWriter, r *http.Request) {
- /*vars := mux.Vars(r)
+ vars := mux.Vars(r)
project := vars["project-name"]
- name := vars["logical-cloud-name"]*/
- /*ret, err := h.client.Get(project, name)
+ name := vars["logical-cloud-name"]
+
+ // Get logical cloud
+ lc, err := h.client.Get(project, name)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
- }*/
+ }
+
+ // Get Clusters
+ clusters, err := h.clusterClient.GetAllClusters(project, name)
+
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+
+ //Get Quotas
+ quotas, err := h.quotaClient.GetAllQuotas(project, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ err = module.CreateEtcdContext(lc, clusters, quotas)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
- // Do Some Work
- // someApplyFunction(project, name, ret)
+ return
}