mirror of https://github.com/apache/cloudstack.git
Fix to create instances with smaller templates (< 1 GB) on PowerFlex/ScaleIO storage (#11211)
* Fix to create instances with smaller templates (< 1 GB) on PowerFlex/ScaleIO storage * code improvements
This commit is contained in:
parent
23de6c7db4
commit
d5f6b7cd1d
|
|
@ -1230,13 +1230,13 @@ public class ScaleIOPrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
|||
}
|
||||
|
||||
org.apache.cloudstack.storage.datastore.api.Volume scaleIOVolume = client.getVolume(scaleIOVolumeId);
|
||||
long newSizeInGB = newSizeInBytes / (1024 * 1024 * 1024);
|
||||
long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
|
||||
double newSizeInGB = newSizeInBytes / (1024.0 * 1024 * 1024);
|
||||
long newSizeIn8GBBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
|
||||
|
||||
if (scaleIOVolume.getSizeInKb() == newSizeIn8gbBoundary << 20) {
|
||||
if (scaleIOVolume.getSizeInKb() == newSizeIn8GBBoundary << 20) {
|
||||
logger.debug("No resize necessary at API");
|
||||
} else {
|
||||
scaleIOVolume = client.resizeVolume(scaleIOVolumeId, (int) newSizeIn8gbBoundary);
|
||||
scaleIOVolume = client.resizeVolume(scaleIOVolumeId, (int) newSizeIn8GBBoundary);
|
||||
if (scaleIOVolume == null) {
|
||||
throw new CloudRuntimeException("Failed to resize volume: " + volumeInfo.getName());
|
||||
}
|
||||
|
|
@ -1362,12 +1362,12 @@ public class ScaleIOPrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
|||
|
||||
@Override
|
||||
public long getVolumeSizeRequiredOnPool(long volumeSize, Long templateSize, boolean isEncryptionRequired) {
|
||||
long newSizeInGB = volumeSize / (1024 * 1024 * 1024);
|
||||
double newSizeInGB = volumeSize / (1024.0 * 1024 * 1024);
|
||||
if (templateSize != null && isEncryptionRequired && needsExpansionForEncryptionHeader(templateSize, volumeSize)) {
|
||||
newSizeInGB = (volumeSize + (1<<30)) / (1024 * 1024 * 1024);
|
||||
newSizeInGB = (volumeSize + (1<<30)) / (1024.0 * 1024 * 1024);
|
||||
}
|
||||
long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
|
||||
return newSizeIn8gbBoundary * (1024 * 1024 * 1024);
|
||||
long newSizeIn8GBBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
|
||||
return newSizeIn8GBBoundary * (1024 * 1024 * 1024);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -555,6 +555,18 @@ public class ScaleIOPrimaryDataStoreDriverTest {
|
|||
|
||||
@Test
|
||||
public void testGetVolumeSizeRequiredOnPool() {
|
||||
Assert.assertEquals(8L * (1024 * 1024 * 1024),
|
||||
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
|
||||
52428800,
|
||||
null,
|
||||
false));
|
||||
|
||||
Assert.assertEquals(8L * (1024 * 1024 * 1024),
|
||||
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
|
||||
52428800,
|
||||
52428800L,
|
||||
true));
|
||||
|
||||
Assert.assertEquals(16L * (1024 * 1024 * 1024),
|
||||
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
|
||||
10L * (1024 * 1024 * 1024),
|
||||
|
|
|
|||
|
|
@ -139,6 +139,9 @@ public class StorPoolStorageAdaptor implements StorageAdaptor {
|
|||
}
|
||||
|
||||
public static String getVolumeNameFromPath(final String volumeUuid, boolean tildeNeeded) {
|
||||
if (volumeUuid == null) {
|
||||
return null;
|
||||
}
|
||||
if (volumeUuid.startsWith("/dev/storpool/")) {
|
||||
return volumeUuid.split("/")[3];
|
||||
} else if (volumeUuid.startsWith("/dev/storpool-byid/")) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue