mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Merge pull request #6618 from swordqiu/hotfix/qj-host-convert-baremetal-previleges
fix: domain user no previleges to convert host
This commit is contained in:
@@ -4345,9 +4345,12 @@ func (self *SHost) PerformConvertHypervisor(ctx context.Context, userCred mcclie
|
||||
if err != nil {
|
||||
return nil, httperrors.NewNotAcceptableError("Convert error: %s", err.Error())
|
||||
}
|
||||
// admin delegate user to create system resource
|
||||
input.ProjectDomain = userCred.GetProjectDomainId()
|
||||
input.Project = userCred.GetProjectId()
|
||||
params := input.JSON(input)
|
||||
// ownerId := userCred.GetProjectId()
|
||||
guest, err := db.DoCreate(GuestManager, ctx, userCred, nil, params, userCred)
|
||||
adminCred := auth.AdminCredential()
|
||||
guest, err := db.DoCreate(GuestManager, ctx, adminCred, nil, params, userCred)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -4355,7 +4358,7 @@ func (self *SHost) PerformConvertHypervisor(ctx context.Context, userCred mcclie
|
||||
lockman.LockObject(ctx, guest)
|
||||
defer lockman.ReleaseObject(ctx, guest)
|
||||
|
||||
guest.PostCreate(ctx, userCred, userCred, nil, params)
|
||||
guest.PostCreate(ctx, adminCred, userCred, nil, params)
|
||||
}()
|
||||
log.Infof("Host convert to %s", guest.GetName())
|
||||
db.OpsLog.LogEvent(self, db.ACT_CONVERT_START, "", userCred)
|
||||
@@ -4366,7 +4369,7 @@ func (self *SHost) PerformConvertHypervisor(ctx context.Context, userCred mcclie
|
||||
opts.Set("server_id", jsonutils.NewString(guest.GetId()))
|
||||
opts.Set("convert_host_type", jsonutils.NewString(hostType))
|
||||
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "BaremetalConvertHypervisorTask", self, userCred, opts, "", "", nil)
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "BaremetalConvertHypervisorTask", self, adminCred, opts, "", "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user