mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
fix(region): guest change disk storage
new disk use src disk driver and cache mode. Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
@@ -265,6 +265,8 @@ func (self *SGuestdisk) ToDiskConfig() *api.DiskConfig {
|
||||
conf := disk.ToDiskConfig()
|
||||
conf.Index = int(self.Index)
|
||||
conf.Mountpoint = self.Mountpoint
|
||||
conf.Driver = self.Driver
|
||||
conf.Cache = self.CacheMode
|
||||
return conf
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,8 @@ func (t *GuestChangeDiskStorageTask) OnDiskChangeStorageComplete(ctx context.Con
|
||||
}
|
||||
|
||||
conf := guestSrcDisk.ToDiskConfig()
|
||||
t.SetStage("OnSourceDiskDetachComplete", jsonutils.Marshal(conf).(*jsonutils.JSONDict))
|
||||
t.Params.Set("src_disk_conf", jsonutils.Marshal(conf))
|
||||
t.SetStage("OnSourceDiskDetachComplete", nil)
|
||||
if err := t.detachSourceDisk(ctx, guest, srcDisk); err != nil {
|
||||
t.TaskFailed(ctx, guest, jsonutils.NewString(fmt.Sprintf("detachSourceDisk: %s", err)))
|
||||
return
|
||||
@@ -258,7 +259,7 @@ func (t *GuestChangeDiskStorageTask) detachSourceDisk(ctx context.Context, guest
|
||||
func (t *GuestChangeDiskStorageTask) OnSourceDiskDetachComplete(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
|
||||
t.SetStage("OnTargetDiskAttachComplete", data.(*jsonutils.JSONDict))
|
||||
conf := new(api.DiskConfig)
|
||||
if err := data.Unmarshal(conf); err != nil {
|
||||
if err := t.Params.Unmarshal(conf, "src_disk_conf"); err != nil {
|
||||
t.TaskFailed(ctx, guest, jsonutils.NewString(fmt.Sprintf("unmarshal %s to api.DiskConfig: %s", data, err)))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user