Skip to content

Commit a1091b0

Browse files
committed
fixup
1 parent ac407d9 commit a1091b0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

engine/schema/src/main/java/com/cloud/host/HostVO.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.apache.cloudstack.util.HypervisorTypeConverter;
4646
import org.apache.cloudstack.utils.jsinterpreter.TagAsRuleHelper;
4747
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
48+
import org.apache.commons.collections.CollectionUtils;
4849
import org.apache.commons.lang.BooleanUtils;
4950
import org.apache.commons.lang3.StringUtils;
5051

@@ -772,7 +773,8 @@ private Set<String> getHostServiceOfferingAndTemplateStrictTags(ServiceOffering
772773
if (StringUtils.isEmpty(serviceOffering.getHostTag()) && StringUtils.isEmpty(template.getTemplateTag())) {
773774
return new HashSet<>();
774775
}
775-
HashSet<String> hostTagsSet = new HashSet<>(getHostTags());
776+
List<String> hostTagsList = getHostTags();
777+
HashSet<String> hostTagsSet = CollectionUtils.isNotEmpty(hostTagsList) ? new HashSet<>(getHostTags()) : new HashSet<>();
776778
HashSet<String> tags = new HashSet<>();
777779
if (StringUtils.isNotEmpty(serviceOffering.getHostTag())) {
778780
tags.addAll(Arrays.asList(serviceOffering.getHostTag().split(",")));

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ protected void avoidOtherClustersForDeploymentIfMigrationDisabled(VirtualMachine
283283
boolean storageMigrationNeededDuringClusterMigration = false;
284284
for (Volume volume : volumes) {
285285
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
286-
if (List.of(ScopeType.HOST, ScopeType.CLUSTER).contains(pool.getScope())) {
286+
if (pool != null && List.of(ScopeType.HOST, ScopeType.CLUSTER).contains(pool.getScope())) {
287287
storageMigrationNeededDuringClusterMigration = true;
288288
break;
289289
}

test/integration/smoke/test_vm_strict_host_tags.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def test_06_deploy_vm_on_any_host_with_strict_tags_failure(self):
166166
self._cleanup.append(vm)
167167
self.fail("VM should not be deployed")
168168
except Exception as e:
169-
self.assertTrue("No suitable host found for follow compute offering tags: t2" in str(e))
169+
self.assertTrue("No suitable host found for vm " in str(e))
170170

171171

172172
class TestScaleVMStrictTags(cloudstackTestCase):
@@ -261,7 +261,7 @@ def test_02_scale_vm_strict_tags_failure(self):
261261
vm.start(self.apiclient)
262262
self.fail("VM should not be be able scale and start")
263263
except Exception as e:
264-
self.assertTrue("No suitable host found for follow compute offering tags: h2" in str(e))
264+
self.assertTrue("No suitable host found for vm " in str(e))
265265

266266

267267
class TestRestoreVMStrictTags(cloudstackTestCase):
@@ -333,7 +333,7 @@ def test_01_restore_vm_strict_tags_success(self):
333333

334334
vm.restore(self.apiclient, templateid=self.template_t2.id, expunge=True)
335335
restored_vm = VirtualMachine.list(self.apiclient, id=vm.id, listall=True)[0]
336-
self.assertEqual(restored_vm.templateid, self.template_t2.id, "VM was not scaled")
336+
self.assertEqual(restored_vm.templateid, self.template_t2.id, "VM was not restored")
337337

338338
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="false")
339339
def test_02_restore_vm_strict_tags_failure(self):
@@ -349,7 +349,7 @@ def test_02_restore_vm_strict_tags_failure(self):
349349
vm.restore(self.apiclient, templateid=self.template_t2.id, expunge=True)
350350
self.fail("VM should not be restored")
351351
except Exception as e:
352-
self.assertTrue("No suitable host found for follow compute offering tags: t2" in str(e))
352+
self.assertTrue("No suitable host found for vm " in str(e))
353353

354354
class TestMigrateVMStrictTags(cloudstackTestCase):
355355
@classmethod

0 commit comments

Comments
 (0)