mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
Automated cherry pick of #21876: Automated cherry pick of #21875: Automated cherry pick of #21804: [WIP] fix: add more action log (#21878)
* fix: add more action log * fix(region): add set cmt bound action
This commit is contained in:
@@ -54,6 +54,7 @@ func init() {
|
||||
cmd.Perform("class-metadata", &options.ResourceMetadataOptions{})
|
||||
cmd.Perform("set-class-metadata", &options.ResourceMetadataOptions{})
|
||||
cmd.PerformClass("validate-ipmi", &compute.HostValidateIPMI{})
|
||||
cmd.Perform("set-commit-bound", &compute.HostSetCommitBoundOptions{})
|
||||
|
||||
cmd.BatchPerform("enable", &options.BaseIdsOptions{})
|
||||
cmd.BatchPerform("disable", &options.BaseIdsOptions{})
|
||||
@@ -201,14 +202,12 @@ func init() {
|
||||
})
|
||||
|
||||
type HostUpdateOptions struct {
|
||||
ID string `help:"ID or Name of Host"`
|
||||
Name string `help:"New name of the host"`
|
||||
Desc string `help:"New Description of the host"`
|
||||
CpuCommitBound float64 `help:"CPU overcommit upper bound at this host"`
|
||||
MemoryCommitBound float64 `help:"Memory overcommit upper bound at this host"`
|
||||
MemoryReserved string `help:"Memory reserved"`
|
||||
CpuReserved int64 `help:"CPU reserved"`
|
||||
HostType string `help:"Change host type, CAUTION!!!!" choices:"hypervisor|kubelet|esxi|baremetal"`
|
||||
ID string `help:"ID or Name of Host"`
|
||||
Name string `help:"New name of the host"`
|
||||
Desc string `help:"New Description of the host"`
|
||||
MemoryReserved string `help:"Memory reserved"`
|
||||
CpuReserved int64 `help:"CPU reserved"`
|
||||
HostType string `help:"Change host type, CAUTION!!!!" choices:"hypervisor|kubelet|esxi|baremetal"`
|
||||
// AccessIp string `help:"Change access ip, CAUTION!!!!"`
|
||||
AccessMac string `help:"Change baremetal access MAC, CAUTION!!!!"`
|
||||
Uuid string `help:"Change baremetal UUID, CAUTION!!!!"`
|
||||
@@ -234,12 +233,6 @@ func init() {
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if args.CpuCommitBound > 0.0 {
|
||||
params.Add(jsonutils.NewFloat64(args.CpuCommitBound), "cpu_cmtbound")
|
||||
}
|
||||
if args.MemoryCommitBound > 0.0 {
|
||||
params.Add(jsonutils.NewFloat64(args.MemoryCommitBound), "mem_cmtbound")
|
||||
}
|
||||
if len(args.MemoryReserved) > 0 {
|
||||
params.Add(jsonutils.NewString(args.MemoryReserved), "mem_reserved")
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ func init() {
|
||||
cmd.Perform("private", &options.BaseIdOptions{})
|
||||
cmd.Get("hardware-info", &options.BaseIdOptions{})
|
||||
cmd.Perform("set-hardware-info", &compute.StorageSetHardwareInfoOptions{})
|
||||
cmd.Perform("set-commit-bound", &compute.StorageSetCommitBoundOptions{})
|
||||
|
||||
type StorageCephRunOptions struct {
|
||||
ID string `help:"ID or name of ceph storage"`
|
||||
|
||||
@@ -663,3 +663,8 @@ type HostLoginInfoOutput struct {
|
||||
|
||||
type HostPerformStartInput struct {
|
||||
}
|
||||
|
||||
type HostSetCommitBoundInput struct {
|
||||
CpuCmtbound *float32
|
||||
MemCmtbound *float32
|
||||
}
|
||||
|
||||
@@ -258,3 +258,7 @@ type StorageUpdateInput struct {
|
||||
HardwareInfo *StorageHardwareInfo `json:"hardware_info"`
|
||||
MasterHost string
|
||||
}
|
||||
|
||||
type StorageSetCmtBoundInput struct {
|
||||
Cmtbound *float32
|
||||
}
|
||||
|
||||
@@ -339,4 +339,6 @@ const (
|
||||
|
||||
ACT_REBUILD = "rebuild"
|
||||
ACT_REBUILD_FAILED = "rebuild_failed"
|
||||
|
||||
ACT_SET_COMMIT_BOUND = "set_commit_bound"
|
||||
)
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
ansible_modules "yunion.io/x/onecloud/pkg/mcclient/modules/ansible"
|
||||
cloudproxy_module "yunion.io/x/onecloud/pkg/mcclient/modules/cloudproxy"
|
||||
"yunion.io/x/onecloud/pkg/util/ansible"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
ssh_util "yunion.io/x/onecloud/pkg/util/ssh"
|
||||
)
|
||||
|
||||
@@ -109,6 +110,7 @@ func (guest *SGuest) GetDetailsSshable(
|
||||
}
|
||||
}
|
||||
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_TRYSSHABLE, nil, userCred, true)
|
||||
return tryData.outputJSON(), nil
|
||||
}
|
||||
|
||||
@@ -498,6 +500,7 @@ func (guest *SGuest) PerformMakeSshable(
|
||||
return output, httperrors.NewGeneralError(err)
|
||||
}
|
||||
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_MAKESSHABLE, nil, userCred, true)
|
||||
output = compute_api.GuestMakeSshableOutput{
|
||||
AnsiblePlaybookId: pbModel.Id,
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ type SHost struct {
|
||||
// 预留CPU大小
|
||||
CpuReserved int `nullable:"true" default:"0" list:"domain" update:"domain" create:"domain_optional"`
|
||||
// CPU超分比
|
||||
CpuCmtbound float32 `nullable:"true" default:"8" list:"domain" update:"domain" create:"domain_optional"`
|
||||
CpuCmtbound float32 `nullable:"true" default:"8" list:"domain" create:"domain_optional"`
|
||||
// CPUMicrocode
|
||||
CpuMicrocode string `width:"64" charset:"ascii" nullable:"true" get:"domain" update:"domain" create:"domain_optional"`
|
||||
// CPU架构
|
||||
@@ -150,7 +150,7 @@ type SHost struct {
|
||||
// 预留内存大小
|
||||
MemReserved int `nullable:"true" default:"0" list:"domain" update:"domain" create:"domain_optional"`
|
||||
// 内存超分比
|
||||
MemCmtbound float32 `nullable:"true" default:"1" list:"domain" update:"domain" create:"domain_optional"`
|
||||
MemCmtbound float32 `nullable:"true" default:"1" list:"domain" create:"domain_optional"`
|
||||
// 页大小
|
||||
PageSizeKB int `nullable:"false" default:"4" list:"domain" update:"domain" create:"domain_optional"`
|
||||
EnableNumaAllocate bool `nullable:"true" default:"false" list:"domain" update:"domain" create:"domain_optional"`
|
||||
@@ -1057,6 +1057,29 @@ func (hh *SHost) saveUpdates(doUpdate func() error, doSchedClean bool) (map[stri
|
||||
return diff, nil
|
||||
}
|
||||
|
||||
func (hh *SHost) PerformSetCommitBound(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
input api.HostSetCommitBoundInput,
|
||||
) (jsonutils.JSONObject, error) {
|
||||
_, err := db.Update(hh, func() error {
|
||||
if input.CpuCmtbound != nil {
|
||||
hh.CpuCmtbound = *input.CpuCmtbound
|
||||
}
|
||||
if input.MemCmtbound != nil {
|
||||
hh.MemCmtbound = *input.MemCmtbound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db.OpsLog.LogEvent(hh, db.ACT_SET_COMMIT_BOUND, input, userCred)
|
||||
logclient.AddActionLogWithContext(ctx, hh, logclient.ACT_SET_COMMIT_BOUND, input, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (hh *SHost) PerformUpdateStorage(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
@@ -4814,6 +4837,7 @@ func (hh *SHost) PerformAutoMigrateOnHostDown(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logclient.AddActionLogWithContext(ctx, hh, logclient.ACT_AUTO_MIGRATE_ON_HOST_DOWN, nil, userCred, true)
|
||||
return nil, hh.SetAllMetadata(ctx, meta, userCred)
|
||||
}
|
||||
|
||||
@@ -6049,7 +6073,9 @@ func (hh *SHost) PerformUndoConvert(ctx context.Context, userCred mcclient.Token
|
||||
}
|
||||
db.OpsLog.LogEvent(&guest, db.ACT_DELETE, "Unconvert baremetal", userCred)
|
||||
}
|
||||
|
||||
db.OpsLog.LogEvent(hh, db.ACT_UNCONVERT_START, "", userCred)
|
||||
logclient.AddActionLogWithContext(ctx, hh, logclient.ACT_UNCONVERT_START, nil, userCred, true)
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "BaremetalUnconvertHypervisorTask", hh, userCred, nil, "", "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -6538,6 +6564,7 @@ func (host *SHost) PerformHostExitMaintenance(ctx context.Context, userCred mccl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logclient.AddSimpleActionLog(host, logclient.ACT_HOST_UNMAINTENANCE, "host unmaintenance", userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -7127,6 +7154,7 @@ func (host *SHost) PerformSetReservedResourceForIsolatedDevice(
|
||||
return nil, errors.Wrap(err, "update isolated device")
|
||||
}
|
||||
}
|
||||
logclient.AddSimpleActionLog(host, logclient.ACT_SET_RESERVE_RESOURCE_FOR_ISOLATED_DEVICES, nil, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
@@ -124,6 +125,7 @@ func (manager *SReservedipManager) ReserveIPWithDurationAndStatus(ctx context.Co
|
||||
}
|
||||
}
|
||||
db.OpsLog.LogEvent(network, db.ACT_RESERVE_IP, rip.GetShortDesc(ctx), userCred)
|
||||
logclient.AddSimpleActionLog(network, logclient.ACT_RESERVE_IP, rip.GetShortDesc(ctx), userCred, true)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -222,6 +224,7 @@ func (self *SReservedip) Release(ctx context.Context, userCred mcclient.TokenCre
|
||||
err := db.DeleteModel(ctx, userCred, self)
|
||||
if err == nil && network != nil {
|
||||
db.OpsLog.LogEvent(network, db.ACT_RELEASE_IP, self.GetShortDesc(ctx), userCred)
|
||||
logclient.AddSimpleActionLog(network, logclient.ACT_RELEASE_IP, self.GetShortDesc(ctx), userCred, true)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
@@ -603,6 +604,7 @@ func PerformSetResourceSchedtag(obj IModelWithSchedtag, ctx context.Context, use
|
||||
if err := obj.ClearSchedDescCache(); err != nil {
|
||||
log.Errorf("Resource %s/%s ClearSchedDescCache error: %v", obj.Keyword(), obj.GetId(), err)
|
||||
}
|
||||
logclient.AddActionLogWithContext(ctx, obj, logclient.ACT_SET_SCHED_TAG, nil, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -417,6 +417,13 @@ func (manager *SSnapshotManager) FetchCustomizeColumns(
|
||||
func (self *SSnapshot) GetShortDesc(ctx context.Context) *jsonutils.JSONDict {
|
||||
res := self.SVirtualResourceBase.GetShortDesc(ctx)
|
||||
res.Add(jsonutils.NewInt(int64(self.Size)), "size")
|
||||
res.Add(jsonutils.NewString(self.DiskId), "disk_id")
|
||||
disk, _ := self.GetDisk()
|
||||
if disk != nil {
|
||||
if guest := disk.GetGuest(); guest != nil {
|
||||
res.Add(jsonutils.NewString(guest.Id), "guest_id")
|
||||
}
|
||||
}
|
||||
info := self.getCloudProviderInfo()
|
||||
res.Update(jsonutils.Marshal(&info))
|
||||
return res
|
||||
|
||||
@@ -88,7 +88,7 @@ type SStorage struct {
|
||||
// example: ssd
|
||||
MediumType string `width:"32" charset:"ascii" nullable:"false" list:"user" update:"domain" create:"domain_required"`
|
||||
// 超售比
|
||||
Cmtbound float32 `nullable:"true" default:"1" list:"domain" update:"domain"`
|
||||
Cmtbound float32 `nullable:"true" default:"1" list:"domain"`
|
||||
// 存储配置信息
|
||||
StorageConf jsonutils.JSONObject `nullable:"true" get:"domain" list:"domain" update:"domain"`
|
||||
|
||||
@@ -1930,6 +1930,26 @@ func (self *SStorage) PerformSetSchedtag(ctx context.Context, userCred mcclient.
|
||||
return PerformSetResourceSchedtag(self, ctx, userCred, query, data)
|
||||
}
|
||||
|
||||
func (self *SStorage) PerformSetCommitBound(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
input api.StorageSetCmtBoundInput,
|
||||
) (jsonutils.JSONObject, error) {
|
||||
_, err := db.Update(self, func() error {
|
||||
if input.Cmtbound != nil {
|
||||
self.Cmtbound = *input.Cmtbound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db.OpsLog.LogEvent(self, db.ACT_SET_COMMIT_BOUND, input, userCred)
|
||||
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_SET_COMMIT_BOUND, input, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (self *SStorage) GetSchedtagJointManager() ISchedtagJointManager {
|
||||
return StorageschedtagManager
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ func (self *BaremetalUnconvertHypervisorTask) OnInit(ctx context.Context, obj db
|
||||
|
||||
func (self *BaremetalUnconvertHypervisorTask) OnGuestDeleteComplete(ctx context.Context, baremetal *models.SHost, body jsonutils.JSONObject) {
|
||||
db.OpsLog.LogEvent(baremetal, db.ACT_UNCONVERT_COMPLETE, "", self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, baremetal, logclient.ACT_UNCONVERT_COMPLETE, nil, self.UserCred, true)
|
||||
driver, err := baremetal.GetHostDriver()
|
||||
if err != nil {
|
||||
self.SetStageFailed(ctx, jsonutils.NewString(errors.Wrapf(err, "GetHostDriver").Error()))
|
||||
@@ -77,6 +78,7 @@ func (self *BaremetalUnconvertHypervisorTask) OnGuestDeleteComplete(ctx context.
|
||||
|
||||
func (self *BaremetalUnconvertHypervisorTask) OnGuestDeleteCompleteFailed(ctx context.Context, baremetal *models.SHost, body jsonutils.JSONObject) {
|
||||
db.OpsLog.LogEvent(baremetal, db.ACT_UNCONVERT_FAIL, body, self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, baremetal, logclient.ACT_UNCONVERT_COMPLETE, nil, self.UserCred, false)
|
||||
self.SetStage("OnFailSyncstatusComplete", nil)
|
||||
baremetal.StartSyncstatus(ctx, self.UserCred, self.GetTaskId())
|
||||
logclient.AddActionLogWithStartable(self, baremetal, logclient.ACT_BM_UNCONVERT_HYPER, body, self.UserCred, false)
|
||||
|
||||
@@ -66,6 +66,7 @@ func (self *DiskSyncstatusTask) OnInit(ctx context.Context, obj db.IStandaloneMo
|
||||
}
|
||||
|
||||
func (self *DiskSyncstatusTask) OnDiskSyncStatusComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithContext(ctx, obj, logclient.ACT_SYNC_STATUS, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
type GuestEjectISOTask struct {
|
||||
@@ -54,5 +55,11 @@ func (self *GuestEjectISOTask) startEjectIso(ctx context.Context, obj db.IStanda
|
||||
}
|
||||
|
||||
func (self *GuestEjectISOTask) OnConfigSyncComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithContext(ctx, obj, logclient.ACT_ISO_DETACH, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
func (self *GuestEjectISOTask) OnConfigSyncCompleteFailed(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithContext(ctx, obj, logclient.ACT_ISO_DETACH, nil, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, nil)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
type GuestInsertIsoTask struct {
|
||||
@@ -62,6 +63,7 @@ func (self *GuestInsertIsoTask) prepareIsoImage(ctx context.Context, obj db.ISta
|
||||
} else {
|
||||
guest.EjectIso(cdromOrdinal, self.UserCred)
|
||||
db.OpsLog.LogEvent(obj, db.ACT_ISO_PREPARE_FAIL, imageId, self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_ISO_ATTACH, nil, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, jsonutils.NewString("host no local storage cache"))
|
||||
}
|
||||
}
|
||||
@@ -72,6 +74,7 @@ func (self *GuestInsertIsoTask) OnIsoPrepareCompleteFailed(ctx context.Context,
|
||||
db.OpsLog.LogEvent(obj, db.ACT_ISO_PREPARE_FAIL, imageId, self.UserCred)
|
||||
guest := obj.(*models.SGuest)
|
||||
guest.EjectIso(cdromOrdinal, self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_ISO_ATTACH, nil, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, data)
|
||||
}
|
||||
|
||||
@@ -95,6 +98,7 @@ func (self *GuestInsertIsoTask) OnIsoPrepareComplete(ctx context.Context, obj db
|
||||
guest := obj.(*models.SGuest)
|
||||
if cdrom, ok := guest.InsertIsoSucc(cdromOrdinal, imageId, path, size, name, bootIndex); ok {
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ISO_ATTACH, cdrom.GetDetails(), self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_ISO_ATTACH, cdrom.GetDetails(), self.UserCred, true)
|
||||
drv, err := guest.GetDriver()
|
||||
if err != nil {
|
||||
self.OnIsoPrepareCompleteFailed(ctx, guest, jsonutils.NewString(err.Error()))
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -76,6 +77,7 @@ func (self *GuestHardResetTask) StartServer(ctx context.Context, guest *models.S
|
||||
}
|
||||
|
||||
func (self *GuestHardResetTask) OnServerStartComplete(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_VM_RESTART, nil, self.GetUserCred(), true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ func (self *GuestIsolatedDeviceSyncTask) OnSyncConfigCompleteFailed(ctx context.
|
||||
}
|
||||
|
||||
func (self *GuestIsolatedDeviceSyncTask) OnStartComplete(ctx context.Context, obj *models.SGuest, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithStartable(self, obj, logclient.ACT_VM_SYNC_ISOLATED_DEVICE, nil, self.GetUserCred(), true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
type GuestSyncstatusTask struct {
|
||||
@@ -106,13 +107,13 @@ func (self *GuestSyncstatusTask) OnGetStatusComplete(ctx context.Context, obj db
|
||||
BlockJobsCount: int(blockJobsCount),
|
||||
}
|
||||
guest.PerformStatus(ctx, self.UserCred, nil, input)
|
||||
logclient.AddSimpleActionLog(guest, logclient.ACT_VM_SYNC_STATUS, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
// logclient.AddActionLog(guest, logclient.ACT_VM_SYNC_STATUS, "", self.UserCred, true)
|
||||
}
|
||||
|
||||
func (self *GuestSyncstatusTask) OnGetStatusCompleteFailed(ctx context.Context, obj db.IStandaloneModel, err jsonutils.JSONObject) {
|
||||
guest := obj.(*models.SGuest)
|
||||
guest.SetStatus(ctx, self.UserCred, api.VM_UNKNOWN, err.String())
|
||||
logclient.AddSimpleActionLog(guest, logclient.ACT_VM_SYNC_STATUS, err, self.UserCred, false)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
// logclient.AddActionLog(guest, logclient.ACT_VM_SYNC_STATUS, err, self.UserCred, false)
|
||||
}
|
||||
|
||||
@@ -1307,11 +1307,13 @@ func (user *SUser) PerformJoin(
|
||||
) (jsonutils.JSONObject, error) {
|
||||
err := joinProjects(user, true, ctx, userCred, input)
|
||||
if err != nil {
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_JOIN_PROJECT, nil, userCred, false)
|
||||
return nil, errors.Wrap(err, "joinProjects")
|
||||
}
|
||||
if input.Enabled {
|
||||
db.EnabledPerformEnable(user, ctx, userCred, true)
|
||||
}
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_JOIN_PROJECT, nil, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -1381,8 +1383,10 @@ func (user *SUser) PerformLeave(
|
||||
) (jsonutils.JSONObject, error) {
|
||||
err := leaveProjects(user, true, ctx, userCred, input)
|
||||
if err != nil {
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_LEAVE_PROJECT, nil, userCred, false)
|
||||
return nil, err
|
||||
}
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_LEAVE_PROJECT, nil, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -1538,6 +1542,7 @@ func (user *SUser) PerformResetCredentials(
|
||||
return nil, errors.Wrapf(err, "DeleteAll %s", api.RECOVERY_SECRETS_TYPE)
|
||||
}
|
||||
}
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_RESET_CREDENTIAL, nil, userCred, true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,16 @@ func (o *HostAutoMigrateOnHostDownOptions) Params() (jsonutils.JSONObject, error
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type HostSetCommitBoundOptions struct {
|
||||
options.BaseIdOptions
|
||||
CpuCmtbound *float32 `help:"Cpu commit bound"`
|
||||
MemCmtBound *float32 `help:"Mem commit bound"`
|
||||
}
|
||||
|
||||
func (o *HostSetCommitBoundOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type HostStatusStatisticsOptions struct {
|
||||
HostListOptions
|
||||
options.StatusStatisticsOptions
|
||||
|
||||
@@ -49,16 +49,15 @@ func (opts *StorageListOptions) GetContextId() string {
|
||||
|
||||
type StorageUpdateOptions struct {
|
||||
options.BaseUpdateOptions
|
||||
CommitBound float64 `help:"Upper bound of storage overcommit rate" json:"cmtbound"`
|
||||
MediumType string `help:"Medium type" choices:"ssd|rotate"`
|
||||
RbdRadosMonOpTimeout int64 `help:"ceph rados_mon_op_timeout"`
|
||||
RbdRadosOsdOpTimeout int64 `help:"ceph rados_osd_op_timeout"`
|
||||
RbdClientMountTimeout int64 `help:"ceph client_mount_timeout"`
|
||||
RbdEnableMessengerV2 bool `help:"ceph enable Messenger V2"`
|
||||
RbdKey string `help:"ceph rbd key"`
|
||||
Reserved string `help:"Reserved storage space"`
|
||||
Capacity int `help:"Capacity for storage"`
|
||||
MasterHost string `help:"slvm storage master host"`
|
||||
MediumType string `help:"Medium type" choices:"ssd|rotate"`
|
||||
RbdRadosMonOpTimeout int64 `help:"ceph rados_mon_op_timeout"`
|
||||
RbdRadosOsdOpTimeout int64 `help:"ceph rados_osd_op_timeout"`
|
||||
RbdClientMountTimeout int64 `help:"ceph client_mount_timeout"`
|
||||
RbdEnableMessengerV2 bool `help:"ceph enable Messenger V2"`
|
||||
RbdKey string `help:"ceph rbd key"`
|
||||
Reserved string `help:"Reserved storage space"`
|
||||
Capacity int `help:"Capacity for storage"`
|
||||
MasterHost string `help:"slvm storage master host"`
|
||||
}
|
||||
|
||||
func (opts *StorageUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
@@ -124,3 +123,12 @@ type StorageSetHardwareInfoOptions struct {
|
||||
func (o *StorageSetHardwareInfoOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(o), nil
|
||||
}
|
||||
|
||||
type StorageSetCommitBoundOptions struct {
|
||||
options.BaseIdOptions
|
||||
Cmtbound *float32 `help:"Storage commit bound"`
|
||||
}
|
||||
|
||||
func (o *StorageSetCommitBoundOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ const (
|
||||
ACT_GUEST_CREATE_FROM_IMPORT = "guest_create_from_import"
|
||||
ACT_GUEST_PANICKED = "guest_panicked"
|
||||
ACT_HOST_MAINTAINING = "host_maintaining"
|
||||
ACT_HOST_UNMAINTENANCE = "host_unmaintenance"
|
||||
|
||||
ACT_MKDIR = "mkdir"
|
||||
ACT_DELETE_OBJECT = "delete_object"
|
||||
@@ -245,6 +246,11 @@ const (
|
||||
ACT_CONSOLE = "console"
|
||||
ACT_WEBSSH = "webssh"
|
||||
ACT_SET_USER_PASSWORD = "set_user_password"
|
||||
ACT_MAKESSHABLE = "make_sshable"
|
||||
ACT_TRYSSHABLE = "try_sshable"
|
||||
|
||||
ACT_ISO_ATTACH = "iso_attach"
|
||||
ACT_ISO_DETACH = "iso_detach"
|
||||
|
||||
ACT_SYNC_OS_INFO = "sync_os_info"
|
||||
|
||||
@@ -280,6 +286,18 @@ const (
|
||||
ACT_DELETE_SECURITY_GROUP_RULE = "delete_security_group_rule"
|
||||
|
||||
ACT_CLEAN_PROJECT = "clean_project"
|
||||
ACT_JOIN_PROJECT = "join_project"
|
||||
ACT_LEAVE_PROJECT = "leave_project"
|
||||
|
||||
ACT_SET_SCHED_TAG = "set_sched_tag"
|
||||
ACT_RESET_CREDENTIAL = "reset_credential"
|
||||
|
||||
ACT_AUTO_MIGRATE_ON_HOST_DOWN = "auto_migrate_on_host"
|
||||
ACT_SET_RESERVE_RESOURCE_FOR_ISOLATED_DEVICES = "set_reserve_resource_for_isolated_devices"
|
||||
|
||||
ACT_UNCONVERT_START = "unconverting"
|
||||
ACT_UNCONVERT_COMPLETE = "unconverted"
|
||||
ACT_SET_COMMIT_BOUND = "set_commit_bound"
|
||||
|
||||
ACT_COLLECT_METRICS = "collect_metrics"
|
||||
|
||||
|
||||
@@ -451,6 +451,10 @@ func init() {
|
||||
EN("Host Maintaining").
|
||||
CN("宿主机进入维护模式"),
|
||||
)
|
||||
t.Set(ACT_HOST_UNMAINTENANCE, i18n.NewTableEntry().
|
||||
EN("Host Unmaintenance").
|
||||
CN("宿主机退出维护模式"),
|
||||
)
|
||||
|
||||
t.Set(ACT_MKDIR, i18n.NewTableEntry().
|
||||
EN("Mkdir").
|
||||
@@ -1373,6 +1377,16 @@ func init() {
|
||||
CN("WebSSH"),
|
||||
)
|
||||
|
||||
o.Set(ACT_TRYSSHABLE, i18n.NewTableEntry().
|
||||
EN("Try Sshable").
|
||||
CN("探测免密登录"),
|
||||
)
|
||||
|
||||
o.Set(ACT_MAKESSHABLE, i18n.NewTableEntry().
|
||||
EN("Make Sshable").
|
||||
CN("设置免密登录"),
|
||||
)
|
||||
|
||||
o.Set(ACT_CLOUDACCOUNT_SYNC_NETWORK, i18n.NewTableEntry().
|
||||
EN("Probe Network").
|
||||
CN("探测网络配置"),
|
||||
@@ -1483,4 +1497,40 @@ func init() {
|
||||
CN("删除费率"),
|
||||
)
|
||||
|
||||
o.Set(ACT_JOIN_PROJECT, i18n.NewTableEntry().
|
||||
EN("Join Project").
|
||||
CN("加入项目"),
|
||||
)
|
||||
o.Set(ACT_LEAVE_PROJECT, i18n.NewTableEntry().
|
||||
EN("Leave Project").
|
||||
CN("移除项目"),
|
||||
)
|
||||
o.Set(ACT_RESET_CREDENTIAL, i18n.NewTableEntry().
|
||||
EN("Reset Credential").
|
||||
CN("重置账号密码"),
|
||||
)
|
||||
o.Set(ACT_SET_SCHED_TAG, i18n.NewTableEntry().
|
||||
EN("Set Scheduler Tag").
|
||||
CN("设置调度标签"),
|
||||
)
|
||||
o.Set(ACT_AUTO_MIGRATE_ON_HOST_DOWN, i18n.NewTableEntry().
|
||||
EN("Auto Migrate On Host Down").
|
||||
CN("宕机自动迁移"),
|
||||
)
|
||||
o.Set(ACT_SET_RESERVE_RESOURCE_FOR_ISOLATED_DEVICES, i18n.NewTableEntry().
|
||||
EN("Set Reserve Resource For Isolated Devices").
|
||||
CN("透传设备设置预留资源"),
|
||||
)
|
||||
o.Set(ACT_UNCONVERT_START, i18n.NewTableEntry().
|
||||
EN("Start Unconvert hypervisor").
|
||||
CN("开始回收为物理机"),
|
||||
)
|
||||
o.Set(ACT_UNCONVERT_COMPLETE, i18n.NewTableEntry().
|
||||
EN("Unconvert Hypervisor Complete").
|
||||
CN("回收为物理机"),
|
||||
)
|
||||
o.Set(ACT_SET_COMMIT_BOUND, i18n.NewTableEntry().
|
||||
EN("Set Commit Bound").
|
||||
CN("设置超售比"),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user