mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
host fix cmt bound, minor fix
This commit is contained in:
@@ -135,6 +135,7 @@ const (
|
||||
VM_CONVERT = "convert"
|
||||
VM_CONVERTING = "converting"
|
||||
VM_CONVERT_FAILED = "convert_failed"
|
||||
VM_CONVERTED = "converted"
|
||||
|
||||
SHUTDOWN_STOP = "stop"
|
||||
SHUTDOWN_TERMINATE = "terminate"
|
||||
|
||||
@@ -143,6 +143,10 @@ type HostDetails struct {
|
||||
CpuCommitRate float64 `json:"cpu_commit_rate"`
|
||||
// 内存超分率
|
||||
MemCommitRate float64 `json:"mem_commit_rate"`
|
||||
// CPU超售比
|
||||
CpuCommitBound float32 `json:"cpu_commit_bound"`
|
||||
// 内存超售比
|
||||
MemCommitBound float32 `json:"mem_commint_bound"`
|
||||
// 存储大小
|
||||
Storage int64 `json:"storage"`
|
||||
// 已使用存储大小
|
||||
|
||||
@@ -291,8 +291,8 @@ func FetchCustomizeColumns(
|
||||
}
|
||||
retVal := make([]*jsonutils.JSONDict, ret[0].Len())
|
||||
for i := 0; i < ret[0].Len(); i += 1 {
|
||||
jsonDict := jsonutils.Marshal(objs[i]).(*jsonutils.JSONDict)
|
||||
jsonDict.Update(ValueToJSONDict(ret[0].Index(i)))
|
||||
jsonDict := ValueToJSONDict(ret[0].Index(i))
|
||||
jsonDict.Update(jsonutils.Marshal(objs[i]).(*jsonutils.JSONDict))
|
||||
retVal[i] = jsonDict
|
||||
}
|
||||
return retVal, nil
|
||||
|
||||
@@ -417,6 +417,12 @@ func (model *SStandaloneResourceBase) AllowPerformSetUserMetadata(ctx context.Co
|
||||
func (model *SStandaloneResourceBase) PerformSetUserMetadata(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformSetUserMetadataInput) (jsonutils.JSONObject, error) {
|
||||
dictStore := make(map[string]interface{})
|
||||
for k, v := range input {
|
||||
if len(k) > 64-len(USER_TAG_PREFIX) {
|
||||
return nil, httperrors.NewInputParameterError("input key too long > %d", 64-len(USER_TAG_PREFIX))
|
||||
}
|
||||
if len(v) > 65535 {
|
||||
return nil, httperrors.NewInputParameterError("input value too long > %d", 65535)
|
||||
}
|
||||
dictStore[USER_TAG_PREFIX+k] = v
|
||||
}
|
||||
err := model.SetUserMetadataAll(ctx, dictStore, userCred)
|
||||
|
||||
@@ -2585,8 +2585,8 @@ func (self *SHost) getMoreDetails(ctx context.Context, out api.HostDetails, show
|
||||
out.Spec = self.GetHardwareSpecification()
|
||||
|
||||
// custom cpu mem commit bound
|
||||
out.CpuCmtbound = self.GetCPUOvercommitBound()
|
||||
out.MemCmtbound = self.GetMemoryOvercommitBound()
|
||||
out.CpuCommitBound = self.GetCPUOvercommitBound()
|
||||
out.MemCommitBound = self.GetMemoryOvercommitBound()
|
||||
|
||||
// extra = self.SManagedResourceBase.getExtraDetails(ctx, extra)
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ func (self *GuestConvertEsxiToKvmTask) taskFailed(ctx context.Context, guest *mo
|
||||
targetGuest.SetStatus(self.UserCred, api.VM_CONVERT_FAILED, reason)
|
||||
db.OpsLog.LogEvent(guest, db.ACT_VM_CONVERT_FAIL, reason, self.UserCred)
|
||||
logclient.AddSimpleActionLog(guest, logclient.ACT_VM_CONVERT, reason, self.UserCred, false)
|
||||
logclient.AddSimpleActionLog(targetGuest, logclient.ACT_VM_CONVERT, reason, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
@@ -185,20 +186,20 @@ func (self *GuestConvertEsxiToKvmTask) OnHostCreateGuestFailed(
|
||||
}
|
||||
|
||||
func (self *GuestConvertEsxiToKvmTask) TaskComplete(ctx context.Context, guest, targetGuest *models.SGuest) {
|
||||
guest.SetStatus(self.UserCred, api.VM_READY, "")
|
||||
guest.SetStatus(self.UserCred, api.VM_CONVERTED, "")
|
||||
guest.SetMetadata(ctx, api.SERVER_META_CONVERTED_SERVER, targetGuest.Id, self.UserCred)
|
||||
if osProfile := guest.GetMetadata("__os_profile__", self.UserCred); len(osProfile) > 0 {
|
||||
guest.SetMetadata(ctx, "__os_profile__", osProfile, self.UserCred)
|
||||
targetGuest.SetMetadata(ctx, "__os_profile__", osProfile, self.UserCred)
|
||||
}
|
||||
if account := guest.GetMetadata(api.VM_METADATA_LOGIN_ACCOUNT, self.UserCred); len(account) > 0 {
|
||||
guest.SetMetadata(ctx, api.VM_METADATA_LOGIN_ACCOUNT, account, self.UserCred)
|
||||
targetGuest.SetMetadata(ctx, api.VM_METADATA_LOGIN_ACCOUNT, account, self.UserCred)
|
||||
}
|
||||
if loginKey := guest.GetMetadata(api.VM_METADATA_LOGIN_KEY, self.UserCred); len(loginKey) > 0 {
|
||||
passwd, _ := utils.DescryptAESBase64(guest.Id, loginKey)
|
||||
if len(passwd) > 0 {
|
||||
secret, err := utils.EncryptAESBase64(targetGuest.Id, passwd)
|
||||
if err == nil {
|
||||
guest.SetMetadata(ctx, api.VM_METADATA_LOGIN_KEY, secret, self.UserCred)
|
||||
targetGuest.SetMetadata(ctx, api.VM_METADATA_LOGIN_KEY, secret, self.UserCred)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user