mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(region): user-date deploy by metadate (#19126)
This commit is contained in:
@@ -544,10 +544,6 @@ func (drv *SManagedVirtualizedGuestDriver) RequestDeployGuestOnHost(ctx context.
|
||||
return guest.GetDriver().RemoteDeployGuestForDeploy(ctx, guest, ihost, task, desc)
|
||||
})
|
||||
case "rebuild":
|
||||
userData, err := task.GetParams().GetString("user_data")
|
||||
if err == nil {
|
||||
desc.UserData = userData
|
||||
}
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
return guest.GetDriver().RemoteDeployGuestForRebuildRoot(ctx, guest, ihost, task, desc)
|
||||
})
|
||||
|
||||
@@ -1585,6 +1585,14 @@ func (self *SGuest) PerformRebuildRoot(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(input.UserData) > 0 {
|
||||
// validate UserData
|
||||
if err := userdata.ValidateUserdata(input.UserData, self.OsType); err != nil {
|
||||
return nil, httperrors.NewInputParameterError("Invalid userdata: %v", err)
|
||||
}
|
||||
self.setUserData(ctx, userCred, input.UserData)
|
||||
}
|
||||
|
||||
if len(input.ImageId) > 0 {
|
||||
img, err := CachedimageManager.getImageInfo(ctx, userCred, input.ImageId, false)
|
||||
if err != nil {
|
||||
@@ -3552,6 +3560,10 @@ func (self *SGuest) PerformUserData(ctx context.Context, userCred mcclient.Token
|
||||
if len(input.UserData) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("user_data")
|
||||
}
|
||||
// validate UserData
|
||||
if err := userdata.ValidateUserdata(input.UserData, self.OsType); err != nil {
|
||||
return nil, httperrors.NewInputParameterError("Invalid userdata: %v", err)
|
||||
}
|
||||
err := self.setUserData(ctx, userCred, input.UserData)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
|
||||
@@ -974,6 +974,7 @@ type ServerRebuildRootOptions struct {
|
||||
NoAccountInit *bool `help:"Not reset account password"`
|
||||
AutoStart *bool `help:"Auto start server after it is created"`
|
||||
AllDisks *bool `help:"Rebuild all disks including data disks"`
|
||||
UserData string `hlep:"user data scripts"`
|
||||
}
|
||||
|
||||
func (o *ServerRebuildRootOptions) GetId() string {
|
||||
|
||||
Reference in New Issue
Block a user