winterhazel commented on code in PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#discussion_r1846905527
##########
framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariableHelper.java:
##########
@@ -271,6 +280,39 @@ protected GenericPresetVariable getPresetVariableZone(Long
zoneId) {
return zone;
}
+ protected void setPresetVariableConfiguration(PresetVariables
presetVariables, UsageVO usageRecord) {
+ if (usageRecord.getUsageType() != UsageTypes.RUNNING_VM) {
+ return;
+ }
+
+ Configuration configuration = new Configuration();
+ setForceHaInConfiguration(configuration, usageRecord);
+
+ presetVariables.setConfiguration(configuration);
+ }
+
+ protected void setForceHaInConfiguration(Configuration configuration,
UsageVO usageRecord) {
+ Long vmId = usageRecord.getUsageId();
+ VMInstanceVO vmVo = vmInstanceDao.findByIdIncludingRemoved(vmId);
+ validateIfObjectIsNull(vmVo, vmId, "VM");
+
+ Long hostId = vmVo.getHostId() == null ? vmVo.getLastHostId() :
vmVo.getHostId();
Review Comment:
```suggestion
Long hostId = ObjectUtils.defaultIfNull(vmVo.getHostId(),
vmVo.getLastHostId());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]