106106 v-model:checked =" migrateWithStorage"
107107 :disabled =" !selectedHost || !selectedHost.id || selectedHost.id === -1" />
108108 </a-form-item >
109+
110+ <a-radio-group
111+ v-if =" migrateWithStorage"
112+ v-model:value =" migrateMode"
113+ @change =" e => { handleMigrateModeChange(e.target.value) }" >
114+ <a-radio class =" radio-style" :value =" 1" >
115+ {{ $t('label.migrate.instance.single.storage') }}
116+ </a-radio >
117+ <a-radio class =" radio-style" :value =" 2" >
118+ {{ $t('label.migrate.instance.specific.storages') }}
119+ </a-radio >
120+ </a-radio-group >
121+
122+ <div v-if =" migrateWithStorage && migrateMode == 1" >
123+ <storage-pool-select-view
124+ ref =" storagePoolSelection"
125+ :autoAssignAllowed =" false"
126+ :resource =" resource"
127+ @select =" handleStoragePoolChange" />
128+ </div >
109129 <instance-volumes-storage-pool-select-list-view
110130 ref =" volumeToPoolSelect"
111- v-if =" migrateWithStorage"
131+ v-if =" migrateWithStorage && migrateMode !== 1 "
112132 class =" top-spaced"
113133 :resource =" resource"
114134 :clusterId =" selectedHost.id ? selectedHost.clusterid : null"
118138
119139 <div class =" actions" >
120140 <a-button @click =" closeModal" >{{ $t('label.cancel') }}</a-button >
121- <a-button type =" primary" ref =" submit" :disabled =" !selectedHost.id" @click =" submitForm" >{{ $t('label.ok') }}</a-button >
141+ <a-button type =" primary" ref =" submit" :disabled =" !selectedHost.id || (migrateWithStorage && migrateMode === 1 && !volumeToPoolSelection.length) " @click =" submitForm" >{{ $t('label.ok') }}</a-button >
122142 </div >
123143 </div >
124144</template >
125145
126146<script >
127147import { api } from ' @/api'
128148import TooltipLabel from ' @/components/widgets/TooltipLabel'
149+ import StoragePoolSelectView from ' @/components/view/StoragePoolSelectView'
129150import InstanceVolumesStoragePoolSelectListView from ' @/components/view/InstanceVolumesStoragePoolSelectListView'
130151
131152export default {
132153 name: ' VMMigrateWizard' ,
133154 components: {
134155 TooltipLabel,
156+ StoragePoolSelectView,
135157 InstanceVolumesStoragePoolSelectListView
136158 },
137159 props: {
@@ -188,6 +210,7 @@ export default {
188210 }
189211 ],
190212 migrateWithStorage: false ,
213+ migrateMode: 1 ,
191214 volumeToPoolSelection: [],
192215 volumes: []
193216 }
@@ -213,6 +236,10 @@ export default {
213236 },
214237 fetchData () {
215238 this .loading = true
239+ this .fetchHostsForMigration ()
240+ this .fetchVolumes ()
241+ },
242+ fetchHostsForMigration () {
216243 api (' findHostsForMigration' , {
217244 virtualmachineid: this .resource .id ,
218245 keyword: this .searchQuery ,
@@ -249,7 +276,6 @@ export default {
249276 handleSelectedHostChange (host ) {
250277 if (host .id === - 1 ) {
251278 this .migrateWithStorage = false
252- this .fetchVolumes ()
253279 }
254280 this .selectedHost = host
255281 this .selectedVolumeForStoragePoolSelection = {}
@@ -258,6 +284,17 @@ export default {
258284 this .$refs .volumeToPoolSelect .resetSelection ()
259285 }
260286 },
287+ handleMigrateModeChange () {
288+ this .volumeToPoolSelection = []
289+ },
290+ handleStoragePoolChange (storagePool ) {
291+ this .volumeToPoolSelection = []
292+ for (const volume of this .volumes ) {
293+ if (storagePool && storagePool .id && storagePool .id !== - 1 ) {
294+ this .volumeToPoolSelection .push ({ volume: volume .id , pool: storagePool .id })
295+ }
296+ }
297+ },
261298 handleVolumeToPoolChange (volumeToPool ) {
262299 this .volumeToPoolSelection = volumeToPool
263300 },
0 commit comments