Merge pull request #475 from wanyaoqi/bugfix/wyq/guest-start-monitor-on-syncstatus

guest start monitor on sync status
This commit is contained in:
yunion-ci-robot
2019-04-22 10:46:11 +08:00
committed by GitHub
+20 -5
View File
@@ -47,6 +47,12 @@ import (
const (
VNC_PORT_BASE = 5900
GUEST_RUNNING = "running"
GUEST_BLOCK_STREAM = "block_stream"
GUEST_SUSPEND = "suspend"
GUSET_STOPPED = "stopped"
GUEST_NOT_FOUND = "notfound"
)
type SGuestManager struct {
@@ -344,19 +350,28 @@ func (m *SGuestManager) CpusetBalance(ctx context.Context, params interface{}) (
}
func (m *SGuestManager) Status(sid string) string {
if status := m.GetStatus(sid); status == GUEST_RUNNING && m.Servers[sid].Monitor == nil {
m.Servers[sid].StartMonitor(context.Background())
return status
} else {
return status
}
}
func (m *SGuestManager) GetStatus(sid string) string {
if guest, ok := m.Servers[sid]; ok {
if guest.Monitor != nil && guest.IsMaster() && !guest.IsMirrorJobSucc() {
return "block_stream"
return GUEST_BLOCK_STREAM
}
if guest.IsRunning() {
return "running"
return GUEST_RUNNING
} else if guest.IsSuspend() {
return "suspend"
return GUEST_SUSPEND
} else {
return "stopped"
return GUSET_STOPPED
}
} else {
return "notfound"
return GUEST_NOT_FOUND
}
}