mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #14304 from swordqiu/feature/qj-daemon-server-support
feature: daemon server support
This commit is contained in:
@@ -744,6 +744,8 @@ type GuestJsonDesc struct {
|
||||
} `json:"instance_snapshot_info"`
|
||||
|
||||
EncryptKeyId string `json:"encrypt_key_id,omitempty"`
|
||||
|
||||
IsDaemon bool `json:"is_daemon"`
|
||||
}
|
||||
|
||||
type ServerChangeDiskStorageInput struct {
|
||||
|
||||
@@ -163,6 +163,8 @@ type SGuest struct {
|
||||
InstanceType string `width:"64" charset:"utf8" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
SshableLastState tristate.TriState `default:"false" list:"user"`
|
||||
|
||||
IsDaemon tristate.TriState `default:"false" list:"user" create:"optional" update:"user"`
|
||||
}
|
||||
|
||||
// 云主机实例列表
|
||||
@@ -4248,6 +4250,8 @@ func (self *SGuest) GetJsonDescAtHypervisor(ctx context.Context, host *SHost) *a
|
||||
HostId: host.Id,
|
||||
|
||||
EncryptKeyId: self.EncryptKeyId,
|
||||
|
||||
IsDaemon: self.IsDaemon.Bool(),
|
||||
}
|
||||
|
||||
if len(self.BackupHostId) > 0 {
|
||||
|
||||
@@ -299,6 +299,10 @@ func (s *SKVMGuestInstance) IsDirtyShotdown() bool {
|
||||
return s.GetPid() == -2
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) IsDaemon() bool {
|
||||
return jsonutils.QueryBoolean(s.Desc, "is_daemon", false)
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) DirtyServerRequestStart() {
|
||||
hostId, _ := s.Desc.GetString("host_id")
|
||||
var body = jsonutils.NewDict()
|
||||
@@ -419,8 +423,8 @@ func (s *SKVMGuestInstance) ImportServer(pendingDelete bool) {
|
||||
s.manager.SaveServer(s.Id, s)
|
||||
s.manager.RemoveCandidateServer(s)
|
||||
|
||||
if s.IsDirtyShotdown() && !pendingDelete {
|
||||
log.Infof("Server dirty shotdown %s", s.GetName())
|
||||
if (s.IsDirtyShotdown() || s.IsDaemon()) && !pendingDelete {
|
||||
log.Infof("Server dirty shotdown or a daemon %s", s.GetName())
|
||||
if jsonutils.QueryBoolean(s.Desc, "is_master", false) ||
|
||||
jsonutils.QueryBoolean(s.Desc, "is_slave", false) {
|
||||
go s.DirtyServerRequestStart()
|
||||
|
||||
@@ -615,6 +615,8 @@ type ServerUpdateOptions struct {
|
||||
Delete string `help:"Lock server to prevent from deleting" choices:"enable|disable" json:"-"`
|
||||
ShutdownBehavior string `help:"Behavior after VM server shutdown" choices:"stop|terminate"`
|
||||
Machine string `help:"Machine type" choices:"q35|pc"`
|
||||
|
||||
IsDaemon *bool `help:"Daemon server" negative:"no-daemon"`
|
||||
}
|
||||
|
||||
func (opts *ServerUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
|
||||
Reference in New Issue
Block a user