X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=mecm%2Fmepm%2Fapplcm%2Fbroker%2Fpkg%2Fhandlers%2FhandlersImpl.go;h=6867b2c463fb4e33ad3fddbb6f299babca8302fa;hb=b53813aee440d6c0a936a2827e5c304cf60d8be1;hp=83594eca328d1b456565b8e1698670faf3c33629;hpb=3ae89fe7e41f324ca11582af14b2c8403bff68e2;p=ealt-edge.git diff --git a/mecm/mepm/applcm/broker/pkg/handlers/handlersImpl.go b/mecm/mepm/applcm/broker/pkg/handlers/handlersImpl.go index 83594ec..6867b2c 100644 --- a/mecm/mepm/applcm/broker/pkg/handlers/handlersImpl.go +++ b/mecm/mepm/applcm/broker/pkg/handlers/handlersImpl.go @@ -23,6 +23,13 @@ import ( "bytes" "encoding/json" "fmt" + "io" + "io/ioutil" + "net/http" + "os" + "path/filepath" + "strings" + "github.com/buger/jsonparser" "github.com/ghodss/yaml" "github.com/google/uuid" @@ -30,18 +37,12 @@ import ( "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "io" - "io/ioutil" - "net/http" - "os" - "path/filepath" - "strings" ) // Handler of REST APIs type HandlerImpl struct { - logger *logrus.Logger - dbAdapter *dbAdapter.DbAdapter + logger *logrus.Logger + dbAdapter *dbAdapter.DbAdapter } // Creates handler implementation @@ -296,7 +297,8 @@ func (impl *HandlerImpl) InstantiateAppInstance(w http.ResponseWriter, r *http.R respondError(w, http.StatusInternalServerError, "artifact not available in application package") return } - pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT") + pluginInfo = "helmplugin" + ":" + os.Getenv("HELM_PLUGIN_PORT") + impl.logger.Infof("Plugin Info ", pluginInfo) case "kubernetes": pkgPath := PackageFolderPath + packageName + PackageArtifactPath + "Kubernetes" artifact = impl.getDeploymentArtifact(pkgPath, "*.yaml") @@ -312,7 +314,7 @@ func (impl *HandlerImpl) InstantiateAppInstance(w http.ResponseWriter, r *http.R impl.logger.Infof("Artifact to deploy:", artifact) adapter := pluginAdapter.NewPluginAdapter(pluginInfo, impl.logger) - workloadId, err := adapter.Instantiate(pluginInfo, req.SelectedMECHostInfo.HostID, artifact) + workloadId, err, resStatus := adapter.Instantiate(pluginInfo, req.SelectedMECHostInfo.HostID, artifact) if err != nil { st, ok := status.FromError(err) if ok && st.Code() == codes.InvalidArgument { @@ -322,9 +324,13 @@ func (impl *HandlerImpl) InstantiateAppInstance(w http.ResponseWriter, r *http.R respondError(w, http.StatusInternalServerError, err.Error()) } } - impl.dbAdapter.UpdateAppInstanceInfoInstStatusHostAndWorkloadId(appInstanceId, "INSTANTIATED", req.SelectedMECHostInfo.HostID, workloadId) - respondJSON(w, http.StatusAccepted, json.NewEncoder(w).Encode("")) + if resStatus == "Failure" { + respondError(w, http.StatusInternalServerError, err.Error()) + } + + impl.dbAdapter.UpdateAppInstanceInfoInstStatusHostAndWorkloadId(appInstanceId, "INSTANTIATED", req.SelectedMECHostInfo.HostID, workloadId) + respondJSON(w, http.StatusAccepted, json.NewEncoder(w).Encode(workloadId)) } // Gets deployment artifact @@ -375,7 +381,7 @@ func (impl *HandlerImpl) QueryAppInstanceInfo(w http.ResponseWriter, r *http.Req switch appPackageInfo.DeployType { case "helm": - pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT") + pluginInfo = "helmplugin" + ":" + os.Getenv("HELM_PLUGIN_PORT") case "kubernetes": pluginInfo = "kubernetes.plugin" + ":" + os.Getenv("KUBERNETES_PLUGIN_PORT") default: @@ -429,7 +435,7 @@ func (impl *HandlerImpl) TerminateAppInstance(w http.ResponseWriter, r *http.Req var pluginInfo string switch appPackageInfo.DeployType { case "helm": - pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT") + pluginInfo = "helmplugin" + ":" + os.Getenv("HELM_PLUGIN_PORT") case "kubernetes": pluginInfo = "kubernetes.plugin" + ":" + os.Getenv("KUBERNETES_PLUGIN_PORT") default: