shwstppr commented on code in PR #10834:
URL: https://github.com/apache/cloudstack/pull/10834#discussion_r2079491795


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -7961,7 +7967,10 @@ protected void selectApplicableNetworkToCreateVm(Account 
caller, Account newAcco
         NetworkVO defaultNetwork;
         List<? extends Network> virtualNetworks = 
_networkModel.listNetworksForAccount(newAccount.getId(), zone.getId(), 
Network.GuestType.Isolated);
         if (virtualNetworks.isEmpty()) {
-            defaultNetwork = createApplicableNetworkToCreateVm(caller, 
newAccount, zone, firstRequiredOffering);
+            try (TransactionLegacy txn = 
TransactionLegacy.open("CreateNetworkTxn")) {

Review Comment:
   Transaction.execute() won't work here?



##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -7594,6 +7595,11 @@ protected void 
executeStepsToChangeOwnershipOfVm(AssignVMCmd cmd, Account caller
         try {
             updateVmNetwork(cmd, caller, vm, newAccount, template);
         } catch (InsufficientCapacityException | ResourceAllocationException 
e) {
+            List<NetworkVO> networkVOS = 
_networkDao.listByAccountIdNetworkName(newAccountId, 
newAccount.getAccountName() + "-network");
+            if (networkVOS.size() == 1) {
+                _networkDao.remove(networkVOS.get(0).getId());
+            }

Review Comment:
   Can network be in implemented state or something? Do we really want to mark 
it as removed directly?



##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -7594,6 +7595,11 @@ protected void 
executeStepsToChangeOwnershipOfVm(AssignVMCmd cmd, Account caller
         try {
             updateVmNetwork(cmd, caller, vm, newAccount, template);
         } catch (InsufficientCapacityException | ResourceAllocationException 
e) {
+            List<NetworkVO> networkVOS = 
_networkDao.listByAccountIdNetworkName(newAccountId, 
newAccount.getAccountName() + "-network");
+            if (networkVOS.size() == 1) {
+                _networkDao.remove(networkVOS.get(0).getId());
+            }
+            _accountMgr.getActiveAccountByName(newAccount.getAccountName() + 
"-network", newAccount.getDomainId());

Review Comment:
   Why this? name won't be null with current code. Do we expect domainId to 
return null and then throw InvalidParameterValueException?



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