DaanHoogland commented on a change in pull request #3976: Enable sending 
hypervior host name via metadata - VR and Config Drive
URL: https://github.com/apache/cloudstack/pull/3976#discussion_r399276119
 
 

 ##########
 File path: 
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
 ##########
 @@ -1610,6 +1612,26 @@ public void finalizeUpdateInSequence(Network network, 
boolean success) {
         }
     }
 
+    @Override
+    public void addNewDisk(VirtualMachineProfile vm, DeployDestination dest) 
throws ResourceUnavailableException {
+        final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
+        for (final NicVO nic : nics) {
+            final NetworkVO network = 
_networksDao.findById(nic.getNetworkId());
+            final Integer networkRate = 
_networkModel.getNetworkRate(network.getId(), vm.getId());
+            final NicProfile profile = new NicProfile(nic, network, 
nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, 
_networkModel.isSecurityGroupSupportedInNetwork(network),
+                    _networkModel.getNetworkTag(vm.getHypervisorType(), 
network));
+            for (final NetworkElement element : networkElements) {
+                if 
(_networkModel.areServicesSupportedInNetwork(network.getId(), Service.UserData)
+                        && element instanceof UserDataServiceProvider &&
+                        (element instanceof ConfigDriveNetworkElement || 
element instanceof VirtualRouterElement)) {
+                    final UserDataServiceProvider sp = 
(UserDataServiceProvider) element;
+                    if (!sp.addNewDisk(profile, network, vm, dest)) {
+                        throw new CloudRuntimeException("Failed to create New 
Iso Disk");
+                    }
+                }
+            }
 
 Review comment:
   so if we have an element that fits, do we still iterate over the rest, or 
should we break on the outer `if`? which makes me think this method has a high 
complexity can you disect it for readability, please?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to