mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
Automatic merge from release/2.2.0 -> release/2.3.0
* commit '20cf5be92a7df191690aeceea66a421fea0a8865': 调整带宽 task: CLOUD-561云服务器调整带宽后,操作日志记录的内容应该准确 增加日志服务黑名单,去掉配置服务的操作日志
This commit is contained in:
@@ -2904,10 +2904,12 @@ func (self *SGuest) PerformChangeBandwidth(ctx context.Context, userCred mcclien
|
||||
guestnics := self.GetNetworks()
|
||||
index, err := data.Int("index")
|
||||
if err != nil || index > int64(len(guestnics)) {
|
||||
logclient.AddActionLog(self, logclient.ACT_VM_CHANGE_BANDWIDTH, "Index Not fount or out of NIC index", userCred, false)
|
||||
return nil, httperrors.NewBadRequestError("Index Not fount or out of NIC index")
|
||||
}
|
||||
bandwidth, err := data.Int("bandwidth")
|
||||
if err != nil || bandwidth <= 0 {
|
||||
logclient.AddActionLog(self, logclient.ACT_VM_CHANGE_BANDWIDTH, "Bandwidth must be larger than 0", userCred, false)
|
||||
return nil, httperrors.NewBadRequestError("Bandwidth must be larger than 0")
|
||||
}
|
||||
guestnic := &guestnics[index]
|
||||
@@ -2917,11 +2919,14 @@ func (self *SGuest) PerformChangeBandwidth(ctx context.Context, userCred mcclien
|
||||
return nil
|
||||
})
|
||||
err := self.StartSyncTask(ctx, userCred, false, "")
|
||||
logclient.AddActionLog(self, logclient.ACT_VM_CHANGE_BANDWIDTH, err, userCred, err == nil)
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
return nil, httperrors.NewBadRequestError("Cannot change bandwidth in status %s", self.Status)
|
||||
msg := fmt.Sprintf("Cannot change bandwidth in status %s", self.Status)
|
||||
logclient.AddActionLog(self, logclient.ACT_VM_CHANGE_BANDWIDTH, msg, userCred, false)
|
||||
return nil, httperrors.NewBadRequestError(msg)
|
||||
}
|
||||
|
||||
func (self *SGuest) AllowPerformChangeConfig(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
|
||||
@@ -48,6 +48,7 @@ const (
|
||||
ACT_VM_PURGE = "清除"
|
||||
ACT_VM_REBUILD = "重装系统"
|
||||
ACT_VM_RESET_PSWD = "重置密码"
|
||||
ACT_VM_CHANGE_BANDWIDTH = "调整带宽"
|
||||
ACT_VM_START = "开机"
|
||||
ACT_VM_STOP = "关机"
|
||||
ACT_VM_RESTART = "重启"
|
||||
@@ -56,6 +57,9 @@ const (
|
||||
ACT_VM_UNBIND_KEYPAIR = "解绑密钥"
|
||||
)
|
||||
|
||||
// golang 不支持 const 的string array, http://t.cn/EzAvbw8
|
||||
var BLACK_LIST_OBJ_TYPE = []string{"parameter"}
|
||||
|
||||
var logclientWorkerMan *appsrv.WorkerManager
|
||||
|
||||
func init() {
|
||||
@@ -73,7 +77,13 @@ func AddActionLog(model IObject, action string, iNotes interface{}, userCred mcc
|
||||
token := userCred
|
||||
notes := stringutils.Interface2String(iNotes)
|
||||
|
||||
// s := auth.GetSession(userCred, "", "")
|
||||
// 忽略不黑名单里的资源类型
|
||||
for _, v := range BLACK_LIST_OBJ_TYPE {
|
||||
if v == model.Keyword() {
|
||||
log.Errorf("不支持的 actionlog 类型")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
objId := model.GetId()
|
||||
if len(objId) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user