Skip to content

Commit 57e80f7

Browse files
committed
server: Dedicated hosts should be 'Not Suitable' while find host for vm migration
1 parent ef14e19 commit 57e80f7

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

plugins/affinity-group-processors/explicit-dedication/src/main/java/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public void process(VirtualMachineProfile vmProfile, DeploymentPlan plan, Exclud
9292
DataCenter dc = _dcDao.findById(vm.getDataCenterId());
9393
List<DedicatedResourceVO> resourceList = new ArrayList<DedicatedResourceVO>();
9494

95+
List<DedicatedResourceVO> dedicatedHosts = _dedicatedDao.listAll();
96+
for (DedicatedResourceVO host : dedicatedHosts) {
97+
// Hosts dedicated to different domain/account are not suitable for migration
98+
if (host.getAccountId() != null && vm.getAccountId() != host.getAccountId()) {
99+
avoid.addHost(host.getHostId());
100+
}
101+
if (host.getDomainId() != null && vm.getDomainId() != host.getDomainId()) {
102+
avoid.addHost(host.getHostId());
103+
}
104+
}
105+
95106
if (vmGroupMappings != null && !vmGroupMappings.isEmpty()) {
96107

97108
for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,12 +1335,8 @@ public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Ho
13351335
}
13361336

13371337
// call affinitygroup chain
1338-
final long vmGroupCount = _affinityGroupVMMapDao.countAffinityGroupsForVm(vm.getId());
1339-
1340-
if (vmGroupCount > 0) {
1341-
for (final AffinityGroupProcessor processor : _affinityProcessors) {
1342-
processor.process(vmProfile, plan, excludes);
1343-
}
1338+
for (final AffinityGroupProcessor processor : _affinityProcessors) {
1339+
processor.process(vmProfile, plan, excludes);
13441340
}
13451341

13461342
for (final HostAllocator allocator : hostAllocators) {

0 commit comments

Comments
 (0)