diff --git a/src/api/rest/server/mcis/control.go b/src/api/rest/server/mcis/control.go index dfe204997..3888567ca 100644 --- a/src/api/rest/server/mcis/control.go +++ b/src/api/rest/server/mcis/control.go @@ -207,7 +207,7 @@ func RestGetAllMcis(c echo.Context) error { } content := RestGetAllMcisStatusResponse{} content.Mcis = result - common.PrintJsonPretty(content) + //common.PrintJsonPretty(content) return c.JSON(http.StatusOK, &content) } else if option == "simple" { // MCIS in simple (without VM information) @@ -218,7 +218,7 @@ func RestGetAllMcis(c echo.Context) error { } content := RestGetAllMcisResponse{} content.Mcis = result - common.PrintJsonPretty(content) + //common.PrintJsonPretty(content) return c.JSON(http.StatusOK, &content) } else { // MCIS in detail (with status information) @@ -229,7 +229,7 @@ func RestGetAllMcis(c echo.Context) error { } content := RestGetAllMcisResponse{} content.Mcis = result - common.PrintJsonPretty(content) + //common.PrintJsonPretty(content) return c.JSON(http.StatusOK, &content) } diff --git a/src/core/mcis/monitoring.go b/src/core/mcis/monitoring.go index b5b7e34ed..cd0f270fb 100644 --- a/src/core/mcis/monitoring.go +++ b/src/core/mcis/monitoring.go @@ -182,7 +182,7 @@ func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, mcisSer errStr := "" if err != nil { common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } fmt.Println("[CallMonitoringAsync] " + mcisID + "/" + vmID + "(" + vmIP + ")" + "with userName:" + userName) @@ -191,14 +191,14 @@ func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, mcisSer vmInfoTmp.MonAgentStatus = "installing" UpdateVmInfo(nsID, mcisID, vmInfoTmp) - url := common.DragonflyRestUrl + cmd - fmt.Println("\n[Calling DRAGONFLY] START") - fmt.Println("VM:" + nsID + "/" + mcisID + "/" + vmID + ", URL:" + url + ", userName:" + userName + ", cspType:" + vmInfoTmp.Location.CloudType + ", service_type:" + mcisServiceType) - if mcisServiceType == "" { mcisServiceType = "default" } + url := common.DragonflyRestUrl + cmd + fmt.Println("\n[Calling DRAGONFLY] START") + fmt.Println("VM:" + nsID + "/" + mcisID + "/" + vmID + ", URL:" + url + ", userName:" + userName + ", cspType:" + vmInfoTmp.Location.CloudType + ", service_type:" + mcisServiceType) + tempReq := monAgentInstallReq{ NsId: nsID, McisId: mcisID, @@ -211,17 +211,16 @@ func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, mcisSer ServiceType: mcisServiceType, } if tempReq.SshKey == "" { - fmt.Printf("\n[Request body to CB-DRAGONFLY]A problem detected.SshKey is empty.\n") common.PrintJsonPretty(tempReq) - err = fmt.Errorf("/request body to install monitoring agent: sshKey is empty/") + err = fmt.Errorf("/request body to install monitoring agent: privateKey is empty/") common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } payload, err := json.Marshal(tempReq) if err != nil { common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } responseLimit := 8 @@ -235,7 +234,7 @@ func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, mcisSer if err != nil { common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } req.Header.Add("Content-Type", "application/json") @@ -247,21 +246,21 @@ func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, mcisSer fmt.Println("Called CB-DRAGONFLY API") if err != nil { common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } else { fmt.Println("HTTP Status code: " + strconv.Itoa(res.StatusCode)) switch { case res.StatusCode >= 400 || res.StatusCode < 200: err = fmt.Errorf("HTTP Status: not in 200-399") common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { common.CBLog.Error(err) - errStr += err.Error() + errStr += "/ " + err.Error() } result = string(body) @@ -277,6 +276,7 @@ func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, mcisSer sshResultTmp.VmIp = vmIP if err != nil { + common.CBLog.Error("[Monitoring Agent deployment errors] " + errStr) sshResultTmp.Result = errStr sshResultTmp.Err = err *returnResult = append(*returnResult, sshResultTmp) @@ -470,30 +470,29 @@ func CallGetMonitoringAsync(wg *sync.WaitGroup, nsID string, mcisID string, vmID errStr = err.Error() } + fmt.Print("[Call CB-DF Result (" + mcisID + "," + vmID + ")] ") res, err := client.Do(req) - // result := "" - - fmt.Print("[Call CB-DF Result (" + mcisID + "," + vmID + ")] ") if err != nil { common.CBLog.Error(err) errStr = err.Error() - } - fmt.Println("HTTP Status code: " + strconv.Itoa(res.StatusCode)) - switch { - case res.StatusCode >= 400 || res.StatusCode < 200: - err1 := fmt.Errorf("HTTP Status: not in 200-399") - common.CBLog.Error(err1) - errStr = err1.Error() - } + } else { + fmt.Println("HTTP Status code: " + strconv.Itoa(res.StatusCode)) + switch { + case res.StatusCode >= 400 || res.StatusCode < 200: + err1 := fmt.Errorf("HTTP Status: not in 200-399") + common.CBLog.Error(err1) + errStr = err1.Error() + } - defer res.Body.Close() - body, err2 := ioutil.ReadAll(res.Body) - if err2 != nil { - common.CBLog.Error(err2) - errStr = err2.Error() + defer res.Body.Close() + body, err2 := ioutil.ReadAll(res.Body) + if err2 != nil { + common.CBLog.Error(err2) + errStr = err2.Error() + } + response = string(body) } - response = string(body) } else { reqParams := df_pb.VMOnDemandMonQryRequest{ NsId: nsID, diff --git a/src/core/mcis/remoteCommand.go b/src/core/mcis/remoteCommand.go index 65b1109d8..d7935acf6 100644 --- a/src/core/mcis/remoteCommand.go +++ b/src/core/mcis/remoteCommand.go @@ -324,17 +324,19 @@ func VerifySshUserName(nsId string, mcisId string, vmId string, vmIp string, ssh fmt.Println("[Start SSH checking squence]") // verify if vm is running with a public ip. - if vmIp == "" { - return "", "", fmt.Errorf("Cannot ssh, VM IP is null") - } - vmStatusInfoTmp, err := GetVmStatus(nsId, mcisId, vmId) - if err != nil { - common.CBLog.Error(err) - return "", "", err - } - if vmStatusInfoTmp.Status != StatusRunning || vmIp == "" { - return "", "", fmt.Errorf("Cannot ssh, VM is not Running") - } + /* + if vmIp == "" { + return "", "", fmt.Errorf("Cannot ssh, VM IP is null") + } + vmStatusInfoTmp, err := GetVmStatus(nsId, mcisId, vmId) + if err != nil { + common.CBLog.Error(err) + return "", "", err + } + if vmStatusInfoTmp.Status != StatusRunning || vmIp == "" { + return "", "", fmt.Errorf("Cannot ssh, VM is not Running") + } + */ /* Code to check endpoint and port connectivity. (disabled for better speed) // CheckConnectivity func checks if given port is open and ready.