mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-11-05 15:31:49 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user