harikrishna-patnala commented on a change in pull request #5539:
URL: https://github.com/apache/cloudstack/pull/5539#discussion_r721301467



##########
File path: 
plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
##########
@@ -892,6 +860,53 @@ private Answer execute(ResizeVolumeCommand cmd) {
                 _storageProcessor.expandDatastore(hostDatastoreSystem, dsMo);
             }
 
+            boolean datastoreChangeObserved = false;
+            boolean volumePathChangeObserved = false;
+
+            if (cmd.getContextParam(DiskTO.PROTOCOL_TYPE) != null && 
cmd.getContextParam(DiskTO.PROTOCOL_TYPE).equalsIgnoreCase(Storage.StoragePoolType.DatastoreCluster.toString()))
 {
+                VirtualMachineDiskInfoBuilder diskInfoBuilder = 
vmMo.getDiskInfoBuilder();
+                VirtualMachineDiskInfo matchingExistingDisk = 
getMatchingExistingDiskWithVolumeDetails(diskInfoBuilder, path, chainInfo, 
managed, cmd.get_iScsiName(), poolUUID, hyperHost, context);
+                if (diskInfoBuilder != null && matchingExistingDisk != null) {
+                    String[] diskChain = matchingExistingDisk.getDiskChain();
+                    DatastoreFile file = new DatastoreFile(diskChain[0]);
+                    if (!file.getFileBaseName().equalsIgnoreCase(path)) {
+                        if (s_logger.isInfoEnabled())
+                            s_logger.info("Detected disk-chain top file change 
on volume: " + path + " -> " + file.getFileBaseName());
+                        path = file.getFileBaseName();
+                        volumePathChangeObserved = true;
+                        chainInfo = _gson.toJson(matchingExistingDisk);
+                    }
+                    DatacenterMO dcMo = new 
DatacenterMO(hyperHost.getContext(), hyperHost.getHyperHostDatacenter());
+                    DatastoreMO diskDatastoreMofromVM = new 
DatastoreMO(context, dcMo.findDatastore(file.getDatastoreName()));
+                    if (diskDatastoreMofromVM != null) {
+                        String actualPoolUuid = 
diskDatastoreMofromVM.getCustomFieldValue(CustomFieldConstants.CLOUD_UUID);
+                        if (!actualPoolUuid.equalsIgnoreCase(poolUUID)) {
+                            s_logger.warn(String.format("Volume %s found to be 
in a different storage pool %s", path, actualPoolUuid));
+                            datastoreChangeObserved = true;
+                            poolUUID = actualPoolUuid;
+                            chainInfo = _gson.toJson(matchingExistingDisk);
+                        }
+                    }
+                }
+            }
+
+            // OfflineVmwareMigration: 5. ignore/replace the rest of the 
try-block; It is the functional bit
+            Pair<VirtualDisk, String> vdisk = vmMo.getDiskDevice(path);
+
+            if (vdisk == null) {
+                if (s_logger.isTraceEnabled()) {
+                    s_logger.trace("resize volume done (failed)");
+                }
+
+                throw new Exception("No such disk device: " + path);
+            }
+

Review comment:
       Moved all disk related validations to a separate method




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