Automatic merge from release/2.1.0 -> release/2.2.0

* commit '81fbc232ef26bc2b942b5bca8db8587e33ad2472':
  fix: kvm find vnc port index out of range
This commit is contained in:
李泽玺
2018-10-24 19:17:29 +08:00
committed by 屈轩
2 changed files with 5 additions and 8 deletions
+4 -5
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"net/http"
"regexp"
"strconv"
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
@@ -81,10 +81,9 @@ func (self *SKVMGuestDriver) RequestReloadDiskSnapshot(ctx context.Context, gues
}
func findVNCPort(results string) int {
reg := regexp.MustCompile(`(\d+\.\d+\.\d+\.\d+):([\d]+)`)
finds := reg.FindStringSubmatch(results)
log.Debugf("finds=%s", finds)
port, _ := strconv.Atoi(finds[2])
vncInfo := strings.Split(results, "\n")
addrParts := strings.Split(vncInfo[1], ":")
port, _ := strconv.Atoi(addrParts[len(addrParts)-1])
return port
}
+1 -3
View File
@@ -311,10 +311,8 @@ func (self *SInstance) GetStatus() string {
if code := strings.Split(statuses.Code, "/"); len(code) == 2 {
if code[0] == "PowerState" {
switch code[1] {
case "stopped":
case "stopped", "deallocated":
return models.VM_READY
case "deallocated":
return models.VM_DEALLOCATED
case "running":
return models.VM_RUNNING
case "stopping":