This is an automated email from the ASF dual-hosted git repository.

sureshanaparti pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.16 by this push:
     new 8db598b  set pod after migration (#5972)
8db598b is described below

commit 8db598bc0fa8d33e11afcae2b89d1cab89eb2f94
Author: dahn <[email protected]>
AuthorDate: Fri Feb 11 14:17:45 2022 +0100

    set pod after migration (#5972)
    
    Co-authored-by: Daan Hoogland <[email protected]>
---
 .../main/java/com/cloud/vm/VirtualMachineManagerImpl.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git 
a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
 
b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
index 340a3e2..2fa44b1 100755
--- 
a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
+++ 
b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2849,6 +2849,8 @@ public class VirtualMachineManagerImpl extends 
ManagerBase implements VirtualMac
                 _networkMgr.commitNicForMigration(vmSrc, profile);
                 volumeMgr.release(vm.getId(), srcHostId);
                 _networkMgr.setHypervisorHostname(profile, dest, true);
+
+                updateVmPod(vm, dstHostId);
             }
 
             work.setStep(Step.Done);
@@ -2856,6 +2858,14 @@ public class VirtualMachineManagerImpl extends 
ManagerBase implements VirtualMac
         }
     }
 
+    private void updateVmPod(VMInstanceVO vm, long dstHostId) {
+        // update the VMs pod
+        HostVO host = _hostDao.findById(dstHostId);
+        VMInstanceVO newVm = _vmDao.findById(vm.getId());
+        newVm.setPodIdToDeployIn(host.getPodId());
+        _vmDao.persist(newVm);
+    }
+
     /**
      * We create the mapping of volumes and storage pool to migrate the VMs 
according to the information sent by the user.
      * If the user did not enter a complete mapping, the volumes that were 
left behind will be auto mapped using {@link 
#createStoragePoolMappingsForVolumes(VirtualMachineProfile, 
DataCenterDeployment, Map, List)}
@@ -4583,6 +4593,8 @@ public class VirtualMachineManagerImpl extends 
ManagerBase implements VirtualMac
                 }
             } else {
                 _networkMgr.setHypervisorHostname(profile, dest, true);
+
+                updateVmPod(vm, dstHostId);
             }
 
             work.setStep(Step.Done);

Reply via email to