DaanHoogland commented on code in PR #6644:
URL: https://github.com/apache/cloudstack/pull/6644#discussion_r968212377


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3857,7 +3858,41 @@ private UserVm createVirtualMachine(DataCenter zone, 
ServiceOffering serviceOffe
             DiskOfferingVO diskOffering = 
_diskOfferingDao.findById(diskOfferingId);
             volumesSize += verifyAndGetDiskSize(diskOffering, diskSize);
         }
-        if (! VirtualMachineManager.ResourceCountRunningVMsonly.value()) {
+        UserVmVO vm = getPermittedVmResource(zone, hostName, displayName, 
owner, diskOfferingId, diskSize, networkList, securityGroupIdList, group, 
httpmethod, userData, sshKeyPairs, caller, requestedIps, defaultIps, 
isDisplayVm, keyboard, affinityGroupIdList, customParameters, customId, 
dhcpOptionMap, datadiskTemplateToDiskOfferringMap, userVmOVFPropertiesMap, 
dynamicScalingEnabled, vmType, template, hypervisorType, accountId, offering, 
isIso, rootDiskOfferingId, volumesSize);
+
+        _securityGroupMgr.addInstanceToGroups(vm.getId(), securityGroupIdList);
+
+        if (affinityGroupIdList != null && !affinityGroupIdList.isEmpty()) {
+            _affinityGroupVMMapDao.updateMap(vm.getId(), affinityGroupIdList);
+        }
+
+        CallContext.current().putContextParameter(VirtualMachine.class, 
vm.getUuid());
+        return vm;
+    }
+    private UserVmVO getPermittedVmResource(DataCenter zone, String hostName, 
String displayName, Account owner, Long diskOfferingId, Long diskSize, 
List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, 
HTTPMethod httpmethod, String userData, List<String> sshKeyPairs, Account 
caller, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean 
isDisplayVm, String keyboard, List<Long> affinityGroupIdList, Map<String, 
String> customParameters, String customId, Map<String, Map<Integer, String>> 
dhcpOptionMap, Map<Long, DiskOffering> datadiskTemplateToDiskOfferringMap, 
Map<String, String> userVmOVFPropertiesMap, boolean dynamicScalingEnabled, 
String vmType, VMTemplateVO template, HypervisorType hypervisorType, long 
accountId, ServiceOfferingVO offering, boolean isIso, Long rootDiskOfferingId, 
long volumesSize) throws ResourceAllocationException, 
StorageUnavailableException, InsufficientCapacityException {

Review Comment:
   no, but it is already there in the calling method (just factorred out for 
fix/hack purposes



-- 
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]

Reply via email to