@@ -349,7 +349,7 @@ public VolumeManagerImpl() {
349349 public VolumeInfo moveVolume (VolumeInfo volume , long destPoolDcId ,
350350 Long destPoolPodId , Long destPoolClusterId ,
351351 HypervisorType dataDiskHyperType )
352- throws ConcurrentOperationException {
352+ throws ConcurrentOperationException {
353353
354354 // Find a destination storage pool with the specified criteria
355355 DiskOfferingVO diskOffering = _diskOfferingDao .findById (volume
@@ -411,7 +411,7 @@ public VolumeVO uploadVolume(UploadVolumeCmd cmd)
411411
412412 private boolean validateVolume (Account caller , long ownerId , Long zoneId ,
413413 String volumeName , String url , String format )
414- throws ResourceAllocationException {
414+ throws ResourceAllocationException {
415415
416416 // permission check
417417 _accountMgr .checkAccess (caller , null , true ,
@@ -480,17 +480,17 @@ private boolean validateVolume(Account caller, long ownerId, Long zoneId,
480480 && !url .toLowerCase ().endsWith ("qcow2.zip" )
481481 && !url .toLowerCase ().endsWith ("qcow2.bz2" ) && !url
482482 .toLowerCase ().endsWith ("qcow2.gz" )))
483- || (format .equalsIgnoreCase ("ova" ) && (!url .toLowerCase ()
484- .endsWith (".ova" )
485- && !url .toLowerCase ().endsWith ("ova.zip" )
486- && !url .toLowerCase ().endsWith ("ova.bz2" ) && !url
487- .toLowerCase ().endsWith ("ova.gz" )))
488- || (format .equalsIgnoreCase ("raw" ) && (!url .toLowerCase ()
489- .endsWith (".img" ) && !url .toLowerCase ().endsWith ("raw" )))) {
483+ || (format .equalsIgnoreCase ("ova" ) && (!url .toLowerCase ()
484+ .endsWith (".ova" )
485+ && !url .toLowerCase ().endsWith ("ova.zip" )
486+ && !url .toLowerCase ().endsWith ("ova.bz2" ) && !url
487+ .toLowerCase ().endsWith ("ova.gz" )))
488+ || (format .equalsIgnoreCase ("raw" ) && (!url .toLowerCase ()
489+ .endsWith (".img" ) && !url .toLowerCase ().endsWith ("raw" )))) {
490490 throw new InvalidParameterValueException (
491491 "Please specify a valid URL. URL:" + url
492- + " is an invalid for the format "
493- + format .toLowerCase ());
492+ + " is an invalid for the format "
493+ + format .toLowerCase ());
494494 }
495495 UriUtils .validateUrl (url );
496496
@@ -908,26 +908,26 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd)
908908
909909 if (isCustomizedIops != null ) {
910910 if (isCustomizedIops ) {
911- minIops = cmd .getMinIops ();
912- maxIops = cmd .getMaxIops ();
913-
914- if (minIops == null && maxIops == null ) {
915- minIops = 0L ;
916- maxIops = 0L ;
917- }
918- else {
911+ minIops = cmd .getMinIops ();
912+ maxIops = cmd .getMaxIops ();
913+
914+ if (minIops == null && maxIops == null ) {
915+ minIops = 0L ;
916+ maxIops = 0L ;
917+ }
918+ else {
919919 if (minIops == null || minIops <= 0 ) {
920920 throw new InvalidParameterValueException ("The min IOPS must be greater than 0." );
921921 }
922922
923- if (maxIops == null ) {
924- maxIops = 0L ;
925- }
923+ if (maxIops == null ) {
924+ maxIops = 0L ;
925+ }
926926
927- if (minIops > maxIops ) {
928- throw new InvalidParameterValueException ("The min IOPS must be less than or equal to the max IOPS." );
929- }
930- }
927+ if (minIops > maxIops ) {
928+ throw new InvalidParameterValueException ("The min IOPS must be less than or equal to the max IOPS." );
929+ }
930+ }
931931 }
932932 else {
933933 minIops = diskOffering .getMinIops ();
@@ -936,10 +936,10 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd)
936936 }
937937
938938 if (!validateVolumeSizeRange (size )) {// convert size from mb to gb
939- // for validation
939+ // for validation
940940 throw new InvalidParameterValueException (
941941 "Invalid size for custom volume creation: " + size
942- + " ,max volume size is:" + _maxVolumeSizeInGb );
942+ + " ,max volume size is:" + _maxVolumeSizeInGb );
943943 }
944944 } else { // create volume from snapshot
945945 Long snapshotId = cmd .getSnapshotId ();
@@ -960,7 +960,7 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd)
960960 diskOffering = _diskOfferingDao .findById (diskOfferingId );
961961 zoneId = snapshotCheck .getDataCenterId ();
962962 size = snapshotCheck .getSize (); // ; disk offering is used for tags
963- // purposes
963+ // purposes
964964
965965 // check snapshot permissions
966966 _accountMgr .checkAccess (caller , null , true , snapshotCheck );
@@ -1314,7 +1314,7 @@ public boolean deleteVolume(long volumeId, Account caller)
13141314
13151315 _accountMgr .checkAccess (caller , null , true , volume );
13161316
1317- if (volume .getInstanceId () != null ) {
1317+ if (volume .getInstanceId () != null ) {
13181318 throw new InvalidParameterValueException (
13191319 "Please specify a volume that is not attached to any VM." );
13201320 }
@@ -1358,9 +1358,20 @@ storage count (in case of upload volume). */
13581358 _usageEventDao .persist (usageEvent );
13591359 }
13601360 }
1361- AsyncCallFuture <VolumeApiResult > future = volService .expungeVolumeAsync (volFactory .getVolume (volume .getId ()));
1362- future .get ();
1363-
1361+ // expunge volume from primary if volume is on primary
1362+ VolumeInfo volOnPrimary = volFactory .getVolume (volume .getId (), DataStoreRole .Primary );
1363+ if (volOnPrimary != null ) {
1364+ s_logger .info ("Expunging volume " + volume .getId () + " from primary data store" );
1365+ AsyncCallFuture <VolumeApiResult > future = volService .expungeVolumeAsync (volOnPrimary );
1366+ future .get ();
1367+ }
1368+ // expunge volume from secondary if volume is on image store
1369+ VolumeInfo volOnSecondary = volFactory .getVolume (volume .getId (), DataStoreRole .Image );
1370+ if (volOnSecondary != null ) {
1371+ s_logger .info ("Expunging volume " + volume .getId () + " from secondary data store" );
1372+ AsyncCallFuture <VolumeApiResult > future2 = volService .expungeVolumeAsync (volOnSecondary );
1373+ future2 .get ();
1374+ }
13641375 } catch (Exception e ) {
13651376 s_logger .warn ("Failed to expunge volume:" , e );
13661377 return false ;
@@ -1647,7 +1658,7 @@ private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volumeToAttach, L
16471658 volumeToAttach = _volsDao .findById (volumeToAttach .getId ());
16481659
16491660 if (volumeToAttachStoragePool .isManaged () &&
1650- volumeToAttach .getPath () == null ) {
1661+ volumeToAttach .getPath () == null ) {
16511662 volumeToAttach .setPath (answer .getDisk ().getVdiUuid ());
16521663
16531664 _volsDao .update (volumeToAttach .getId (), volumeToAttach );
@@ -1659,8 +1670,8 @@ private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volumeToAttach, L
16591670 // insert record for disk I/O statistics
16601671 VmDiskStatisticsVO diskstats = _vmDiskStatsDao .findBy (vm .getAccountId (), vm .getDataCenterId (),vm .getId (), volumeToAttach .getId ());
16611672 if (diskstats == null ) {
1662- diskstats = new VmDiskStatisticsVO (vm .getAccountId (), vm .getDataCenterId (),vm .getId (), volumeToAttach .getId ());
1663- _vmDiskStatsDao .persist (diskstats );
1673+ diskstats = new VmDiskStatisticsVO (vm .getAccountId (), vm .getDataCenterId (),vm .getId (), volumeToAttach .getId ());
1674+ _vmDiskStatsDao .persist (diskstats );
16641675 }
16651676
16661677 return _volsDao .findById (volumeToAttach .getId ());
@@ -2033,7 +2044,7 @@ public Volume detachVolumeFromVM(DetachVolumeCmd cmmd) {
20332044 @ DB
20342045 protected VolumeVO switchVolume (VolumeVO existingVolume ,
20352046 VirtualMachineProfile <? extends VirtualMachine > vm )
2036- throws StorageUnavailableException {
2047+ throws StorageUnavailableException {
20372048 Transaction txn = Transaction .currentTxn ();
20382049
20392050 Long templateIdToUse = null ;
@@ -2340,14 +2351,14 @@ private static enum VolumeTaskType {
23402351 MIGRATE
23412352 }
23422353 private static class VolumeTask {
2343- final VolumeTaskType type ;
2344- final StoragePoolVO pool ;
2345- final VolumeVO volume ;
2346- VolumeTask (VolumeTaskType type , VolumeVO volume , StoragePoolVO pool ) {
2347- this .type = type ;
2348- this .pool = pool ;
2349- this .volume = volume ;
2350- }
2354+ final VolumeTaskType type ;
2355+ final StoragePoolVO pool ;
2356+ final VolumeVO volume ;
2357+ VolumeTask (VolumeTaskType type , VolumeVO volume , StoragePoolVO pool ) {
2358+ this .type = type ;
2359+ this .pool = pool ;
2360+ this .volume = volume ;
2361+ }
23512362 }
23522363
23532364 private List <VolumeTask > getTasks (List <VolumeVO > vols , Map <Volume , StoragePool > destVols ) throws StorageUnavailableException {
@@ -2448,7 +2459,7 @@ private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, VirtualMachinePro
24482459 DataStore destPool = null ;
24492460 if (recreate
24502461 && (dest .getStorageForDisks () == null || dest
2451- .getStorageForDisks ().get (vol ) == null )) {
2462+ .getStorageForDisks ().get (vol ) == null )) {
24522463 destPool = dataStoreMgr .getDataStore (vol .getPoolId (), DataStoreRole .Primary );
24532464 s_logger .debug ("existing pool: " + destPool .getId ());
24542465 } else {
@@ -2605,8 +2616,8 @@ public boolean configure(String name, Map<String, Object> params)
26052616 .getValue (Config .CustomDiskOfferingMinSize .toString ());
26062617 _customDiskOfferingMinSize = NumbersUtil .parseInt (
26072618 _customDiskOfferingMinSizeStr , Integer
2608- .parseInt (Config .CustomDiskOfferingMinSize
2609- .getDefaultValue ()));
2619+ .parseInt (Config .CustomDiskOfferingMinSize
2620+ .getDefaultValue ()));
26102621
26112622 String maxVolumeSizeInGbString = _configDao
26122623 .getValue ("storage.max.volume.size" );
0 commit comments