You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/07/04 07:47:27 UTC

[GitHub] borisstoyanov commented on a change in pull request #2709: check volumes for state when retrieving pool for configDrive creation

borisstoyanov commented on a change in pull request #2709: check volumes for state when retrieving pool for configDrive creation
URL: https://github.com/apache/cloudstack/pull/2709#discussion_r200035435
 
 

 ##########
 File path: server/src/com/cloud/network/element/ConfigDriveNetworkElement.java
 ##########
 @@ -322,27 +324,78 @@ public void commitMigration(NicProfile nic, Network network, VirtualMachineProfi
     private DataStore findDataStore(VirtualMachineProfile profile, DeployDestination dest) {
         DataStore dataStore = null;
         if (VirtualMachineManager.VmConfigDriveOnPrimaryPool.value()) {
-            if (dest.getStorageForDisks() != null) {
-                for (final Volume volume : dest.getStorageForDisks().keySet()) {
-                    if (volume.getVolumeType() == Volume.Type.ROOT) {
-                        final StoragePool primaryPool = dest.getStorageForDisks().get(volume);
-                        dataStore = _dataStoreMgr.getDataStore(primaryPool.getId(), DataStoreRole.Primary);
-                        break;
-                    }
-                }
+            if(MapUtils.isNotEmpty(dest.getStorageForDisks())) {
+                dataStore = getPlannedDataStore(dest, dataStore);
             }
             if (dataStore == null) {
-                final List<VolumeVO> volumes = _volumeDao.findByInstanceAndType(profile.getVirtualMachine().getId(), Volume.Type.ROOT);
-                if (volumes != null && volumes.size() > 0) {
-                    dataStore = _dataStoreMgr.getDataStore(volumes.get(0).getPoolId(), DataStoreRole.Primary);
-                }
+                dataStore = savelyPickExistingRootVolumeDataStore(profile, dataStore);
             }
         } else {
             dataStore = _dataStoreMgr.getImageStore(dest.getDataCenter().getId());
         }
         return dataStore;
     }
 
+    private DataStore getPlannedDataStore(DeployDestination dest, DataStore dataStore) {
+        for (final Volume volume : dest.getStorageForDisks().keySet()) {
+            if (volume.getVolumeType() == Volume.Type.ROOT) {
+                final StoragePool primaryPool = dest.getStorageForDisks().get(volume);
+                dataStore = _dataStoreMgr.getDataStore(primaryPool.getId(), DataStoreRole.Primary);
+                break;
+            }
+        }
+        return dataStore;
+    }
+
+    private DataStore savelyPickExistingRootVolumeDataStore(VirtualMachineProfile profile, DataStore dataStore) {
 
 Review comment:
   typo? 'safely' 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services