@@ -719,10 +719,8 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept
719719
720720 String userSpecifiedName = getVolumeNameFromCommand (cmd );
721721
722- VolumeVO volume = commitVolume (cmd , caller , owner , displayVolume , zoneId , diskOfferingId , provisioningType , size , minIops , maxIops , parentVolume , userSpecifiedName ,
722+ return commitVolume (cmd , caller , owner , displayVolume , zoneId , diskOfferingId , provisioningType , size , minIops , maxIops , parentVolume , userSpecifiedName ,
723723 _uuidMgr .generateUuid (Volume .class , cmd .getCustomId ()));
724-
725- return volume ;
726724 }
727725
728726 private VolumeVO commitVolume (final CreateVolumeCmd cmd , final Account caller , final Account owner , final Boolean displayVolume , final Long zoneId , final Long diskOfferingId ,
@@ -1044,6 +1042,7 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10441042 // the requested change
10451043
10461044 /* If this volume has never been beyond allocated state, short circuit everything and simply update the database. */
1045+ // We need to publish this event to usage_volume table
10471046 if (volume .getState () == Volume .State .Allocated ) {
10481047 s_logger .debug ("Volume is in the allocated state, but has never been created. Simply updating database with new size and IOPS." );
10491048
@@ -1057,7 +1056,8 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10571056 }
10581057
10591058 _volsDao .update (volume .getId (), volume );
1060-
1059+ UsageEventUtils .publishUsageEvent (EventTypes .EVENT_VOLUME_RESIZE , volume .getAccountId (), volume .getDataCenterId (), volume .getId (), volume .getName (),
1060+ volume .getDiskOfferingId (), volume .getTemplateId (), volume .getSize (), Volume .class .getName (), volume .getUuid ());
10611061 return volume ;
10621062 }
10631063
@@ -1134,7 +1134,7 @@ private void validateIops(Long minIops, Long maxIops) {
11341134
11351135 private VolumeVO orchestrateResizeVolume (long volumeId , long currentSize , long newSize , Long newMinIops , Long newMaxIops , Integer newHypervisorSnapshotReserve , Long newDiskOfferingId ,
11361136 boolean shrinkOk ) {
1137- VolumeVO volume = _volsDao .findById (volumeId );
1137+ final VolumeVO volume = _volsDao .findById (volumeId );
11381138 UserVmVO userVm = _userVmDao .findById (volume .getInstanceId ());
11391139 StoragePoolVO storagePool = _storagePoolDao .findById (volume .getPoolId ());
11401140 boolean isManaged = storagePool .isManaged ();
@@ -1209,14 +1209,8 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n
12091209 volService .resizeVolumeOnHypervisor (volumeId , newSize , hosts [0 ], instanceName );
12101210 }
12111211 }
1212-
1213- volume .setSize (newSize );
1214-
1215- _volsDao .update (volume .getId (), volume );
12161212 }
12171213
1218- volume = _volsDao .findById (volume .getId ());
1219-
12201214 if (newDiskOfferingId != null ) {
12211215 volume .setDiskOfferingId (newDiskOfferingId );
12221216 }
@@ -1229,20 +1223,18 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n
12291223
12301224 /* Update resource count for the account on primary storage resource */
12311225 if (!shrinkOk ) {
1232- _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), new Long ( newSize - currentSize ) );
1226+ _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), newSize - currentSize );
12331227 } else {
1234- _resourceLimitMgr .decrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), new Long ( currentSize - newSize ) );
1228+ _resourceLimitMgr .decrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), currentSize - newSize );
12351229 }
1230+
1231+ UsageEventUtils .publishUsageEvent (EventTypes .EVENT_VOLUME_RESIZE , volume .getAccountId (), volume .getDataCenterId (), volume .getId (), volume .getName (),
1232+ volume .getDiskOfferingId (), volume .getTemplateId (), volume .getSize (), Volume .class .getName (), volume .getUuid ());
1233+
12361234 return volume ;
1237- } catch (InterruptedException e ) {
1238- s_logger .warn ("failed get resize volume result" , e );
1239- throw new CloudRuntimeException (e .getMessage ());
1240- } catch (ExecutionException e ) {
1241- s_logger .warn ("failed get resize volume result" , e );
1242- throw new CloudRuntimeException (e .getMessage ());
1235+
12431236 } catch (Exception e ) {
1244- s_logger .warn ("failed get resize volume result" , e );
1245- throw new CloudRuntimeException (e .getMessage ());
1237+ throw new CloudRuntimeException ("Exception caught during resize volume operation of volume UUID: " + volume .getUuid (), e );
12461238 }
12471239 }
12481240
0 commit comments