@@ -374,6 +374,11 @@ export default {
374374 openModal (record ) {
375375 this .selectedResource = { ... this .resource , hostDevicesName: record .hostDevicesName }
376376 this .showAddModal = true
377+ this .$nextTick (() => {
378+ if (this .$refs .hostDevicesTransfer ) {
379+ this .$refs .hostDevicesTransfer .refreshVMList ()
380+ }
381+ })
377382 },
378383 closeAction () {
379384 this .showAddModal = false
@@ -619,6 +624,16 @@ export default {
619624 details: ' all'
620625 })
621626 const vm = vmResponse? .listvirtualmachinesresponse ? .virtualmachine ? .[0 ]
627+ if (vm && vm .state === ' Running' ) {
628+ this .$notification .warning ({
629+ message: this .$t (' label.warning' ),
630+ description: this .$t (' message.cannot.remove.device.vm.running' )
631+ })
632+ this .showPciDeleteModal = false
633+ this .selectedPciDevice = null
634+ this .pciConfigs = {}
635+ return
636+ }
622637
623638 const params = {
624639 id: vm .id
@@ -668,10 +683,28 @@ export default {
668683 this .pciConfigs = {}
669684 },
670685 showConfirmModal (device ) {
671- console .log (' Selected device:' , device)
672- console .log (' VM Names:' , this .vmNames )
673- this .selectedPciDevice = device
674- this .showPciDeleteModal = true
686+ if (device .virtualmachineid ) {
687+ api (' listVirtualMachines' , {
688+ id: device .virtualmachineid ,
689+ listall: true
690+ }).then (response => {
691+ const vm = response? .listvirtualmachinesresponse ? .virtualmachine ? .[0 ]
692+ if (vm && vm .state === ' Running' ) {
693+ this .$notification .warning ({
694+ message: this .$t (' label.warning' ),
695+ description: this .$t (' message.cannot.remove.device.vm.running' )
696+ })
697+ return
698+ }
699+ this .selectedPciDevice = device
700+ this .showPciDeleteModal = true
701+ }).catch (error => {
702+ this .$notifyError (error)
703+ })
704+ } else {
705+ this .selectedPciDevice = device
706+ this .showPciDeleteModal = true
707+ }
675708 },
676709 async updateDataWithVmNames () {
677710 try {
0 commit comments