-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunstate.go
98 lines (90 loc) · 3 KB
/
runstate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package qcli
type RunState int
const (
RunStateDebug RunState = iota
RunStateFinishMigrate
RunStateInMigrate
RunStateInternalError
RunStateIOError
RunStatePaused
RunStatePostMigrate
RunStatePreLaunch
RunStateRestoreVM
RunStateRunning
RunStateSaveVM
RunStateShutdown
RunStateSuspended
RunStateWatchdog
RunStateGuestPanicked
RunStateColo
RunStateUnknown
)
const (
RunStateDebugStr string = "debug"
RunStateFinishMigrateStr string = "finish-migrate"
RunStateInMigrateStr string = "inmigrate"
RunStateInternalErrorStr string = "internal-error"
RunStateIOErrorStr string = "io-error"
RunStatePausedStr string = "paused"
RunStatePostMigrateStr string = "postmigrate"
RunStatePreLaunchStr string = "prelaunch"
RunStateRestoreVMStr string = "restore-vm"
RunStateRunningStr string = "running"
RunStateSaveVMStr string = "save-vm"
RunStateShutdownStr string = "shutdown"
RunStateSuspendedStr string = "suspended"
RunStateWatchdogStr string = "watchdog"
RunStateGuestPanickedStr string = "guest-panicked"
RunStateColoStr string = "colo"
RunStateUnknownStr string = "unknown"
)
func (rs RunState) String() string {
toString := map[RunState]string{
RunStateDebug: RunStateDebugStr,
RunStateFinishMigrate: RunStateFinishMigrateStr,
RunStateInMigrate: RunStateInMigrateStr,
RunStateInternalError: RunStateInternalErrorStr,
RunStateIOError: RunStateIOErrorStr,
RunStatePaused: RunStatePausedStr,
RunStatePostMigrate: RunStatePostMigrateStr,
RunStatePreLaunch: RunStatePreLaunchStr,
RunStateRestoreVM: RunStateRestoreVMStr,
RunStateRunning: RunStateRunningStr,
RunStateSaveVM: RunStateSaveVMStr,
RunStateShutdown: RunStateShutdownStr,
RunStateSuspended: RunStateSuspendedStr,
RunStateWatchdog: RunStateWatchdogStr,
RunStateGuestPanicked: RunStateGuestPanickedStr,
RunStateColo: RunStateColoStr,
RunStateUnknown: RunStateUnknownStr,
}
if rs, ok := toString[rs]; ok {
return rs
}
return RunStateUnknownStr
}
func ToRunState(status string) RunState {
toRunState := map[string]RunState{
RunStateDebugStr: RunStateDebug,
RunStateFinishMigrateStr: RunStateFinishMigrate,
RunStateInMigrateStr: RunStateInMigrate,
RunStateInternalErrorStr: RunStateInternalError,
RunStateIOErrorStr: RunStateIOError,
RunStatePausedStr: RunStatePaused,
RunStatePostMigrateStr: RunStatePostMigrate,
RunStatePreLaunchStr: RunStatePreLaunch,
RunStateRestoreVMStr: RunStateRestoreVM,
RunStateRunningStr: RunStateRunning,
RunStateSaveVMStr: RunStateSaveVM,
RunStateShutdownStr: RunStateShutdown,
RunStateSuspendedStr: RunStateSuspended,
RunStateWatchdogStr: RunStateWatchdog,
RunStateGuestPanickedStr: RunStateGuestPanicked,
RunStateColoStr: RunStateColo,
RunStateUnknownStr: RunStateUnknown,
}
if rs, ok := toRunState[status]; ok {
return rs
}
return RunStateUnknown
}