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:
wanyaoqi
2023-02-16 13:40:06 +08:00
parent 692b5512da
commit cec7de6914
2 changed files with 5 additions and 2 deletions
+2
View File
@@ -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
}