diff options
author | 2020-04-14 17:54:45 -0700 | |
---|---|---|
committer | 2020-04-16 16:58:05 -0700 | |
commit | b7a4e00a6cd9d4ce903448ea958d85f17c8d68ab (patch) | |
tree | 5ac53a49fd1efd559494755ca666ecf9550b1014 /src/ncm/api/clusterhandler.go | |
parent | c898a84208d20f0040778450cc401a35c3f8ee41 (diff) |
Add apply API for network intents
Support POST API to 'apply' and 'terminate' network and
providernetwork intents for a given cluster.
Issue-ID: MULTICLOUD-1029
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Change-Id: I8c9bae9e93aeeb68654eaab1f15de9883c22215c
Diffstat (limited to 'src/ncm/api/clusterhandler.go')
-rw-r--r-- | src/ncm/api/clusterhandler.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ncm/api/clusterhandler.go b/src/ncm/api/clusterhandler.go index 8c50f720..78453aa8 100644 --- a/src/ncm/api/clusterhandler.go +++ b/src/ncm/api/clusterhandler.go @@ -324,6 +324,36 @@ func (h clusterHandler) deleteClusterHandler(w http.ResponseWriter, r *http.Requ w.WriteHeader(http.StatusNoContent) } +// apply network intents associated with the cluster +func (h clusterHandler) applyClusterHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + provider := vars["provider-name"] + name := vars["name"] + + err := h.client.ApplyNetworkIntents(provider, name) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusNoContent) +} + +// terminate network intents associated with the cluster +func (h clusterHandler) terminateClusterHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + provider := vars["provider-name"] + name := vars["name"] + + err := h.client.TerminateNetworkIntents(provider, name) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusNoContent) +} + // Create handles creation of the ClusterLabel entry in the database func (h clusterHandler) createClusterLabelHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) |