k8s deployment yaml for applcm
[ealt-edge.git] / mecm / mepm / applcm / broker / pkg / handlers / handlersImpl.go
index 83594ec..243bfab 100644 (file)
@@ -296,7 +296,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 +313,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 +323,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 +380,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 +434,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: