Browse Source

Edit ResetPass
add ForgetPass
Add Overal statistics
add VMStatistics

torabkheslat 4 years ago
parent
commit
054648b87d
3 changed files with 920 additions and 69 deletions
  1. 358 33
      handler.go
  2. 14 4
      main.go
  3. 548 32
      ovirt.go

+ 358 - 33
handler.go

@@ -3,14 +3,18 @@ package main
 import (
 	"crypto/sha256"
 	"crypto/tls"
+	"database/sql"
 	"encoding/json"
 	"fmt"
 	"io/ioutil"
 	"net/http"
 	"net/url"
+	"strconv"
 	"strings"
 	"time"
 
+	"github.com/dchest/uniuri"
+
 	"github.com/dgrijalva/jwt-go"
 	"github.com/labstack/echo"
 )
@@ -74,6 +78,38 @@ type userInfo struct {
 	ID        int         `json:"id"`
 	Principal string      `json:"principal"`
 }
+type ServiceList struct {
+	TotalCount    string `json:"TotalCount,omitempty"`
+	ActiveCount   string `json:"ActiveCount,omitempty"`
+	ActiveVMCount string `json:"ActiveVMCount,omitempty"`
+	TotalVMCount  string `json:"TotalVMCount,omitempty"`
+}
+type user_findResult struct {
+	Error     interface{} `json:"error"`
+	ID        int         `json:"id"`
+	Principal string      `json:"principal"`
+	Result    struct {
+		Count  int `json:"count"`
+		Result []struct {
+			Dn               string   `json:"dn"`
+			Gidnumber        []string `json:"gidnumber"`
+			Givenname        []string `json:"givenname"`
+			Homedirectory    []string `json:"homedirectory"`
+			Krbcanonicalname []string `json:"krbcanonicalname"`
+			Krbprincipalname []string `json:"krbprincipalname"`
+			Loginshell       []string `json:"loginshell"`
+			Mail             []string `json:"mail"`
+			Nsaccountlock    bool     `json:"nsaccountlock"`
+			Sn               []string `json:"sn"`
+			Telephonenumber  []string `json:"telephonenumber"`
+			UID              []string `json:"uid"`
+			Uidnumber        []string `json:"uidnumber"`
+		} `json:"result"`
+		Summary   string `json:"summary"`
+		Truncated bool   `json:"truncated"`
+	} `json:"result"`
+	Version string `json:"version"`
+}
 
 var User = userInfo{}
 
@@ -120,7 +156,7 @@ func (h *handler) login(c echo.Context) error {
 	return echo.ErrUnauthorized
 }
 func getUserInfo(token string, username string) userInfo {
-	fmt.Println("Checking for User: ", username)
+	//fmt.Println("Checking for User: ", username)
 	url := URL + "/ipa/session/json"
 	method := "POST"
 	_json := fmt.Sprintf(`
@@ -156,7 +192,7 @@ func getUserInfo(token string, username string) userInfo {
 	res, err := client.Do(req)
 	defer res.Body.Close()
 	body, err := ioutil.ReadAll(res.Body)
-	fmt.Println("Getting Data for Response: ", res.Status)
+	//fmt.Println("Getting Data for Response: ", res.Status)
 	user := userInfo{}
 	json.Unmarshal(body, &user)
 	fmt.Println("Getting Data for User: ", user.Result.Result.Uidnumber)
@@ -164,15 +200,16 @@ func getUserInfo(token string, username string) userInfo {
 }
 func (h *handler) uuidgen(c echo.Context) error {
 	resource := c.FormValue("resource")
-	id,code := uuidgen(resource)
+	id, code := uuidgen(resource)
 
 	resp := _response{
 		Origin:  "uuidgen",
 		Message: id,
 		Code:    code,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 func (h *handler) addUser(c echo.Context) error {
 	type apiErr struct {
@@ -329,17 +366,27 @@ func (h *handler) addUser(c echo.Context) error {
 		if __err != nil {
 			return c.String(http.StatusBadRequest, "Error of error!!")
 		}
-		res2B, _ := json.Marshal(_apiErr)
-		return c.String(http.StatusBadRequest, string(res2B))
+		//res2B, _ := json.Marshal(_apiErr)
+		//return c.String(http.StatusBadRequest, string(res2B))
+		resp := _response{
+			Origin:  "AddUser",
+			Message: _apiErr.Error.Name + ": " + _apiErr.Error.Message,
+			Code:    _apiErr.Error.Code,
+		}
+		return c.JSON(http.StatusNotFound, resp)
+		//return c.JSON(http.StatusBadRequest, _apiErr)
 	}
-	go sendMail("Welcome to ZiCloud\r\n Your temporary link is :\r\n https://zicloud.com/reset/"+url.QueryEscape(ciphertext), "Welcome to ZiCloud", mail)
+	shortLink := setResetKey(ciphertext, username)
+	go sendMail("Welcome to ZiCloud\r\n Your temporary link is :\r\n https://zicloud.com/reset/"+url.QueryEscape(shortLink), "Welcome to ZiCloud", mail)
+	//go sendMail("Welcome to ZiCloud\r\n Your temporary link is :\r\n https://zicloud.com/reset/"+url.QueryEscape(ciphertext), "Welcome to ZiCloud", mail)
 	resp := _response{
 		Origin:  "addUser",
-		Message: "Done, Reset Link was sent to " + mail,
+		Message: "Done, Reset Link was sent to your email",
 		Code:    1000,
 	}
-	b, _ = json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ = json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 func (h *handler) disableUser(c echo.Context) error {
 	user := c.Get("user").(*jwt.Token)
@@ -380,7 +427,8 @@ func (h *handler) disableUser(c echo.Context) error {
 	req.Header.Add("Cookie", token)
 	res, err := client.Do(req)
 	if err != nil {
-		return c.String(http.StatusBadRequest, "Error"+err.Error())
+		//return c.String(http.StatusBadRequest, "Error"+err.Error())
+		return c.JSON(http.StatusOK, "Error"+err.Error())
 	}
 	defer res.Body.Close()
 	resp := _response{
@@ -388,8 +436,9 @@ func (h *handler) disableUser(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 func (h *handler) resetUser(c echo.Context) error {
 	type keyJson struct {
@@ -402,10 +451,20 @@ func (h *handler) resetUser(c echo.Context) error {
 	}
 	t := time.Now() //%Y%m%d%H%M%SZ
 	t = t.Add(time.Hour * 24 * 60)
-	username := c.FormValue("Username")
+	//username := c.FormValue("Username")
 	password := c.FormValue("Password")
-	key := c.FormValue("key")
-	key, _ = url.QueryUnescape(key)
+	short := c.FormValue("key")
+	key, username := getResetKey(short)
+	if len(key) < 5 {
+		resp := _response{
+			Origin:  "resetUser",
+			Message: "Object Not found",
+			Code:    1001,
+		}
+		//b, _ := json.MarshalIndent(resp, "", "  ")
+		return c.JSON(http.StatusOK, resp)
+	}
+	//key, _ = url.QueryUnescape(key)
 	_sha256 := sha256.Sum256([]byte(username))
 	var hashChannel = make(chan []byte, 1)
 	hashChannel <- _sha256[:]
@@ -485,7 +544,8 @@ func (h *handler) resetUser(c echo.Context) error {
 	//fmt.Println(req)
 	//fmt.Println(res)
 	if err != nil {
-		return c.String(http.StatusBadRequest, "Error"+err.Error())
+		//return c.String(http.StatusBadRequest, "Error"+err.Error())
+		return c.JSON(http.StatusBadRequest, "Error"+err.Error())
 	}
 	defer res.Body.Close()
 	resp := _response{
@@ -493,8 +553,10 @@ func (h *handler) resetUser(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	expireResetKey(username)
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 func (h *handler) dnsrecordadd(c echo.Context) error {
 	user := c.Get("user").(*jwt.Token)
@@ -541,7 +603,8 @@ func (h *handler) dnsrecordadd(c echo.Context) error {
 	req.Header.Add("Cookie", token)
 	res, err := client.Do(req)
 	if err != nil {
-		return c.String(http.StatusBadRequest, "Error"+err.Error())
+		//return c.String(http.StatusBadRequest, "Error"+err.Error())
+		return c.JSON(http.StatusBadRequest, "Error"+err.Error())
 	}
 	//body, err := ioutil.ReadAll(res.Body)
 	//_res:=result{}
@@ -553,8 +616,9 @@ func (h *handler) dnsrecordadd(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 func (h *handler) token(c echo.Context) error {
 	user := c.Get("user").(*jwt.Token)
@@ -609,22 +673,283 @@ func (h *handler) verifyUser(c echo.Context) error {
 			resp := _response{
 				Origin:  "VerifyUser",
 				Message: "User Not Found",
-				Code:    1001,
-			}
-			b, _errr := json.MarshalIndent(resp, "", "  ")
-			if _errr != nil {
-				fmt.Println(_errr)
+				Code:    1000,
 			}
-			fmt.Print(string(b))
-			return c.JSON(http.StatusNotFound, string(b))
+			//b, _errr := json.MarshalIndent(resp, "", "  ")
+			//b, _= json.Marshal(resp)
+			//if _errr != nil {
+			//	fmt.Println(_errr)
+			//}
+			//fmt.Print(string(b))
+			return c.JSON(http.StatusOK, resp)
 		}
 	}
 	resp := _response{
 		Origin:  "VerifyUser",
 		Message: "User Found",
-		Code:    1002,
+		Code:    1001,
+	}
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+
+	return c.JSON(http.StatusNotFound, resp)
+}
+
+func (h *handler) forgetpassword(c echo.Context) error {
+
+	user := c.Get("user").(*jwt.Token)
+	claims := user.Claims.(jwt.MapClaims)
+	_sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
+	var hashChannel_ = make(chan []byte, 1)
+	hashChannel_ <- _sha256[:]
+	token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
+	_type := c.FormValue("type")
+	_data := c.FormValue("data")
+	url := URL + "/ipa/session/json"
+	method := "POST"
+	__type, _ := strconv.Atoi(_type)
+	_json := ""
+	if __type == 1 {
+		// email
+		_json = fmt.Sprintf(`
+{
+  "id": 0,
+    "method": "user_find/1",
+    "params": [
+        [],
+        {
+            "mail": [
+                "%s"
+            ],
+            "version": "2.235"
+        }
+    ]
+}
+`, _data)
+	} else if __type == 2 {
+		// username
+		_json = fmt.Sprintf(`
+{
+  "id": 0,
+    "method": "user_find/1",
+    "params": [
+        [
+            "%s"
+        ],
+        {
+            "version": "2.235"
+        }
+    ]
+}
+`, _data)
+	} else if __type == 3 {
+		//mobile
+		_json = fmt.Sprintf(`
+{
+    "id": 0,
+    "method": "user_find/1",
+    "params": [
+        [],
+        {
+            "mobile": [
+                "%s"
+            ],
+            "version": "2.235"
+        }
+    ]
+}
+`, _data)
+
+	} else {
+		resp := _response{
+			Origin:  "forgetpassword",
+			Message: "unknown requested type",
+			Code:    1001,
+		}
+		return c.JSON(http.StatusNotFound, resp)
+	}
+	//fmt.Println(_json)
+	payload := strings.NewReader(_json)
+	tr := &http.Transport{
+		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
+	}
+	client := &http.Client{Transport: tr}
+	req, err := http.NewRequest(method, url, payload)
+
+	if err != nil {
+		fmt.Println(err)
+	}
+	req.Header.Add("Referer", URL+"/ipa")
+	req.Header.Add("Content-Type", "application/json")
+	req.Header.Add("Accept", "text/plain")
+	req.Header.Add("Cookie", token)
+	res, err := client.Do(req)
+	defer res.Body.Close()
+	body, err := ioutil.ReadAll(res.Body)
+	//fmt.Println("Getting Data for Response: ", body)
+	_user := user_findResult{}
+	json.Unmarshal(body, &_user)
+	fmt.Println("find in forgetpass : ", _user.Result.Count)
+	if _user.Result.Count != 1 {
+		resp := _response{
+			Origin:  "forgetpassword",
+			Message: "Something goes wrong",
+			Code:    1001,
+		}
+		return c.JSON(http.StatusNotFound, resp)
+	}
+	b, err := json.Marshal(claims)
+	if err != nil {
+		fmt.Println("err:", err)
+	}
+	//fmt.Println("AddUser Claims: ", claims)
+	//fmt.Println("AddUser token: ", token)
+	username := _user.Result.Result[0].UID[0]
+	sha256 := sha256.Sum256([]byte(username))
+	var hashChannel = make(chan []byte, 1)
+	hashChannel <- sha256[:]
+	ciphertext := encrypt(<-hashChannel, string(b))
+	shortLink := setResetKey(ciphertext, username)
+	key, _ := getResetKey(username)
+	if len(key) > 5 {
+		resp := _response{
+			Origin:  "forgetpassword",
+			Message: "A resetLink request with this email already exists",
+			Code:    1003,
+		}
+		return c.JSON(http.StatusNotFound, resp)
+	}
+	go sendMail("Your temporary link is :\r\n https://zicloud.com/reset/"+shortLink, "ResetPassword Link", _user.Result.Result[0].Mail[0])
+
+	resp := _response{
+		Origin:  "forgetpassword",
+		Message: "You will receive an email with a link to reset your password",
+		Code:    1000,
+	}
+	return c.JSON(http.StatusNotFound, resp)
+}
+
+func setResetKey(key string, username string) string {
+	short := uniuri.NewLen(32)
+	db, err := sql.Open("mysql", MySQLUSER+":"+MySQLPASS+"@tcp(127.0.0.1:3306)/zicloud")
+	if err != nil {
+		return ""
+	}
+	defer db.Close()
+	insert, err := db.Query("INSERT INTO url_shortener VALUES ( '" + short + "'," +
+		"'" + key + "'," +
+		"NOW() + INTERVAL 1 HOUR" + "," +
+		"'" + "setResetKey" + "'," +
+		"'" + username + "'," +
+		"1" +
+		" )")
+	defer insert.Close()
+	return short
+}
+func getResetKey(short string) (string, string) {
+	db, _ := sql.Open("mysql", MySQLUSER+":"+MySQLPASS+"@tcp(127.0.0.1:3306)/zicloud")
+	results, _ := db.Query("SELECT `long` as `long`, related_obj as username FROM url_shortener where active=1 and short='" + short + "' and expiration > NOW()")
+	var key, username string
+	for results.Next() {
+		err := results.Scan(&key, &username)
+		if err != nil {
+			return "ERR", "ERR"
+		}
+	}
+
+	return key, username
+}
+func expireResetKey(username string) {
+	db, err := sql.Open("mysql", MySQLUSER+":"+MySQLPASS+"@tcp(127.0.0.1:3306)/zicloud")
+	if err != nil {
+		return
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
+	update, err := db.Query("update url_shortener set active='0' where related_obj='" + username + "'")
+	defer db.Close()
+	defer update.Close()
 
-	return c.JSON(http.StatusOK, string(b))
+}
+func (h *handler) ListServices(c echo.Context) error {
+	user := c.Get("user").(*jwt.Token)
+	claims := user.Claims.(jwt.MapClaims)
+	//IPAUid:=claims["IPAUid"]
+	_sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
+	var hashChannel_ = make(chan []byte, 1)
+	hashChannel_ <- _sha256[:]
+	token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
+	_BA := strings.Split(token, ";")
+	BA := _BA[len(_BA)-2]
+	db, _ := sql.Open("mysql", MySQLUSER+":"+MySQLPASS+"@tcp(127.0.0.1:3306)/zicloud")
+	results, _ := db.Query("SELECT `type` as `type`, uuid as Service_uuid , active , objectName FROM service_profile where uid=" + claims["IPAUid"].(string))
+	activeCount := 0
+	totalCount := 0
+	activeVMCount := 0
+	totalVMCount := 0
+	var cpu , mem float64
+	var _type, service_uuid, active, objectName string
+	for results.Next() {
+		err := results.Scan(&_type, &service_uuid, &active, &objectName)
+		if err != nil {
+			resp := _response{
+				Origin:  "ListServices",
+				Message: "Listing Error",
+				Code:    1001,
+			}
+			//b, _ := json.MarshalIndent(resp, "", "  ")
+			return c.JSON(http.StatusOK, resp)
+		}
+		if _type == "VM" {
+			if active == "1" {
+				activeCount++
+				activeVMCount++
+				//fmt.Println(vmStatistics(BA,service_uuid))
+				_,_cpu,_mem:=vmStatistics(BA,service_uuid)
+				cpu+=_cpu
+				mem+=_mem
+			}
+			totalCount++
+			totalVMCount++
+		}
+	}
+	//fmt.Println(activeVMCount)
+	//fmt.Println(activeCount)
+	//fmt.Println(totalCount)
+	//fmt.Println(totalVMCount)
+	//SL := ServiceList{
+	//	TotalCount:    string(totalCount),
+	//	ActiveCount:   string(activeCount),
+	//	ActiveVMCount: string(activeVMCount),
+	//	TotalVMCount:  string(totalVMCount),
+	//}
+	type AutoGenerated struct {
+		Message struct {
+			TotalCount    string `json:"TotalCount"`
+			ActiveCount   string `json:"ActiveCount"`
+			ActiveVMCount string `json:"ActiveVMCount"`
+			TotalVMCount  string `json:"TotalVMCount"`
+			TotalCPUUsage  string `json:"TotalCPUUsage"`
+			TotalMemUsage  string `json:"TotalMemUsage"`
+		} `json:"message"`
+		Origin string `json:"origin"`
+		Code   int    `json:"code"`
+	}
+	resp := AutoGenerated{
+		Message: struct {
+			TotalCount    string `json:"TotalCount"`
+			ActiveCount   string `json:"ActiveCount"`
+			ActiveVMCount string `json:"ActiveVMCount"`
+			TotalVMCount  string `json:"TotalVMCount"`
+			TotalCPUUsage  string `json:"TotalCPUUsage"`
+			TotalMemUsage  string `json:"TotalMemUsage"`
+		}{
+			TotalCount:    strconv.Itoa(totalCount),
+			ActiveCount:   strconv.Itoa(activeCount),
+			ActiveVMCount: strconv.Itoa(activeVMCount),
+			TotalVMCount:  strconv.Itoa(totalVMCount),
+			TotalCPUUsage:  fmt.Sprintf("%f", 100*cpu/float64(activeVMCount)),
+			TotalMemUsage:  fmt.Sprintf("%f", 100*mem/float64(activeVMCount)),
+		},
+		Origin: "ListServices",
+		Code:   1000,
+	}
+	return c.JSON(http.StatusOK, resp)
 }

+ 14 - 4
main.go

@@ -128,7 +128,9 @@ func main() {
 	echoHandler.POST("/resetUser", h.resetUser)
 	echoHandler.GET("/verifyUser", h.verifyUser)
 	echoHandler.POST("/dnsrecordadd", h.dnsrecordadd, isLoggedIn, isAdmin)
+	echoHandler.POST("/forgetpassword", h.forgetpassword, isLoggedIn, isAdmin)
 	echoHandler.POST("/token", h.token, isLoggedIn)
+	echoHandler.POST("/ListServices", h.ListServices, isLoggedIn)
 
 	iaas := &ovirt{}
 	echoHandler.GET("/ovirtListVMs", iaas.listVM, isLoggedIn)
@@ -142,6 +144,7 @@ func main() {
 	echoHandler.POST("/ovirtAddDisk", iaas.AddDisk, isLoggedIn)
 	echoHandler.POST("/ovirtEditVM", iaas.EditVM, isLoggedIn)
 	echoHandler.POST("/ovirtResetPassword", iaas.ResetPassword, isLoggedIn)
+	echoHandler.POST("/vmDetails", iaas.vmDetails, isLoggedIn)
 
 	echoHandler.Logger.Fatal(echoHandler.Start(os.Args[1] + ":" + os.Args[2]))
 }
@@ -150,14 +153,17 @@ func encrypt(key []byte, text string) string {
 	plaintext := []byte(text)
 	block, err := aes.NewCipher(key)
 	if err != nil {
-		panic(err)
+		//panic(err)
+		fmt.Sprintf("encrypt got error")
+		return ""
 	}
 	// The IV needs to be unique, but not secure. Therefore it's common to
 	// include it at the beginning of the ciphertext.
 	ciphertext := make([]byte, aes.BlockSize+len(plaintext))
 	iv := ciphertext[:aes.BlockSize]
 	if _, err := io.ReadFull(rand.Reader, iv); err != nil {
-		panic(err)
+		fmt.Sprintf("encrypt got error")
+		return ""
 	}
 
 	stream := cipher.NewCFBEncrypter(block, iv)
@@ -171,13 +177,17 @@ func decrypt(key []byte, cryptoText string) string {
 
 	block, err := aes.NewCipher(key)
 	if err != nil {
-		panic(err)
+		fmt.Sprintf("decrypt got error")
+		return ""
+		//panic(err)
 	}
 
 	// The IV needs to be unique, but not secure. Therefore it's common to
 	// include it at the beginning of the ciphertext.
 	if len(ciphertext) < aes.BlockSize {
-		panic("ciphertext too short")
+		fmt.Sprintf("ciphertext too short")
+		return ""
+		//panic("ciphertext too short")
 	}
 	iv := ciphertext[:aes.BlockSize]
 	ciphertext = ciphertext[aes.BlockSize:]

+ 548 - 32
ovirt.go

@@ -10,6 +10,7 @@ import (
 	"github.com/labstack/echo"
 	"io/ioutil"
 	"net/http"
+	"strconv"
 	"strings"
 )
 
@@ -90,6 +91,26 @@ type addVMTask struct {
 		Value string `json:"Value,omitempty"`
 	} `json:"headers"`
 }
+type VMStatistics struct {
+	Statistic []struct {
+		Kind   string `json:"kind"`
+		Type   string `json:"type"`
+		Unit   string `json:"unit"`
+		Values struct {
+			Value []struct {
+				Datum float64 `json:"datum"`
+			} `json:"value"`
+		} `json:"values"`
+		VM struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"vm,omitempty"`
+		Name        string `json:"name"`
+		Description string `json:"description"`
+		Href        string `json:"href,omitempty"`
+		ID          string `json:"id"`
+	} `json:"statistic"`
+}
 
 func (o ovirt) vmStatus(uuid string) string {
 	type vmStatus struct {
@@ -511,11 +532,12 @@ func (o ovirt) addvm(c echo.Context) error {
 	if err != nil {
 		resp := _response{
 			Origin:  "ovirt-addvm",
-			Message: "Error on pars AddVMResponse",
+			Message: "Error on pars AddVMResponse: " + err.Error(),
 			Code:    1001,
 		}
-		b, _ := json.MarshalIndent(resp, "", "  ")
-		return c.String(http.StatusBadRequest, string(b))
+		//b, _ := json.MarshalIndent(resp, "", "  ")
+		return c.JSON(http.StatusBadRequest, resp)
+		//return c.String(http.StatusBadRequest, string(b))
 	}
 	{
 
@@ -594,8 +616,9 @@ func (o ovirt) addvm(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 func (o ovirt) listVM(c echo.Context) error {
 	user := c.Get("user").(*jwt.Token)
@@ -628,8 +651,9 @@ func (o ovirt) listVM(c echo.Context) error {
 		Message: string(body),
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 
 func (o ovirt) StartVM(c echo.Context) error {
@@ -644,7 +668,7 @@ func (o ovirt) StartVM(c echo.Context) error {
 	BA := _BA[len(_BA)-2]
 	url := OvirtURL + "/ovirt-engine/api/vms/" + vmuuid + "/start"
 	method := "POST"
-	__json:="{\"async\":\"true\"}"
+	__json := "{\"async\":\"true\"}"
 	sha256 := sha256.Sum256([]byte(vmuuid))
 	var hashChannel = make(chan []byte, 1)
 	hashChannel <- sha256[:]
@@ -677,8 +701,9 @@ func (o ovirt) StartVM(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 
 func (o ovirt) StopVM(c echo.Context) error {
@@ -693,7 +718,7 @@ func (o ovirt) StopVM(c echo.Context) error {
 	BA := _BA[len(_BA)-2]
 	url := OvirtURL + "/ovirt-engine/api/vms/" + vmuuid + "/shutdown"
 	method := "POST"
-	__json:="{\"async\":\"true\"}"
+	__json := "{\"async\":\"true\"}"
 	sha256 := sha256.Sum256([]byte(vmuuid))
 	var hashChannel = make(chan []byte, 1)
 	hashChannel <- sha256[:]
@@ -726,8 +751,9 @@ func (o ovirt) StopVM(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 }
 
 func (o ovirt) RebootVM(c echo.Context) error {
@@ -742,7 +768,7 @@ func (o ovirt) RebootVM(c echo.Context) error {
 	BA := _BA[len(_BA)-2]
 	url := OvirtURL + "/ovirt-engine/api/vms/" + vmuuid + "/reboot"
 	method := "POST"
-	__json:="{\"async\":\"true\"}"
+	__json := "{\"async\":\"true\"}"
 	sha256 := sha256.Sum256([]byte(vmuuid))
 	var hashChannel = make(chan []byte, 1)
 	hashChannel <- sha256[:]
@@ -775,8 +801,9 @@ func (o ovirt) RebootVM(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 func (o ovirt) PowerOffVM(c echo.Context) error {
 	vmuuid := c.FormValue("VmUUID")
@@ -790,7 +817,7 @@ func (o ovirt) PowerOffVM(c echo.Context) error {
 	BA := _BA[len(_BA)-2]
 	url := OvirtURL + "/ovirt-engine/api/vms/" + vmuuid + "/stop"
 	method := "POST"
-	__json:="{\"async\":\"true\"}"
+	__json := "{\"async\":\"true\"}"
 	sha256 := sha256.Sum256([]byte(vmuuid))
 	var hashChannel = make(chan []byte, 1)
 	hashChannel <- sha256[:]
@@ -823,8 +850,9 @@ func (o ovirt) PowerOffVM(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 
 func (o ovirt) ResetVM(c echo.Context) error {
@@ -833,8 +861,9 @@ func (o ovirt) ResetVM(c echo.Context) error {
 		Message: "not implemented",
 		Code:    1003,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	return c.JSON(http.StatusOK, resp)
+	//return c.String(http.StatusOK, string(b))
 
 }
 
@@ -844,9 +873,9 @@ func (o ovirt) AddNIC(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
-
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 
 func (o ovirt) AddDisk(c echo.Context) error {
@@ -855,9 +884,9 @@ func (o ovirt) AddDisk(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
-
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 
 func (o ovirt) EditVM(c echo.Context) error {
@@ -866,9 +895,9 @@ func (o ovirt) EditVM(c echo.Context) error {
 		Message: "Done",
 		Code:    1000,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
-
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
 }
 
 func (o ovirt) ResetPassword(c echo.Context) error {
@@ -877,7 +906,494 @@ func (o ovirt) ResetPassword(c echo.Context) error {
 		Message: "not implemented",
 		Code:    1003,
 	}
-	b, _ := json.MarshalIndent(resp, "", "  ")
-	return c.String(http.StatusOK, string(b))
+	//b, _ := json.MarshalIndent(resp, "", "  ")
+	//return c.String(http.StatusOK, string(b))
+	return c.JSON(http.StatusOK, resp)
+}
+
+func vmStatistics(BA string, VMUUID string) (string, float64, float64) {
+	//ram,cpu,storage
+	var _disk []string
+	{
+		type DiskAttachments struct {
+			DiskAttachment []struct {
+				Active              string `json:"active"`
+				Bootable            string `json:"bootable"`
+				Interface           string `json:"interface"`
+				LogicalName         string `json:"logical_name"`
+				PassDiscard         string `json:"pass_discard"`
+				ReadOnly            string `json:"read_only"`
+				UsesScsiReservation string `json:"uses_scsi_reservation"`
+				Disk                struct {
+					Href string `json:"href"`
+					ID   string `json:"id"`
+				} `json:"disk"`
+				VM struct {
+					Href string `json:"href"`
+					ID   string `json:"id"`
+				} `json:"vm"`
+				Href string `json:"href"`
+				ID   string `json:"id"`
+			} `json:"disk_attachment"`
+		}
+
+		url := OvirtURL + "/ovirt-engine/api/vms/" + VMUUID + "/diskattachments"
+		//fmt.Println("Url:" ,url)
+		method := "GET"
+
+		client := &http.Client{
+		}
+		req, err := http.NewRequest(method, url, nil)
+
+		if err != nil {
+			return "", -1, -1
+		}
+		req.Header.Add("Version", "4")
+		req.Header.Add("Accept", "application/json")
+		req.Header.Add("Authorization", BA)
+
+		res, err := client.Do(req)
+		defer res.Body.Close()
+		body, err := ioutil.ReadAll(res.Body)
+		diskattachments := DiskAttachments{}
+		_err := json.Unmarshal(body, &diskattachments)
+		if _err != nil {
+			fmt.Println("Error: ", _err)
+		}
+		for _, v := range diskattachments.DiskAttachment {
+			url := OvirtURL + "/ovirt-engine/api/disks/" + v.Disk.ID
+			type DiskAttachment struct {
+				ActualSize      string `json:"actual_size"`
+				Alias           string `json:"alias"`
+				Backup          string `json:"backup"`
+				ContentType     string `json:"content_type"`
+				Format          string `json:"format"`
+				ImageID         string `json:"image_id"`
+				PropagateErrors string `json:"propagate_errors"`
+				ProvisionedSize string `json:"provisioned_size"`
+				QcowVersion     string `json:"qcow_version"`
+				Shareable       string `json:"shareable"`
+				Sparse          string `json:"sparse"`
+				Status          string `json:"status"`
+				StorageType     string `json:"storage_type"`
+				TotalSize       string `json:"total_size"`
+				WipeAfterDelete string `json:"wipe_after_delete"`
+				DiskProfile     struct {
+					Href string `json:"href"`
+					ID   string `json:"id"`
+				} `json:"disk_profile"`
+				Quota struct {
+					Href string `json:"href"`
+					ID   string `json:"id"`
+				} `json:"quota"`
+				StorageDomains struct {
+					StorageDomain []struct {
+						Href string `json:"href"`
+						ID   string `json:"id"`
+					} `json:"storage_domain"`
+				} `json:"storage_domains"`
+				Actions struct {
+					Link []struct {
+						Href string `json:"href"`
+						Rel  string `json:"rel"`
+					} `json:"link"`
+				} `json:"actions"`
+				Name        string `json:"name"`
+				Description string `json:"description"`
+				Href        string `json:"href"`
+				ID          string `json:"id"`
+				Link        []struct {
+					Href string `json:"href"`
+					Rel  string `json:"rel"`
+				} `json:"link"`
+			}
+			//fmt.Println("Url:" ,url)
+			method := "GET"
+
+			client := &http.Client{
+			}
+			req, _ := http.NewRequest(method, url, nil)
+
+			//if err != nil {
+			//	return "Null"
+			//}
+			req.Header.Add("Version", "4")
+			req.Header.Add("Accept", "application/json")
+			req.Header.Add("Authorization", BA)
+
+			res, _ := client.Do(req)
+			defer res.Body.Close()
+			body, _ := ioutil.ReadAll(res.Body)
+
+			//fmt.Println("full response: ",string(body))
+			disk := DiskAttachment{}
+			_err := json.Unmarshal(body, &disk)
+			if _err != nil {
+				fmt.Println("Error: ", _err)
+			}
+			_disk = append(_disk, disk.ProvisionedSize)
+
+			//_disk = D_disk + "" + disk.ProvisionedSize+" "
+		}
+
+	}
+	url := OvirtURL + "/ovirt-engine/api/vms/" + VMUUID + "/statistics"
+	//fmt.Println("Url:" ,url)
+	method := "GET"
 
+	client := &http.Client{
+	}
+	req, err := http.NewRequest(method, url, nil)
+
+	if err != nil {
+		return "", -1, -1
+	}
+	req.Header.Add("Version", "4")
+	req.Header.Add("Accept", "application/json")
+	req.Header.Add("Authorization", BA)
+
+	res, err := client.Do(req)
+	defer res.Body.Close()
+	body, err := ioutil.ReadAll(res.Body)
+
+	//fmt.Println("full response: ",string(body))
+	_vmstatistics := VMStatistics{}
+	_err := json.Unmarshal(body, &_vmstatistics)
+	if _err != nil {
+		fmt.Println("Error: ", _err)
+	}
+	cpuUUID := _vmstatistics.Statistic[4].ID
+	memUsedUUID := _vmstatistics.Statistic[1].ID
+	memTotalUUID := _vmstatistics.Statistic[0].ID
+	//fmt.Println(memUsedUUID)
+	var cpu, memUsed, memTotal string
+	type ItemUsage struct {
+		Kind   string `json:"kind"`
+		Type   string `json:"type"`
+		Unit   string `json:"unit"`
+		Values struct {
+			Value []struct {
+				Datum float64 `json:"datum"`
+			} `json:"value"`
+		} `json:"values"`
+		VM struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"vm"`
+		Name        string `json:"name"`
+		Description string `json:"description"`
+		Href        string `json:"href"`
+		ID          string `json:"id"`
+	}
+	{
+		url := OvirtURL + "/ovirt-engine/api/vms/" + VMUUID + "/statistics/" + cpuUUID
+		//fmt.Println("Url:" ,url)
+		method := "GET"
+
+		client := &http.Client{
+		}
+		req, err := http.NewRequest(method, url, nil)
+
+		if err != nil {
+			return "", -1, -1
+		}
+		req.Header.Add("Version", "4")
+		req.Header.Add("Accept", "application/json")
+		req.Header.Add("Authorization", BA)
+
+		res, err := client.Do(req)
+		defer res.Body.Close()
+		body, err := ioutil.ReadAll(res.Body)
+		cpuUsage := ItemUsage{}
+		_err := json.Unmarshal(body, &cpuUsage)
+		if _err != nil {
+			fmt.Println("Error: ", _err)
+		}
+		cpu = fmt.Sprintf("%f", cpuUsage.Values.Value[0].Datum)
+	}
+	{
+		url := OvirtURL + "/ovirt-engine/api/vms/" + VMUUID + "/statistics/" + memUsedUUID
+		//fmt.Println("Url:" ,url)
+		method := "GET"
+
+		client := &http.Client{
+		}
+		req, err := http.NewRequest(method, url, nil)
+
+		if err != nil {
+			return "", -1, -1
+		}
+		req.Header.Add("Version", "4")
+		req.Header.Add("Accept", "application/json")
+		req.Header.Add("Authorization", BA)
+
+		res, err := client.Do(req)
+		defer res.Body.Close()
+		body, err := ioutil.ReadAll(res.Body)
+		memUsage := ItemUsage{}
+		_err := json.Unmarshal(body, &memUsage)
+		if _err != nil {
+			fmt.Println("Error: ", _err)
+		}
+		memUsed = fmt.Sprintf("%f", memUsage.Values.Value[0].Datum)
+	}
+	{
+		url := OvirtURL + "/ovirt-engine/api/vms/" + VMUUID + "/statistics/" + memTotalUUID
+		//fmt.Println("Url:" ,url)
+		method := "GET"
+
+		client := &http.Client{
+		}
+		req, err := http.NewRequest(method, url, nil)
+
+		if err != nil {
+			return "", -1, -1
+		}
+		req.Header.Add("Version", "4")
+		req.Header.Add("Accept", "application/json")
+		req.Header.Add("Authorization", BA)
+
+		res, err := client.Do(req)
+		defer res.Body.Close()
+		body, err := ioutil.ReadAll(res.Body)
+		memUsage := ItemUsage{}
+		_err := json.Unmarshal(body, &memUsage)
+		if _err != nil {
+			fmt.Println("Error: ", _err)
+		}
+		memTotal = fmt.Sprintf("%f", memUsage.Values.Value[0].Datum)
+	}
+	//fmt.Println("CPU:" ,cpu)
+	//fmt.Println("MEM:", memUsed)
+	//fmt.Println("MEM:", memTotal)
+	_memusage, _ := strconv.ParseFloat(memUsed, 32)
+	_memtotal, _ := strconv.ParseFloat(memTotal, 32)
+	mem := _memusage / _memtotal
+
+	_cpu, _ := strconv.ParseFloat(cpu, 64)
+	return strings.Join(_disk,", "), _cpu, mem
+
+}
+func (o ovirt) vmDetails(c echo.Context) error {
+	//name,...,traffic,ip,status
+	user := c.Get("user").(*jwt.Token)
+	claims := user.Claims.(jwt.MapClaims)
+	_sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
+	var hashChannel_ = make(chan []byte, 1)
+	hashChannel_ <- _sha256[:]
+	token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
+	_BA := strings.Split(token, ";")
+	BA := _BA[len(_BA)-2]
+	uuid := c.FormValue("uuid")
+	if len(uuid) < 5 {
+		resp := _response{
+			Origin:  "AddUser",
+			Message: "Missing UUID",
+			Code:    1001,
+		}
+		return c.JSON(http.StatusNotFound, resp)
+	}
+	type vmStatus struct {
+		NextRunConfigurationExists string `json:"next_run_configuration_exists"`
+		NumaTuneMode               string `json:"numa_tune_mode"`
+		Status                     string `json:"status"`
+		StopTime                   int64  `json:"stop_time"`
+		OriginalTemplate           struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"original_template"`
+		Template struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"template"`
+		Actions struct {
+			Link []struct {
+				Href string `json:"href"`
+				Rel  string `json:"rel"`
+			} `json:"link"`
+		} `json:"actions"`
+		Name        string `json:"name"`
+		Description string `json:"description"`
+		Comment     string `json:"comment"`
+		Href        string `json:"href"`
+		ID          string `json:"id"`
+		Bios        struct {
+			BootMenu struct {
+				Enabled string `json:"enabled"`
+			} `json:"boot_menu"`
+			Type string `json:"type"`
+		} `json:"bios"`
+		CPU struct {
+			Architecture string `json:"architecture"`
+			Topology     struct {
+				Cores   string `json:"cores"`
+				Sockets string `json:"sockets"`
+				Threads string `json:"threads"`
+			} `json:"topology"`
+		} `json:"cpu"`
+		Display struct {
+			AllowOverride       string `json:"allow_override"`
+			CopyPasteEnabled    string `json:"copy_paste_enabled"`
+			DisconnectAction    string `json:"disconnect_action"`
+			FileTransferEnabled string `json:"file_transfer_enabled"`
+			Monitors            string `json:"monitors"`
+			SingleQxlPci        string `json:"single_qxl_pci"`
+			SmartcardEnabled    string `json:"smartcard_enabled"`
+			Type                string `json:"type"`
+		} `json:"display"`
+		Initialization struct {
+			AuthorizedSSHKeys        string `json:"authorized_ssh_keys"`
+			CloudInitNetworkProtocol string `json:"cloud_init_network_protocol"`
+			CustomScript             string `json:"custom_script"`
+			HostName                 string `json:"host_name"`
+			NicConfigurations        struct {
+			} `json:"nic_configurations"`
+			RegenerateSSHKeys string `json:"regenerate_ssh_keys"`
+			UserName          string `json:"user_name"`
+		} `json:"initialization"`
+		Io struct {
+			Threads string `json:"threads"`
+		} `json:"io"`
+		Memory    string `json:"memory"`
+		Migration struct {
+			AutoConverge string `json:"auto_converge"`
+			Compressed   string `json:"compressed"`
+			Encrypted    string `json:"encrypted"`
+		} `json:"migration"`
+		Origin string `json:"origin"`
+		Os     struct {
+			Boot struct {
+				Devices struct {
+					Device []string `json:"device"`
+				} `json:"devices"`
+			} `json:"boot"`
+			Type string `json:"type"`
+		} `json:"os"`
+		Sso struct {
+			Methods struct {
+				Method []struct {
+					ID string `json:"id"`
+				} `json:"method"`
+			} `json:"methods"`
+		} `json:"sso"`
+		Stateless string `json:"stateless"`
+		Type      string `json:"type"`
+		Usb       struct {
+			Enabled string `json:"enabled"`
+		} `json:"usb"`
+		Cluster struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"cluster"`
+		Quota struct {
+			ID string `json:"id"`
+		} `json:"quota"`
+		Link []struct {
+			Href string `json:"href"`
+			Rel  string `json:"rel"`
+		} `json:"link"`
+		CPUShares        string `json:"cpu_shares"`
+		CreationTime     int64  `json:"creation_time"`
+		DeleteProtected  string `json:"delete_protected"`
+		HighAvailability struct {
+			Enabled  string `json:"enabled"`
+			Priority string `json:"priority"`
+		} `json:"high_availability"`
+		LargeIcon struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"large_icon"`
+		MemoryPolicy struct {
+			Ballooning string `json:"ballooning"`
+			Guaranteed string `json:"guaranteed"`
+			Max        string `json:"max"`
+		} `json:"memory_policy"`
+		MigrationDowntime  string `json:"migration_downtime"`
+		MultiQueuesEnabled string `json:"multi_queues_enabled"`
+		PlacementPolicy    struct {
+			Affinity string `json:"affinity"`
+			Hosts    struct {
+				Host []struct {
+					Href string `json:"href"`
+					ID   string `json:"id"`
+				} `json:"host"`
+			} `json:"hosts"`
+		} `json:"placement_policy"`
+		SmallIcon struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"small_icon"`
+		StartPaused                 string `json:"start_paused"`
+		StorageErrorResumeBehaviour string `json:"storage_error_resume_behaviour"`
+		TimeZone                    struct {
+			Name string `json:"name"`
+		} `json:"time_zone"`
+		CPUProfile struct {
+			Href string `json:"href"`
+			ID   string `json:"id"`
+		} `json:"cpu_profile"`
+	}
+	//url := "https://ovirt-cl.zi-tel.com/ovirt-engine/api/vms/c1a44128-6c6c-406b-99d8-4a68a99380c9"
+	url := OvirtURL + "/ovirt-engine/api/vms/" + uuid
+	//fmt.Println("Url:" ,url)
+	method := "GET"
+
+	client := &http.Client{
+	}
+	req, _ := http.NewRequest(method, url, nil)
+
+	//if err != nil {
+	//	return "Null"
+	//}
+	req.Header.Add("Version", "4")
+	req.Header.Add("Accept", "application/json")
+	req.Header.Add("Authorization", BA)
+
+	res, _ := client.Do(req)
+	defer res.Body.Close()
+	body, _ := ioutil.ReadAll(res.Body)
+
+	//fmt.Println("full response: ",string(body))
+	_vmstatus := vmStatus{}
+	_err := json.Unmarshal(body, &_vmstatus)
+	if _err != nil {
+		fmt.Println("Error: ", _err)
+	}
+	disk, cpu, ram := vmStatistics(BA, uuid)
+	type AutoGenerated struct {
+		Message struct {
+			Disk       string `json:"Disk"`
+			Memory     string `json:"Memory"`
+			CPU        string `json:"CPU"`
+			NetAddress string `json:"NetAddress"`
+			Traffic    string `json:"Traffic"`
+			Status     string `json:"Status"`
+			Name       string `json:"Name"`
+		} `json:"message"`
+		Origin string `json:"origin"`
+		Code   int    `json:"code"`
+	}
+	resp := AutoGenerated{
+		Message: struct {
+			Disk       string `json:"Disk"`
+			Memory     string `json:"Memory"`
+			CPU        string `json:"CPU"`
+			NetAddress string `json:"NetAddress"`
+			Traffic    string `json:"Traffic"`
+			Status     string `json:"Status"`
+			Name       string `json:"Name"`
+		}{
+			Disk:       disk,
+			Memory:     fmt.Sprintf("%f", ram),
+			CPU:        fmt.Sprintf("%f", cpu),
+			NetAddress: "",
+			Traffic:    "",
+			Status:     _vmstatus.Status,
+			Name:       _vmstatus.Name,
+		},
+		Origin: "vmDetails",
+		Code:   1000,
+	}
+	return c.JSON(http.StatusOK, resp)
+	//return _vmstatus.Status, _vmstatus.Name, disk, cpu, ram
 }