mike-tutkowski commented on a change in pull request #2761: Add managed storage
pool constraints to MigrateWithVolume API method
URL: https://github.com/apache/cloudstack/pull/2761#discussion_r205228427
##########
File path:
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -2332,15 +2339,44 @@ protected void migrate(final VMInstanceVO vm, final
long srcHostId, final Deploy
return volumeToPoolObjectMap;
}
+ /**
+ * If we the volume is placed in a managed storage we execute the
following checks:
+ * <ul>
+ * <li> If the volume is not placed in a managed storage, then we do
not need to proceed with these checks
+ * <li> Cross cluster migration with cluster-wide storage pool.
Volumes in managed storage cannot be migrated out of their current pool.
Therefore, an exception is thrown.
+ * </ul>
+ */
+ protected void executeManagedStorageChecks(Host targetHost, StoragePoolVO
currentPool, VolumeVO volume) {
+ if (!currentPool.isManaged()) {
+ return;
+ }
+ if (currentPool.getClusterId() == targetHost.getClusterId()) {
Review comment:
Since currentPool.getClusterId() can be null (if the storage pool is zone
wide), you might want to reverse these if statements (like this):
if (ScopeType.ZONE.equals(currentPool.getScope())) {
return;
}
if (currentPool.getClusterId() == targetHost.getClusterId()) {
return;
}
Also, since getClusterId() for currentPool and targetHost both return an
Integer (not an int), you might want to perform the compare like this:
if (targetHost.getClusterId().equals(currentPool.getClusterId())) {
return;
}
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services